Changeset View
Changeset View
Standalone View
Standalone View
autotests/html/test.octave.html
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 43 | <span style="font-weight:bold;">classdef</span> polynomial2 | |||
---|---|---|---|---|---|
48 | <span style="font-weight:bold;">methods</span> | 48 | <span style="font-weight:bold;">methods</span> | ||
49 | <span style="font-weight:bold;">function</span> p = polynomial2 (a) | 49 | <span style="font-weight:bold;">function</span> p = polynomial2 (a) | ||
50 | <span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">nargin</span> > <span style="color:#b08000;">1</span>) | 50 | <span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">nargin</span> > <span style="color:#b08000;">1</span>) | ||
51 | <span style="color:#644a9b;">print_usage</span> (); | 51 | <span style="color:#644a9b;">print_usage</span> (); | ||
52 | <span style="font-weight:bold;">endif</span> | 52 | <span style="font-weight:bold;">endif</span> | ||
53 | 53 | | |||
54 | <span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">nargin</span> == <span style="color:#b08000;">1</span>) | 54 | <span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">nargin</span> == <span style="color:#b08000;">1</span>) | ||
55 | <span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">isa</span> (a, <span style="color:#bf0303;">"polynomial2"</span>)) | 55 | <span style="font-weight:bold;">if</span> (<span style="color:#644a9b;">isa</span> (a, <span style="color:#bf0303;">"polynomial2"</span>)) | ||
56 | p.<span style="color:#644a9b;">poly</span> = a.<span style="color:#644a9b;">poly</span>; | 56 | p.poly = a.poly; | ||
57 | <span style="font-weight:bold;">elseif</span> (<span style="color:#644a9b;">isreal</span> (a) && <span style="color:#644a9b;">isvector</span> (a)) | 57 | <span style="font-weight:bold;">elseif</span> (<span style="color:#644a9b;">isreal</span> (a) && <span style="color:#644a9b;">isvector</span> (a)) | ||
58 | p.<span style="color:#644a9b;">poly</span> = a(:).'; <span style="color:#898887;"># force row vector</span> | 58 | p.poly = a(:).'; <span style="color:#898887;"># force row vector</span> | ||
59 | <span style="font-weight:bold;">else</span> | 59 | <span style="font-weight:bold;">else</span> | ||
60 | <span style="color:#644a9b;">error</span> (<span style="color:#bf0303;">"polynomial2: A must be a real vector"</span>); | 60 | <span style="color:#644a9b;">error</span> (<span style="color:#bf0303;">"polynomial2: A must be a real vector"</span>); | ||
61 | <span style="font-weight:bold;">endif</span> | 61 | <span style="font-weight:bold;">endif</span> | ||
62 | <span style="font-weight:bold;">endif</span> | 62 | <span style="font-weight:bold;">endif</span> | ||
63 | <span style="font-weight:bold;">endfunction</span> | 63 | <span style="font-weight:bold;">endfunction</span> | ||
64 | 64 | | |||
65 | <span style="font-weight:bold;">function</span> <span style="color:#644a9b;">disp</span> (p) | 65 | <span style="font-weight:bold;">function</span> <span style="color:#644a9b;">disp</span> (p) | ||
66 | a = p.<span style="color:#644a9b;">poly</span>; | 66 | a = p.poly; | ||
67 | first = <span style="color:#644a9b;">true</span>; | 67 | first = <span style="color:#644a9b;">true</span>; | ||
68 | <span style="font-weight:bold;">for</span> <span style="color:#644a9b;">i</span> = <span style="color:#b08000;">1</span> : <span style="color:#644a9b;">length</span> (a); | 68 | <span style="font-weight:bold;">for</span> <span style="color:#644a9b;">i</span> = <span style="color:#b08000;">1</span> : <span style="color:#644a9b;">length</span> (a); | ||
69 | <span style="font-weight:bold;">if</span> (a(<span style="color:#644a9b;">i</span>) != <span style="color:#b08000;">0</span>) | 69 | <span style="font-weight:bold;">if</span> (a(<span style="color:#644a9b;">i</span>) != <span style="color:#b08000;">0</span>) | ||
70 | <span style="font-weight:bold;">if</span> (first) | 70 | <span style="font-weight:bold;">if</span> (first) | ||
71 | first = <span style="color:#644a9b;">false</span>; | 71 | first = <span style="color:#644a9b;">false</span>; | ||
72 | <span style="font-weight:bold;">elseif</span> (a(<span style="color:#644a9b;">i</span>) > <span style="color:#b08000;">0</span> || <span style="color:#644a9b;">isnan</span> (a(<span style="color:#644a9b;">i</span>))) | 72 | <span style="font-weight:bold;">elseif</span> (a(<span style="color:#644a9b;">i</span>) > <span style="color:#b08000;">0</span> || <span style="color:#644a9b;">isnan</span> (a(<span style="color:#644a9b;">i</span>))) | ||
73 | <span style="color:#644a9b;">printf</span> (<span style="color:#bf0303;">" +"</span>); | 73 | <span style="color:#644a9b;">printf</span> (<span style="color:#bf0303;">" +"</span>); | ||
74 | <span style="font-weight:bold;">endif</span> | 74 | <span style="font-weight:bold;">endif</span> | ||
Show All 25 Lines |