KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseSpaceReducer.m
Go to the documentation of this file.
1 namespace spacereduction{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public KerMorObject,
30  public: /* ( setObservable ) */
31 
49 
50 
51  IncludeBSpan = false;
52 
53 
54  IncludeAxData = false;
55 
56 
82  public:
83 
85 
86 
87  public:
88 
89 
90  function [V , W ] = generateReducedSpace(models.BaseFullModel model) {
91  [V, W] = this.generateReducedSpaceImpl(model, this.TargetDimensions);
92  }
108  function plotSummary(pm,context) {
109  if ~isempty(this.ProjectionError)
110  str = sprintf(" %s/%s: Projection error over training data ",...
111  context,class(this));
112  h = pm.nextPlot(sprintf(" spacereduction_projerr_%s ",this.ID),...
113  str," subspace size "," error ");
114  semilogy(h,this.ProjectionError," LineWidth ",2);
115  end
116  }
117 
118 
119  protected:
120 
121 
122  function V = getInitialSpace(blockdata,pod,subset) {
123 
124  n = blockdata.getNumBlocks;
125  x = blockdata.getBlock(1);
126  x0 = x(subset,1);
127 /* if this.ComputeParallel
128  * parfor idx=2:n
129  * x = blockdata.getBlock(idx);%#ok
130  * x0 = [x0, x(subset,1)];
131  * end
132  * x0 = unique(x0','rows')';
133  * else */
134  for idx=2:n
135  x = blockdata.getBlock(idx);
136  x = x(subset,1);
137  /* Only add nonexisting vectors */
138  if isempty(Utils.findVecInMatrix(x0,x))
139  x0 = [x0 x];/* #ok */
140 
141  end
142  end
143 /* end */
144  if all(x0 == 0)
145  if KerMor.App.Verbose > 1
146  fprintf(" Initial values are all zero vectors. Using main POD mode of first block data as initial space.\n ");
147  end
148  xb1 = blockdata.getBlock(1);
149  V = pod.computePOD(xb1(subset,:));
150  elseif size(x0,2) > 1
151  V = pod.computePOD(x0);
152  else
153  V = x0;
154  end
155  V = V / norm(V);
156  }
170  protected: /* ( Abstract ) */
171 
172  virtual function [V , W ] = generateReducedSpaceImpl(models.BaseFullModel model,subset) = 0;
173 
174 
175  /* % Getter & setter */
176  public:
177 
178 
179 #if 0 //mtoc++: 'set.IncludeTrajectoryFxiData'
180 function IncludeTrajectoryFxiData(value) {
181  if isempty(value) || ~islogical(value) || ~isscalar(value)
182  error(" Value needs to be a logical scalar. ");
183  end
184  this.IncludeTrajectoryFxiData= value;
185  }
186 
187 #endif
188 
189 
190 
191 #if 0 //mtoc++: 'set.IncludeFiniteDifferences'
192 function IncludeFiniteDifferences(value) {
193  if isempty(value) || ~islogical(value) || ~isscalar(value)
194  error(" Value needs to be a logical scalar. ");
195  end
196  this.IncludeFiniteDifferences= value;
197  }
198 
199 #endif
200 
201 
202 
203 #if 0 //mtoc++: 'set.IncludeBSpan'
204 function IncludeBSpan(value) {
205  if isempty(value) || ~islogical(value) || ~isscalar(value)
206  error(" Value needs to be a logical scalar. ");
207  end
208  this.IncludeBSpan= value;
209  }
210 
211 #endif
212 
213 
214 
215 #if 0 //mtoc++: 'set.IncludeAxData'
216 function IncludeAxData(value) {
217  if isempty(value) || ~islogical(value) || ~isscalar(value)
218  error(" Value needs to be a logical scalar. ");
219  end
220  this.IncludeAxData= value;
221  }
222 
223 #endif
224 
225 
226 
227 #if 0 //mtoc++: 'set.TargetDimensions'
228 function TargetDimensions(value) {
229  err = false;
230  if ~strcmp(value ," : ")
231  if iscell(value)
232  for k=1:length(value)
233  if ~isvector(value[k])
234  err = true;
235  break;
236  end
237  end
238  elseif ~isvector(value)
239  err = true;
240  end
241  end
242  if err
243  error(" TargetDimensions must either be ':', a column vector or a cell of column vectors. ");
244  end
245  this.TargetDimensions= value;
246  }
247 
248 #endif
249 
250 
272 };
273 }
274 
275 
276 
Collection of generally useful functions.
Definition: Utils.m:17
function plotSummary(pm, context)
varargin TargetDimensions
This property determines which dimensions are to be reduced. It is possible to reduce the entire numb...
static function idx = findVecInMatrix(A, b)
Finds column vectors inside a matrix.
Definition: Utils.m:259
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
A MatLab cell array or matrix.
Base class for any KerMor class.
Definition: KerMorObject.m:17
function [ V , W ] = generateReducedSpace(models.BaseFullModel model)
Generates the reduced linear subspace for the given model.
A boolean value.
virtual function [ V , W ] = generateReducedSpaceImpl(models.BaseFullModel model, subset)
A variable number of input arguments.
IReductionSummaryPlotProvider:
ID
An ID that allows to uniquely identify this DPCMObject (at least within the current MatLab session/co...
Definition: DPCMObject.m:70
Speed test * all(1:3)
logical IncludeTrajectoryFxiData
Flag if to include values for each value, too.
Global configuration class for all KerMor run-time settings.
Definition: KerMor.m:17
static function KerMor theinstance = App()
The singleton KerMor instance.
Definition: KerMor.m:910
Base class for all space reduction algorithms.
function V = getInitialSpace(blockdata, pod, subset)
Computes the initial space, which is the first POD mode of the initial values!