1 function res = power_vector2(x,pdeg)
2 %
function res = power_vector2(x,pdeg)
4 %
function computing the vector of all monomials of degree pdeg of
5 % the vector x, which is assumed to be 2-dimensional (resp: only
6 % first two entries are used)
7 % monomials up to deg 4 are explicitly implemented, hence fast,
8 % higher degrees are computed recursively. If using higher degree
9 % more often, simply insert explicit functions into case select list.
11 % Bernard Haasdonk 29.1.2009
19 res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2]
';
21 res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2,...
22 x(1)^3, x(1)^2*x(2), x(1) * x(2)^2, x(2)^3]';
24 res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2,...
25 x(1)^3, x(1)^2*x(2), x(1) * x(2)^2, x(2)^3,...
26 x(1)^4, x(1)^3*x(2), x(1)^2*x(2)^2, x(1)* x(2)^3, x(2)^4]
';
28 disp(['if using this pdeg more frequently, include in power_vector2
', ...
29 'explicitly
for increased performance
'])
31 error('only integers as pdeg allowed!
');
33 % recursive definition
34 pv_pmin1 = power_vector2(x,pdeg-1);
35 pv_new = x(1).^(pdeg:-1:0)'.* x(2).^(0:pdeg)
';
36 res = [pv_pmin1; pv_new];