4 %
function to compute and empirical continuousity constant of the Matrix
5 % L_I^-1 of a linear evolution scheme. Required
for the nomal L2-error
8 % computes the largest magnitude of ||L_I^-1||
for all \mu\in M_train and
9 % takes the maximum of those as empirical continuousity constant.
11 % Dominik Garmatter 11.03 2012
13 model_data = gen_model_data(model);
15 %
get the components of L_I
16 model.decomp_mode = 1;
17 [L_I_comp, ~, ~] = model.operators_ptr(model, model_data);
19 % formt he Training set Mtrain as a discretisation of the parameter space
20 par.numintervals = model.RB_numintervals-2;
21 par.range = model.mu_ranges;
23 Mtrain =
get(diskret_par_space,
'vertex')
';
25 spectral_build = zeros(size(Mtrain,2),1);
26 n = size(L_I_comp{1},1);
29 for i = 1:size(Mtrain,2)
31 % assemble L_I for the current mu
32 model = model.set_mu(model,Mtrain(:,i));
33 model.decomp_mode = 2;
34 [L_I_coeff, ~, ~] = model.operators_ptr(model, model_data);
35 L_I = lincomb_sequence(L_I_comp,L_I_coeff);
36 % compute the largest magnitude
37 spectral_build(i) = eigs(@(x)my_mult_for_L_I(x,L_I,model_data.W),n,1,'LM
');
38 try %first try to solve the EWP with default tolerance eps
39 spectral_build(i) = eigs(@(x)my_mult_for_L_I(x, L_I, model_data.W), n, model_data.W, 1,'LM
');
41 if (strcmp(err.identifier,'MATLAB:eigs:ARPACKroutineErrorMinus14
')) %if no eigenvalues to sufficient accuracy was found reduce the tolerance and try it again
45 disp(['I reduced the tolerance of an eigenvalueproblem to
' mat2str(opts.tol)]);
47 spectral_build(i) = eigs(@(x)my_mult_for_L_I(x, L_I, model_data.W), n, model_data.W, 1,'LM
',opts);
48 no_solution = 0; %end when there is no error
49 catch err2 %when it still fails reduce the tolerance and try again!
51 if (strcmp(err2.identifier,'MATLAB:eigs:ARPACKroutineErrorMinus14
'))
52 opts.tol = 100 * opts.tol;
54 if opts.tol > 1e-3 %if the tolerance is reduced until a certain value, give an error since the tolerance is too soft!
55 error(['I reduced the tolerance to
' mat2str(opts.tol) ' but I still could not find a solution. Reconsider your Problem
']);
59 else %if there is another error rethrow
64 model.L_I_inv_norm_bound = max(spectral_build);
67 %==========================================================================
70 function y = my_mult_for_L_I(x,L,K)
71 % AFUN for eigs to compute ||(L_I)^-1(\mu)||_2.
72 % Does the operationy = K^-1/2 * L^-1 * K * L^-1 * K^-1/2 * x.
A hierarchical cubegrid of arbitrary dimension.
function model = eop_C_L_I(model)
model = eop_C_L_I(model)