rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
estimate_lin_ds_bound_constants.m
1 function [C1,C2] = estimate_lin_ds_bound_constants(model)
2 %function [C1,C2] = estimate_lin_ds_bound_constants(model)
3 %
4 % function estimating the constant
5 % @f$ C_1 \geq ||\exp(A(\mu) t)||_G @f$ for all t and
6 % @f$ C_2 \geq ||C(\mu)||_G @f$ by some random sets of @f$\mu@f$, t and
7 % state vectors x.
8 % These quantities are required for a-posteriori error estimation
9 % of reduced model.
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.G_matrix_function_ptr(model);
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  model = model.set_mu(M(:,mui),model);
38  model.decomp_mode = 0; % complete
39  A = model.A_function_ptr(model);
40  C = model.C_function_ptr(model);
41 
42  for ti = 1:nt
43 
44  expAtX = expm(A*T(ti))*X ;
45  normAtX = sqrt(sum((G*expAtX).*expAtX,1));
46 
47  C1new = max(normAtX);
48  if (length(C1new)>1)
49  C1new = C1new(1);
50  end;
51 
52  if (C1new>C1)
53  C1 = C1new;
54  end;
55 
56  CX = C*X;
57  if (size(CX,1)>1)
58  normCX = sqrt(sum((G*CX).*CX,1));
59  else
60  normCX = sqrt(CX.*CX);
61  end;
62 
63  C2new = max(normCX);
64  if (length(C2new)>1)
65  C2new = C2new(1);
66  end;
67 
68  if (C2new>C2)
69  C2 = C2new;
70  end;
71 
72  end;
73 
74 end;