Mercurial > matrix-functions
comparison toolbox/vand.m @ 2:c124219d7bfa draft
Re-add the 1995 toolbox after noticing the statement in the ~higham/mctoolbox/ webpage.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Thu, 07 May 2015 18:36:24 +0200 |
parents | 8f23314345f4 |
children |
comparison
equal
deleted
inserted
replaced
1:e471a92d17be | 2:c124219d7bfa |
---|---|
1 function V = vand(m, p) | |
2 %VAND Vandermonde matrix. | |
3 % V = VAND(P), where P is a vector, produces the (primal) | |
4 % Vandermonde matrix based on the points P, i.e. V(i,j) = P(j)^(i-1). | |
5 % VAND(M,P) is a rectangular version of VAND(P) with M rows. | |
6 % Special case: If P is a scalar then P equally spaced points on [0,1] | |
7 % are used. | |
8 | |
9 % Reference: | |
10 % N.J. Higham, Stability analysis of algorithms for solving | |
11 % confluent Vandermonde-like systems, SIAM J. Matrix Anal. Appl., | |
12 % 11 (1990), pp. 23-41. | |
13 | |
14 if nargin == 1, p = m; end | |
15 n = max(size(p)); | |
16 | |
17 % Handle scalar p. | |
18 if n == 1 | |
19 n = p; | |
20 p = seqa(0,1,n); | |
21 end | |
22 | |
23 if nargin == 1, m = n; end | |
24 | |
25 p = p(:).'; % Ensure p is a row vector. | |
26 V = ones(m,n); | |
27 for i=2:m | |
28 V(i,:) = p.*V(i-1,:); | |
29 end |