Mercurial > hg > octave-nkf
diff scripts/special-matrix/vander.m @ 9137:eebc7f8e7398
extend vander to allow specified number of columns
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 20 Apr 2009 11:43:14 +0200 |
parents | e0250e2b60ed |
children | c309e028185e |
line wrap: on
line diff
--- a/scripts/special-matrix/vander.m +++ b/scripts/special-matrix/vander.m @@ -19,8 +19,10 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} vander (@var{c}) +## @deftypefn {Function File} {} vander (@var{c}, @var{n}) ## Return the Vandermonde matrix whose next to last column is @var{c}. +## If @var{n} is specified, it determines the number of columns; +## otherwise, @var{n} is taken to be equal to the length of @var{c}. ## ## A Vandermonde matrix has the form: ## @iftex @@ -51,15 +53,16 @@ ## Author: jwe -function retval = vander (c) +function retval = vander (c, n) - if (nargin != 1) + if (nargin == 1) + n = length (c); + elseif (nargin != 2) print_usage (); endif if (isvector (c)) - n = length (c); - retval = zeros (n, n, class (c)); + retval = zeros (length (c), n, class (c)); ## avoiding many ^s appears to be faster for n >= 100. d = 1; c = c(:);