comparison vandermonde.m @ 770:0090a86d8b72 feature/grids

Improve mononomial and vandermonde functions to work in multiple dimension and adapt to sym or double inputs
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 27 Jun 2018 11:10:52 +0200
parents 184833fe4c0e
children
comparison
equal deleted inserted replaced
769:e958ed76e484 770:0090a86d8b72
1 % Create vandermonde matrix for points x and polynomials of order p 1 % Create vandermonde matrix for points x and polynomials of order p
2 % x and p are vectors 2 % x is a list of N points of size [N,dim],
3 % v is a length(x) by length(p) matrix 3 % p is a list of polynomial orders of size [M, dim].
4 % the given mononomials are evaluated and the NxM matrix V is returned.
4 function V = vandermonde(x, p) 5 function V = vandermonde(x, p)
5 V = sym(zeros(length(x), length(p))); % Is there a way to make this work for both double and sym 6 assert(size(x,2) == size(p,2), 'x and p must have the same number of columns')
7 n = size(x,1);
8 m = size(p,1);
6 9
7 for i = 1:length(p) 10 for i = 1:m
8 V(:, i) = mononomial(x,p(i)); 11 V(:,i) = mononomial(x, p(i,:));
9 end 12 end
13
14 assertSize(V,[n,m]);
10 end 15 end