rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
test_power_vector2.m
Go to the documentation of this file.
1 function OK = test_power_vector2
2 %function OK = test_power_vector2
3 % function testing the powervectors and its derivatives, i.e. check
4 % whether finite difference approximates the derivative.
5 
6 % Bernard Haasdonk 28.8.2009
7 
8 OK = 1;
9 
10 pdeg = 4;
11 
12 for n = 1:100
13  x = rand(1,2);
14  h = 1e-7;
15 
16  for p = 1:pdeg
17  D = power_vector2_derivative(x,p);
18 
19  d1 = (power_vector2(x+[h,0],p)-power_vector2(x,p))/h;
20  d2 = (power_vector2(x+[0,h],p)-power_vector2(x,p))/h;
21 
22  Dappr = [d1,d2];
23 
24  maxerr = max(max(abs(Dappr-D)));
25 % disp(['p = ',num2str(p),', maxerr =',num2str(maxerr)]);
26 
27  if (maxerr>1e-5)
28  OK = 0;
29  return;
30  end;
31 
32  end;
33 end;%| \docupdate