Mercurial > hg > octave-avbm
changeset 13881:da929884f51e
vander.m: Update coding style
* vander.m: Update coding style
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 17 Nov 2011 11:32:50 -0800 |
parents | 1dc120c06ce0 |
children | ecf0c6bca0c9 c71a4c53e70a |
files | scripts/special-matrix/vander.m |
diffstat | 1 files changed, 20 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/special-matrix/vander.m +++ b/scripts/special-matrix/vander.m @@ -60,37 +60,36 @@ print_usage (); endif - if (isvector (c)) - retval = zeros (length (c), n, class (c)); - ## avoiding many ^s appears to be faster for n >= 100. - d = 1; - c = c(:); - for i = n:-1:1 - retval(:,i) = d; - d = c .* d; - endfor - else - error ("vander: argument must be a vector"); + if (! isvector (c)) + error ("vander: polynomial C must be a vector"); endif + ## avoiding many ^s appears to be faster for n >= 100. + retval = zeros (length (c), n, class (c)); + d = 1; + c = c(:); + for i = n:-1:1 + retval(:,i) = d; + d .*= c; + endfor + endfunction + %!test %! c = [0,1,2,3]; %! expect = [0,0,0,1; 1,1,1,1; 8,4,2,1; 27,9,3,1]; -%! result = vander(c); -%! assert(expect, result); +%! assert(vander (c), expect); -%!assert((vander (1) == 1 && vander ([1, 2, 3]) == vander ([1; 2; 3]) -%! && vander ([1, 2, 3]) == [1, 1, 1; 4, 2, 1; 9, 3, 1] -%! && vander ([1, 2, 3]*i) == [-1, i, 1; -4, 2i, 1; -9, 3i, 1])); +%!assert (vander (1), 1) +%!assert (vander ([1, 2, 3]), vander ([1; 2; 3])) +%!assert (vander ([1, 2, 3]), [1, 1, 1; 4, 2, 1; 9, 3, 1]) +%!assert (vander ([1, 2, 3]*i), [-1, i, 1; -4, 2i, 1; -9, 3i, 1]) %!assert(vander (2, 3), [4, 2, 1]) %!assert(vander ([2, 3], 3), [4, 2, 1; 9, 3, 1]) -%!error vander ([1, 2; 3, 4]); +%!error vander (); +%!error vander (1, 2, 3); +%!error <polynomial C must be a vector> vander ([1, 2; 3, 4]); -%!error vander (); - -%!error vander (1, 2, 3); -