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
PolyKernel.m
Go to the documentation of this file.
1 namespace kernels{
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 kernels.BaseKernel {
28  public: /* ( setObservable ) */
29 
30  Degree = 2;
45  public: /* ( setObservable ) */
46 
47 
48  PolyKernel(deg) {
49  if nargin == 1
50  /* \todo validity checks */
51  this.Degree= deg;
52  end
53  this.IsScProd= true;
54  }
55 
56 
57  function copy = clone() {
58  copy = clone@kernels.BaseKernel(this, kernels.PolyKernel);
59  copy.Degree= this.Degree;
60  }
61 
62 
63  function c = getGlobalLipschitz() {
64  error(" Not implemented yet! ");
65  }
73  function Nabla = getNabla(colvec<double> x,matrix<double> y) {
74  Nabla = this.Degree*bsxfun(@times, y, x^t*y.^(this.Degree-1));
75  }
87  if ~isempty(this.fP)
88  x = x(this.fP,:);
89  end
90  if nargin == 2 || isempty(y)
91  y = x;
92  else
93  if ~isempty(this.fP)
94  y = y(this.fP,:);
95  end
96  end
97  K = (x^t*(this.fG*y)).^this.Degree;
98 /* sx = this.fG*x;
99  * n1sq = sum(x.*sx,1);
100  * n1 = size(x,2);
101  * if nargin == 2 || isempty(y)
102  * y = x;
103  * n2sq = n1sq;
104  * n2 = n1;
105  * else
106  * if ~isempty(this.fP)
107  * y = y(this.fP,:);
108  * end
109  * n2sq = sum(y.*(this.fG*y),1);
110  * n2 = size(y,2);
111  * end
112  * no = sqrt(repmat(n1sq',1,n2) .* repmat(n2sq,n1,1));
113  * a = (sx'*y);
114  * b = a ./ no;
115  * K = b.^this.Degree;
116  * %K = ((sx'*y) ./ no).^this.Degree; */
117  }
118 
119 
120  public: /* ( Static ) */ /* ( setObservable ) */
121 
122  static function res = test_PolyKernel(pm) {
123  if nargin < 1
124  pm = PlotManager(false,3,3);
125  pm.LeaveOpen= true;
126  end
127  c = 1;
128  x = (-1.2:.01:1.2)+c;
129 
130  k = kernels.PolyKernel;
131  kexp = kernels.KernelExpansion;
132  kexp.Kernel= k;
133  kexp.Centers.xi= c;
134  kexp.Ma= 1;
135  conf = [.1 .4 .8 1 2 3 4];
136  for n = 1:length(conf)
137  k.Degree= conf(n);
138  tag = sprintf(" poly_1d_deg%g ",k.Degree);
139  h = pm.nextPlot(tag,sprintf(" Polynomial kernel with deg=%g on 1D data ",k.Degree));
140  z = kexp.evaluate(x);
141  plot(h,x,[real(z); imag(z)]);
142  end
143  kexp.Centers.xi= [c; 1.6*c];
144  [X,Y] = meshgrid(x);
145  x2 = [X(:)" ; Y(:) "];
146  for n = 1:length(conf)
147  k.Degree= conf(n);
148  tag = sprintf(" poly_2d_deg%g ",k.Degree);
149  h = pm.nextPlot(tag,sprintf(" Polynomial kernel with deg=%g on 2D data ",k.Degree));
150  Z = real(reshape(kexp.evaluate(x2),length(x),[]));
151  surf(h,X,Y,Z," EdgeColor "," none ");
152  end
153  if nargin < 1
154  pm.done;
155  end
156  res = true;
157  }
158 
159 
160 
161 };
162 }
163 
164 
165 
Degree
The degree of the polynomial kernel.
Definition: PolyKernel.m:30
function c = getGlobalLipschitz()
Definition: PolyKernel.m:63
function Nabla = getNabla(colvec< double > x,matrix< double > y)
Partial derivatives of scalar product is simply the second argument vector.
Definition: PolyKernel.m:73
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Definition: PlotManager.m:17
function K = evaluate(colvec< double > x,matrix< double > y)
Definition: PolyKernel.m:86
static function res = test_PolyKernel(pm)
Definition: PolyKernel.m:122
#define X(i, j)
function copy = clone()
Definition: PolyKernel.m:57
logical IsScProd
Flag that determines if the current kernel bases on scalar product evaluations, i.e. are of the form for some scalar function .
Definition: BaseKernel.m:105
#define Y(i, j)
POLYKERNEL Basic polynomial kernel.
Definition: PolyKernel.m:18
Base class for all KerMor Kernels.
Definition: BaseKernel.m:18