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
AffLinCoreFun.m
Go to the documentation of this file.
1 namespace dscomponents{
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 dscomponents.ACoreFun,
20  public general.AffParamMatrix ,
50  public: /* ( setObservable ) */
51 
76  private: /* ( Transient ) */
77 
78  cachedA;
79 
80 
81  public: /* ( Transient ) */
82 
84  this = this@general.AffParamMatrix;
85  this = this@dscomponents.ACoreFun(sys);
86  this.CustomProjection= true;
87  this.TimeDependent= false;
88  this.cachedA= [];
89  }
97  function fx = evaluate(colvec<double> x,double t) {
98  if this.TimeDependent
99  fx = this.compose(t, this.mu)*x;
100  else
101  fx = this.cachedA*x;
102  end
103  }
115  function fx = evaluateMulti(colvec<double> x,double t,colvec<double> mu) {
116  if (~this.TimeDependent || numel(t) == 1) && size(mu,2) == 1
117  fx = this.compose(t, mu)*x;
118  else
119  /* Multi-Argument case */
120  fx = zeros(size(x));
121  for k = 1:size(x,2)
122  fx(:,k) = this.compose(t(k), mu(:,k))*x(:,k);
123  end
124  end
125  }
126 
127 
129  prepareSimulation@dscomponents.ACoreFun(this, mu);
130  this.cachedA= [];
131  if ~isempty(mu) && ~this.TimeDependent
132  this.cachedA= this.compose(0, mu);
133  end
134  }
135 
136 
137  function fx = evaluateCoreFun() {
138  error(" This method should never be called. ");
139  }
150  function J = getStateJacobian(unused1,double t) {
151  if this.TimeDependent
152  J = this.compose(t, this.mu);
153  else
154  J = this.cachedA;
155  end
156  }
169  function c = getGlobalLipschitz(double t,colvec<double> mu) {
170  error(" need to update. ");
171  a = this.AffParamMatrix;
172  c = 0;
173  for idx=1:length(this.Coefficients)
174  cfun = this.Coefficients[idx];
175  c = c + abs(cfun(t,mu)) * norm(a.Matrices(:,:,idx));
176  end
177  }
188  function proj = project(V,W) {
189  proj = this.clone;
190  proj = project@dscomponents.ACoreFun(this, V, W, proj);
191  proj = project@general.AffParamMatrix(this, V, W, proj);
192  proj.JSparsityPattern= [];
193  }
194 
195 
196  function addMatrix(string coeff_fcn,matrix<double> mat) {
197 
198  /* Update the xDim as first matrix is added */
199  if isempty(this.xDim)
200  this.xDim= size(mat,2);
201  end
202  if isempty(this.fDim)
203  this.fDim= size(mat,1);
204  end
205 
206  addMatrix@general.AffParamMatrix(this, coeff_fcn, mat);
207 
208  /* Compute sparsity pattern */
209  if issparse(mat)
210  if ~isempty(this.JSparsityPattern)
211  this.JSparsityPattern= mat ~= 0 | this.JSparsityPattern;
212  else
213  this.JSparsityPattern= mat ~= 0;
214  end
215  else
216  this.JSparsityPattern= [];
217  end
218 
219  mu = ones(1,100);
220  if ~this.TimeDependent
221  this.TimeDependent= ~all(this.cfun(0,mu) == this.cfun(Inf,mu));
222  if KerMor.App.Verbose > 1
223  fprintf(" AffLinCoreFun: Guessed time-dependency to %d.\n ",this.TimeDependent);
224  end
225  end
226  }
240  function prod = mtimes(other) {
241  prod = mtimes@general.AffParamMatrix(this, other);
242  prod.postprocess;
243  }
252  function diff = minus(other) {
253  diff = minus@general.AffParamMatrix(this, other);
254  diff.postprocess;
255  }
264  function sum = plus(other) {
265  sum = plus@general.AffParamMatrix(this, other);
266  sum.postprocess;
267  }
276  function transp = ctranspose() {
277  transp = ctranspose@general.AffParamMatrix(this);
278  transp.postprocess;
279  }
287  private: /* ( Transient ) */
288 
289  function postprocess() {
290  if this.N > 0
291  this.xDim= this.dims(2);
292  this.JSparsityPattern= [];
293  end
294  }
303  public: /* ( Sealed ) */ /* ( Transient ) */
304 
305  function copy = clone() {
306  copy = dscomponents.AffLinCoreFun(this.System);
307  copy = clone@general.AffParamMatrix(this, copy);
308  copy = clone@dscomponents.ACoreFun(this, copy);
309  copy.CoeffClass= this.CoeffClass;
310  }
311 
312 
313 };
314 }
315 
316 
317 
function transp = ctranspose()
Implements the default transposition method.
function fx = evaluateCoreFun()
This method will never be called as evaluate is overridden directly for performance. this is possible as AffLinCoreFuns have both CustomProjection and MultiArgumentEvaluations.
integer fDim
The current output dimension of the function.
Definition: ACoreFun.m:171
CustomProjection
Set this property if the projection process is customized by overriding the default project method...
Definition: ACoreFun.m:108
logical TimeDependent
Flag that indicates if the ACoreFun is (truly) time-dependent.
Definition: ACoreFun.m:84
function addMatrix(string coeff_fcn,matrix< double > mat)
Adds a new matrix to the affine-linear core function.
function c = getGlobalLipschitz(double t,colvec< double > mu)
Implementation of the interface method from IGlobalLipschitz.
function diff = minus(other)
Implements the default subtraction method.
function proj = project(V, W)
handle cfun
coefficient function handle as specified by funStr
function prepareSimulation(colvec< double > mu)
Basic interface for all dynamical system's core functions Inherits the AProjectable interface...
Definition: ACoreFun.m:18
integer xDim
The current state space dimension of the function's argument .
Definition: ACoreFun.m:151
function prod = mtimes(other)
Implements the default multiplication method.
models.BaseFirstOrderSystem System
The system associated with the current ACoreFun.
Definition: ACoreFun.m:193
V
The matrix of the biorthogonal pair .
Definition: AProjectable.m:61
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
Definition: ACoreFun.m:208
function M = compose(t, mu)
Composes the affine-linear combination of matrices for given time and parameter .
function fx = evaluate(colvec< double > x,double t)
Evaluates affine-linear core function by matrix-vector multiplication.
Definition: AffLinCoreFun.m:97
Speed test * all(1:3)
function copy = clone()
rowvec< integer > dims
dimension of the matrices
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
Definition: ACoreFun.m:127
char CoeffClass
Export setting. Java class name for JKerMor model export.
Definition: AffLinCoreFun.m:52
function J = getStateJacobian(unused1,double t)
Overrides the default jacobian finite difference implementation. Jacobian of linear operator is the o...
function [ n , m ] = size(dim)
Implementation of ABlockedData.size.
function sum = plus(other)
Implements the default addition method.
IGLOBALLIPSCHITZ Interface for all functions that have a global lipschitz constant for the state/spat...
function fx = evaluateMulti(colvec< double > x,double t,colvec< double > mu)
Global configuration class for all KerMor run-time settings.
Definition: KerMor.m:17
General time/parameter-affine matrix.
static function KerMor theinstance = App()
The singleton KerMor instance.
Definition: KerMor.m:910
W
The matrix of the biorthogonal pair .
Definition: AProjectable.m:72
A MatLab character array.
integer N
The number of affine matrices / size of the linear combination.
AffLinCoreFun(sys)
Creates a new instance of the AffLinCoreFun.
Definition: AffLinCoreFun.m:83
Simple affine-linear core function "f" for a dynamical system.
Definition: AffLinCoreFun.m:18