2 %reduced_data = riccati_gen_reduced(model, detailed_data)
4 % Build the reduced data, i.e. all matrices and components that are
5 % required
for the calculation of the reduced solution and the residual
6 % norm in an online efficient manner.
8 % Andreas Schmidt, 2015
10 if ~isfield(detailed_data,
'RB_V');
13 V = detailed_data.RB_V;
15 % 1. Project all the matrices:
16 model_data = gen_model_data(model);
18 % For copying all the coefficient functions:
19 reduced_data = model_data;
22 reduced_data.VtV = V
'*V;
24 for k = 1:length(model_data.A_components)
25 Ak{k} = W'*model_data.A_components{k}*V;
27 reduced_data.A_components = Ak;
28 reduced_data.B_components = {};
29 for k = 1:length(model_data.B_components)
30 reduced_data.B_components{k} = W
'*model_data.B_components{k};
32 reduced_data.C_comp = {};
33 for k = 1:length(model_data.C_components)
34 reduced_data.C_components{k} = model_data.C_components{k}*V;
36 reduced_data.E_comp = {};
37 for k = 1:length(model_data.E_components)
38 reduced_data.E_components{k} = W'*model_data.E_components{k}*V;
40 reduced_data.x0_components = {};
41 for k = 1:length(model_data.x0_components)
42 reduced_data.x0_components{k} = W
'*model_data.x0_components{k};
45 % For the error estimator:
47 for i=1:length(model_data.B_components)
48 for j=1:length(model_data.B_components)
49 estim.M2{i,j} = (W'*model_data.B_components{i})*(model_data.B_components{j}
'*W);
53 for i=1:length(model_data.C_components)
54 for j=1:length(model_data.C_components)
55 for k=1:length(model_data.E_components)
56 for l=1:length(model_data.E_components)
57 estim.M4{i,j,k,l} = (W'*model_data.E_components{k}*model_data.C_components{i}
')*(model_data.C_components{j}*model_data.E_components{l}'*W);
65 for i = 1:length(model_data.A_components)
66 for j = 1:length(model_data.C_components)
67 for k = 1:length(model_data.C_components)
68 for l = 1:length(model_data.E_components)
69 estim.M1{i,j,k,l} = W
'*model_data.E_components{l}*model_data.C_components{j}'*model_data.C_components{k}*(model_data.A_components{i})
'*W;
73 for j = 1:length(model_data.E_components)
74 estim.M3{i,j} = W'*model_data.E_components{j}*(model_data.A_components{i})
'*W;
75 estim.M6{i,j} = estim.M3{i,j}';
77 for j = 1:length(model_data.A_components)
78 estim.M5{i,j} = W
'*model_data.A_components{i}*(model_data.A_components{j}')*W;
82 for i = 1:length(model_data.C_components)
83 for j = 1:length(model_data.C_components)
84 for k = 1:length(model_data.C_components)
85 for l = 1:length(model_data.C_components)
86 estim.M7{i,j,k,l} = trace(model_data.C_components{i}*model_data.C_components{j}
'*model_data.C_components{k}*model_data.C_components{l}');
91 for i = 1:length(model_data.E_components)
92 for j = 1:length(model_data.E_components)
93 estim.M8{i,j} = W
'*model_data.E_components{i}*(model_data.E_components{j}')*W;
98 % Finally the last components
for the error estimator:
99 estim.normE = normest(model_data.E_components{1});
102 % Prepare the value
for ||BB^T||
104 estim.normBBT_use2norm =
false;
105 if length(model_data.B_components) == 1
106 estim.normBBT = normest(model_data.B_components{1});
107 estim.normBBT_use2norm =
true;
109 for i = 1:length(model_data.B_components)
110 for j = 1:length(model_data.B_components)
111 for k = 1:length(model_data.B_components)
112 for l = 1:length(model_data.B_components)
113 estim.normBBT{i,j,k,l} = trace(model_data.B_components{k}
'*model_data.B_components{l});
121 if isfield(detailed_data,'gamma
')
122 estim.gamma = detailed_data.gamma;
124 if strcmp(estim.gamma.mode, 'kernel_interpolation
')
125 % Build the kernel weights
126 mus = estim.gamma.interpol_mus;
127 gammas = estim.gamma.interpol_gammas;
128 k = riccati_kernel_functions(model, estim.gamma.kernel);
129 % Calculate the alphas:
130 K = zeros(length(gammas));
131 for i = 1:length(gammas)
132 for j = 1:length(gammas)
133 K(i,j) = k(mus(i,:),mus(j,:));
137 estim.gamma.alpha = K\gammas;
138 elseif strcmp(estim.gamma.mode, 'exponential_bound
')
139 if length(model_data.E_components) > 1
140 error('Only one component in E is currently supported!
');
143 % NOTE: This is a workaround for a real strange and nasty "bug" in
144 % Matlabs svds function:
147 estim.normEInv = 1/svds(model_data.E_components{1},1,0);
149 if ~isempty(estim.normEInv)
156 reduced_data.estim = estim;
function reduced_data = riccati_gen_reduced_data(model, detailed_data)
reduced_data = riccati_gen_reduced(model, detailed_data)