Mercurial > hg > octave-terminal
changeset 7387:b429b21abdd4
[project @ 2008-01-15 21:43:11 by jwe]
author | jwe |
---|---|
date | Tue, 15 Jan 2008 21:43:11 +0000 |
parents | 22815fa9c368 |
children | 0e1ccfe1bf91 |
files | scripts/ChangeLog scripts/special-matrix/vander.m |
diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,7 @@ 2008-01-15 Thomas Weber <thomas.weber.mail@gmail.com> + * special-matrix/vander.m: Vectorize. New test. + * elfun/acot.m, elfun/acoth.m, elfun/acsc.m, elfun/acsch.m, elfun/asec.m, elfun/asech.m, elfun/cot.m, elfun/coth.m, elfun/csc.m,elfun/csch.m, elfun/lcm.m, elfun/sec.m, elfun/sech.m,
--- a/scripts/special-matrix/vander.m +++ b/scripts/special-matrix/vander.m @@ -1,5 +1,5 @@ ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, -## 2004, 2005, 2006, 2007 John W. Eaton +## 2004, 2005, 2006, 2007, 2008 John W. Eaton ## ## This file is part of Octave. ## @@ -58,13 +58,15 @@ if (isvector (c)) n = length (c); - retval = zeros (n, n); - j = 1:n; - for i = 1:n - retval(i,:) = c(i) .^ (n - j); - endfor + retval = (c(:) * ones (1, n)) .^ (ones (n, 1) * (n-1:-1:0)); else error ("vander: argument must be a vector"); endif 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);