rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_ds_estimate_bound_constants.m
1 function [C1,C2] = lin_ds_estimate_bound_constants(model,model_data)
2 %function [C1,C2] = lin_ds_estimate_bound_constants(model,model_data)
3 %
4 % function estimating the constant
5 % \verbatim @f$ C1 >= ||expm(A(mu) t)||_G for all t @f$ \endverbatim
6 %
7 % and
8 %
9 % \verbatim @f$ C2 >= |C(mu)|_G @f$ \endverbatim
10 
11 % Bernard Haasdonk 3.4.2009
12 
13 C1 = 0;
14 C2 = 0;
15 
16 nmu = model.estimate_lin_ds_nmu;
17 nX = model.estimate_lin_ds_nX;
18 nt = model.estimate_lin_ds_nt;
19 
20 G = model_data.G;
21 
22 X = rand(size(G,1),nX);
23 Xnorm = sqrt(sum((G*X).*X,1));
24 X = X*sparse(1:nX,1:nX,Xnorm.^(-1));
25 %Xnorm = sqrt(sum((G*X).*X,1));
26 %disp('check norm 1!')
27 %keyboard;
28 
29 M = rand_uniform(nmu,model.mu_ranges);
30 T = (0:nt)/nt * model.T;
31 
32 % the following implementation with 2 loops is very bad matlab
33 % style. But I do not yet see, how that can be vectorized easily...
34 
35 for mui=1:nmu
36 
37  tic;
38  model = model.set_mu(model,M(:,mui));
39  model.decomp_mode = 0; % complete
40  model = model.set_time(model,0);
41  %model.t = 0;
42  A = model.A_function_ptr(model,model_data);
43  C = model.C_function_ptr(model,model_data);
44 
45  for ti = 0:nt
46 % disp(ti);
47  expAtX = expm(A*T(ti+1))*X ;
48  normAtX = sqrt(sum((G*expAtX).*expAtX,1));
49 
50  C1new = max(normAtX);
51  if (length(C1new)>1)
52  C1new = C1new(1);
53  end;
54 
55  if (C1new>C1)
56  C1 = C1new;
57  end;
58 
59  CX = C*X;
60  if (size(CX,1)>1)
61  normCX = sqrt(sum((G*CX).*CX,1));
62  else
63  normCX = sqrt(CX.*CX);
64  end;
65 
66  C2new = max(normCX);
67  if (length(C2new)>1)
68  C2new = C2new(1);
69  end;
70 
71  if (C2new>C2)
72  C2 = C2new;
73  end;
74 
75  % if model.debug
76  disp(['current C1: ',num2str(C1),' ',...
77  'current C2: ',num2str(C2)]);
78  % end;
79 
80  t = toc;
81  if (ti == 1) && (mui == 1)
82  disp(['Estimation of constants C1 and C2 will take ',...
83  num2str(t*(nmu*(nt+1)-2)),' seconds']);
84  end;
85  end;
86 
87 end;
88