rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ISeparableFunction.m
1 classdef ISeparableFunction < handle
2 
3  properties (Constant, Abstract)
4  id;
5  end
6 
7  methods (Abstract)
8 
9  res = evaluate(this, descr, model_data);
10 
11  comps = components(this, descr, model_data);
12 
13  coeffs = coefficients(this, descr);
14 
15  A = inner_product_matrix(this, descr, model_data);
16  end
17 
18  methods
19  function fa = projection(this, model, detailed_data)
20  model_data = detailed_data.model_data;
21  A = inner_product_matrix(this, model, model_data);
22  f = evaluate(this, model, model_data);
23 
24  fa = f' * A * detailed_data.RB;
25  end
26 
27  function acomp = project_components(this, rmodel, detailed_data)
28  model_data = detailed_data.model_data;
29  A = inner_product_matrix(this, rmodel, model_data);
30 
31  Nmax = get_N(rmodel, this.id);
32 
33  comps = components(this, rmodel.descr, model_data);
34 
35  acomp = cellfun(@(X) X' * A * detailed_data.RB(:,1:Nmax), ...
36  comps, 'UniformOutput', false);
37  acomp = cat(1, acomp{:});
38 
39  if rmodel.debug && length(acomp) > 1
40  if max(abs(detailed_data.RB(:,Nmax) * acomp{1}'-acomp{1}))>0.001
41  U0 = [acomp{1},acomp{2}];
42  U0_RB = [detailed_data.RB(:,Nmax)*acomp{1}',detailed_data.RB*a0{2}'];
43  plot_params = [];
44  plot_params.plot = model.plot;
45  plot_params.title = [this.id, 'Components'];
46  plot_sequence(U0,model_data.grid,plot_params);
47  plot_params.title = [this.id, 'RB'];
48  plot_sequence(U0_RB,model_data.grid,plot_params);
49  error('rb projection badly approximating separable function !!!');
50  end
51  end
52  end
53  end
54 end