[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Change to vander.m
From: |
Thomas Weber |
Subject: |
Re: Change to vander.m |
Date: |
Wed, 16 Jan 2008 22:00:40 +0100 |
Am Dienstag, den 15.01.2008, 16:43 -0500 schrieb John W. Eaton:
> On 15-Jan-2008, Thomas Weber wrote:
> | ? plot/.hg
> | Index: special-matrix/vander.m
> | ===================================================================
> | RCS file: /cvs/octave/scripts/special-matrix/vander.m,v
> | retrieving revision 1.25
> | diff -u -r1.25 vander.m
> | --- special-matrix/vander.m 12 Oct 2007 21:27:26 -0000 1.25
> | +++ special-matrix/vander.m 15 Jan 2008 20:23:18 -0000
> | @@ -58,13 +58,17 @@
> |
> | if (isvector (c))
> | n = length (c);
> | - retval = zeros (n, n);
> | - j = 1:n;
> | - for i = 1:n
> | - retval(i,:) = c(i) .^ (n - j);
> | - endfor
> | + N = ones(n,1) * [n-1:-1:0];
> | + C = c(:) * ones(1,n);
> | + retval = C .^ N;
>
> Is there any need for the variables N and C? why not just write
>
> retval = (c(:) * ones (1, n)) .^ (ones (n, 1) * (n-1:-1:0));
I used them to check what I'm doing.
Thomas