Mercurial > hg > octave-max
changeset 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 | 537a73861cb7 |
children | 436b498b0506 |
files | scripts/ChangeLog scripts/special-matrix/vander.m |
diffstat | 2 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-04-20 Jaroslav Hajek <highegg@gmail.com> + + * special-matrix/vander.m: Allow second argument. + 2009-04-17 Rik <rdrider0-list@yahoo.com> * plot/__marching_cube__.m: Correct help Texinfo so manual will compile
--- 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(:);