from
A Vandermonde matrix inversion
by Steven Huang
The M-file inverses a kind of Vandermonde matrix by using Stirling polynomial coefficients.
|
| VanInverse(B)
|
function A = VanInverse(B)
% This function inverse a Vandermonde Matrix B.
% Matrix B is a n-by-n matrix, its (i,j) entry is i^(j-1),
% where i,j = 1,2,...,n
% for example, n = 4
% B =
% 1 1 1 1
% 1 2 4 8
% 1 3 9 27
% 1 4 16 64
% This routine uses a Stirling polynomial(the first kind) coefficients
% For fast operation, a C Stirling coefficient function has
% been posted with name: mStirling.c. The C-version of this
% inverse function is also available upon request.
n = size(B,1);
A = zeros(n,n);
% compute the Stirling coeffs (by column), could use mStirling.c
for (i=1:n)
if (i==1)
k = 3;
coeff = [1 -2];
else
k = 2;
coeff = [1 -1];
end
while (k<=n)
if (k == i);
k = k + 1;
continue;
else
coeff = conv(coeff, [1 -k]);
k = k + 1;
end
end
A(:,i) = coeff' .* ((-1).^(n-i)/(factorial(n-i)*factorial(i-1)));
end
A = flipud(A);
|
|
Contact us at files@mathworks.com