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
KernelLS.m
Go to the documentation of this file.
1 namespace general{
2 namespace regression{
3 
4 
5 /* (Autoinserted by mtoc++)
6  * This source code has been filtered by the mtoc++ executable,
7  * which generates code that can be processed by the doxygen documentation tool.
8  *
9  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
10  * Except for the comments, the function bodies of your M-file functions are untouched.
11  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
12  * attached source files that are highly readable by humans.
13  *
14  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
15  * the correct locations in the source code browser.
16  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
17  */
18 
19 class KernelLS
20  :public KerMorObject,
21  public IKernelCoeffComp {
36  /* @change{0,4,sa,2011-05-07} Implemented Setter for the properties G and Epsilon */
37 
38  public: /* ( setObservable ) */
39 
40  K;
68  CGMaxIt = "[]";
84  CGTol = 1e-6;
116  public: /* ( setObservable ) */
117 
118 
120  this = this@KerMorObject;
121  this.registerProps(" K "," lambda "," CGMaxIt "," CGTol "," MaxStraightInvDim ");
122  }
123 
124 
125  function copy = clone() {
126  copy = general.regression.KernelLS;
127  copy = clone@IKernelCoeffComp(this, copy);
128  copy.MaxStraightInvDim= this.MaxStraightInvDim;
129  copy.CGTol= this.CGTol;
130  copy.CGMaxIt= this.CGMaxIt;
131  copy.lambda= this.lambda;
132  copy.K= this.K;
133  }
134 
135 
136  function [a , sf ] = regress(fx,ainit) {
137  n = size(this.K,1);
138 
139  y = (fx*this.K)^t;
140  M = this.K^t*this.K + this.lambda*speye(n, n);
141 
142  if length(y) <= this.MaxStraightInvDim
143  a = M\y;
144  sf = StopFlag.SUCCESS;
145  else
147  [a, flag] = bicg(M,y,this.CGTol, this.CGMaxIt);/* #ok
148  *| @todo return correct stop flag */
149 
150  sf = StopFlag.SUCCESS;
151  end
152  }
153 
154 
155  function init(kernels.KernelExpansion kexp) {
156  this.K= kexp.getKernelMatrix;
157  }
169  function [ai , svidx , sf ] = computeKernelCoefficients(yi,initialai) {
170  [ai, sf] = this.regress(yi);
171  svidx = 1:size(yi,2);
172  }
173 
174 
175 
176 #if 0 //mtoc++: 'set.K'
177 function K(value) {
178  if (isa(value," handle ") && ~isa(value, " data.FileMatrix ")) || (~ismatrix(value) || ~isa(value," double "))
179  error(" Value must be a data.FileMatrix or a double matrix. ");
180  end
181  this.K= value;
182  }
183 
184 #endif
185 
192 #if 0 //mtoc++: 'set.lambda'
193 function lambda(value) {
194  if ~isposrealscalar(value)
195  error(" value must be a positive scalar ");
196  end
197  this.lambda= value;
198  }
199 
200 #endif
201 
202 
203 
204 #if 0 //mtoc++: 'set.CGMaxIt'
205 function CGMaxIt(value) {
206  if ~isempty(value) && ~isposintscalar(value)
207  error(" value must be a positive integer scalar ");
208  end
209  this.CGMaxIt= value;
210  }
211 
212 #endif
213 
214 
215 
216 #if 0 //mtoc++: 'set.CGTol'
217 function CGTol(value) {
218  if ~isposrealscalar(value)
219  error(" value must be a positive real scalar. ");
220  end
221  this.CGTol= value;
222  }
223 
224 #endif
225 
226 
227 
228 #if 0 //mtoc++: 'set.MaxStraightInvDim'
229 function MaxStraightInvDim(value) {
230  if ~isposintscalar(value)
231  error(" value must be a positive integer scalar ");
232  end
233  this.MaxStraightInvDim= value;
234  }
235 
236 #endif
237 
259 };
260 }
261 }
262 
263 
K
The kernel matrix to use for LS regression.
Definition: KernelLS.m:40
A double value.
Base class for any KerMor class.
Definition: KerMorObject.m:17
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
Definition: DPCMObject.m:125
An integer value.
KERNELLS Least-Squares kernel regression ("Rigde Regression") Since the systems can be considerably l...
Definition: KernelLS.m:19
CGTol
Tolerance for cg method.
Definition: KernelLS.m:84
MaxStraightInvDim
Maximum dimension of function for which direct inversion is performed instead of pcg.
Definition: KernelLS.m:100
static const SUCCESS
Algorithm terminated otherwisely successful.
Definition: StopFlag.m:83
KerMorObject()
Constructs a new KerMor object.
Definition: KerMorObject.m:55
function ismat = ismatrix(value)
ismatrix: Compatibility function for matlab versions smaller than 2011b
Definition: ismatrix.m:17
function K = getKernelMatrix()
Computes the kernel matrix for the currently set center data.
function [ a , sf ] = regress(fx, ainit)
Definition: KernelLS.m:136
Interface for kernel expansion coefficient computation.
double lambda
The regularization term weight.
Definition: KernelLS.m:53
function [ ai , svidx , sf ] = computeKernelCoefficients(yi, initialai)
Kernel coefficient computation.
Definition: KernelLS.m:169
function init(kernels.KernelExpansion kexp)
% IKernelCoeffComp interface members Sets the kernel matrix.
Definition: KernelLS.m:155
function res = isposintscalar(value)
isposintscalar: Backwards-compatibility function for matlab versions greater than 2012a ...
function copy = clone()
Definition: KernelLS.m:125
CGMaxIt
Maximum iteration count for the conjugate gradient method.
Definition: KernelLS.m:68
function res = isposrealscalar(value)
isposintscalar: Backwards-compatibility function for matlab versions greater than 2012a ...
KernelExpansion: Base class for state-space kernel expansions.
StopFlag: Flags that algorithms can use to specify the reason for their termination.
Definition: StopFlag.m:17