Mercurial > repos > public > sbplib
comparison mononomial.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 function y = mononomial(x, k) | 1 % calculate a N-D mononomial with powers k in points x: |
2 if k < 0 | 2 % z = x(:,1).^k(1) * x(:,2).^k(2) * ... |
3 y = x*0; | 3 function z = mononomial(x, k) |
4 assert(size(x,2) == length(k), 'k must have the same length as the width of x'); | |
5 | |
6 if any(k < 0) | |
7 z = x(:,1)*0; | |
4 return | 8 return |
5 end | 9 end |
6 y = x.^k/factorial(k); | 10 |
11 denom = prod(factorial(k)); | |
12 | |
13 for i = 1:length(k) | |
14 x(:,i) = x(:,i).^k(i); | |
15 end | |
16 z = prod(x,2)/denom; | |
7 end | 17 end |
8 |