rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
power_vector2_derivative.m
1 function res = power_vector2_derivative(x,pdeg)
2 %function res = power_vector2_derivative(x,pdeg)
3 %
4 % function computing the derivative of the power-vector, which is
5 % the vector of all monomials of degree pdeg of
6 % the vector x, which is assumed to be 2-dimensional (resp: only
7 % first two entries are used)
8 %
9 % res hence is a jacobian matrix of size num_monomials x 2 matrix.
10 
11 % Bernard Haasdonk 28.8.2009
12 
13 switch pdeg
14  case 0
15 % res = [1];
16  res =[0,0];
17  case 1
18  % res = [1;x(:)];
19  res = [0,0 ; ...
20  1,0 ; ...
21  0,1 ];
22  case 2
23 % res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2]';
24 % res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2]';
25  res = [0,0 ; ...
26  1,0 ; ...
27  0,1 ; ...
28  2*x(1),0 ; ...
29  x(2),x(1) ; ...
30  0,2*x(2)];
31  case 3
32 % res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2,...
33 % x(1)^3, x(1)^2*x(2), x(1) * x(2)^2, x(2)^3]';
34  res = [0,0 ; ...
35  1,0 ; ...
36  0,1 ; ...
37  2*x(1),0 ; ...
38  x(2),x(1) ; ...
39  0,2*x(2) ; ...
40  3*x(1)^2, 0; ...
41  2*x(1)*x(2),x(1)^2; ...
42  x(2)^2,x(1)*x(2)*2; ...
43  0, 3*x(2)^2];
44  case 4
45 % res = [1,x(1),x(2),x(1)^2, x(1)*x(2),x(2)^2,...
46 % x(1)^3, x(1)^2*x(2), x(1) * x(2)^2, x(2)^3,...
47 % x(1)^4, x(1)^3*x(2), x(1)^2*x(2)^2, x(1)* x(2)^3, x(2)^4]';
48  res = [0,0 ; ...
49  1,0 ; ...
50  0,1 ; ...
51  2*x(1),0 ; ...
52  x(2),x(1) ; ...
53  0,2*x(2) ; ...
54  3*x(1)^2, 0; ...
55  2*x(1)*x(2),x(1)^2; ...
56  x(2)^2,x(1)*x(2)*2; ...
57  0, 3*x(2)^2; ...
58  4*x(1)^3, 0; ...
59  3*x(1)^2*x(2), x(1)^3; ...
60  2*x(1)*x(2)^2,x(1)^2*2*x(2); ...
61  x(2)^3,x(1)*3* x(2)^2; ...
62  0,4*x(2)^3];
63  otherwise
64  error('powervector not defined for desired pdeg')
65 end;
66 %| \docupdate