Mercurial > repos > public > sbplib
comparison vandermonde.m @ 890:c70131daaa6e feature/d1_staggered
Merge with feature/poroelastic.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Wed, 21 Nov 2018 18:29:29 -0800 |
parents | 0090a86d8b72 |
children |
comparison
equal
deleted
inserted
replaced
885:18e10217dca9 | 890:c70131daaa6e |
---|---|
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 |