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
PointerCoreFun.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 {
36  private:
37 
38  target;
39 
40 
41  public:
42 
43  PointerCoreFun(function_handle funPtr,xdim,logical timedep) {
44 
45  /* Create ACoreFun without associated system (cannot be used
46  * here) */
47  this = this@dscomponents.ACoreFun([]);
48  if nargin < 3
49  /* Assume worst case: set time dependency to true! */
50  timedep = true;
51  end
52 
53  /* Creates a new wrapper for a core function handle. */
54  if ~isa(funPtr," function_handle ")
55  error(" Argument funPtr must be a function handle. ");
56  elseif nargin(funPtr) ~= 3
57  error(" funPtr nargin must equal three (= x,t,mu). ");
58  end
59  this.CustomProjection= false;
60  this.TimeDependent= timedep;
61  this.target= funPtr;
62  this.xDim= xdim;
63  this.fDim= size(funPtr(rand(xdim,1),0,rand(100,1)),1);
64  }
82  function fx = evaluateCoreFun(colvec<double> x,double t) {
83  fx = this.target(x, t, this.mu);
84  }
95  function proj = project(V,W) {
96 
97  /* no need to call clone here as the only property gets changed
98  * anyways. */
99  newfun = @(z,t,mu)W^t * this.target(V*z,t,mu);
100  proj = dscomponents.PointerCoreFun(newfun, size(V,2));
101  }
112  public: /* ( Sealed ) */
113 
114  function copy = clone() {
115  copy = dscomponents.PointerCoreFun(this.target);
116  }
117 
118 
119  public: /* ( Static ) */
120 
121  static function test_PointerCoreFun() {
122  m = models.BaseFullModel;
123  fun = @(x,t,mu)x*3.*t;
124  m.System.x0= dscomponents.ConstInitialValue(1);
125  m.System.f= dscomponents.PointerCoreFun(fun,1);
126  m.simulate;
127  clear m;
128  }
129 
130 
131 
132 };
133 }
134 
135 
136 
static function test_PointerCoreFun()
integer fDim
The current output dimension of the function.
Definition: ACoreFun.m:171
PointerCoreFun(function_handle funPtr, xdim,logical timedep)
Creates a new core function using the function pointer as inner function.
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
A MatLab function handle.
A boolean value.
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
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 proj = project(V, W)
Projects the core function into the reduced space. Creates a new PointerCoreFun and computes ...
Allows for core functions provided by function handles.
W
The matrix of the biorthogonal pair .
Definition: AProjectable.m:72
function fx = evaluateCoreFun(colvec< double > x,double t)
Evaluates the core function at x,t,mu.