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
Basics5_KernelsAndApprox.m
Go to the documentation of this file.
1 namespace demos{
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 
20 
21 /* % Create a basic kernel expansion manually */
22 lw = 2;
23 /* Centers */
24 c = [-1 .5 1.2];
25 /* Coefficients */
26 a = [.5 -.2 .8];
27 /* Get a Gaussian kernel with gamma=1 */
28 k = kernels.GaussKernel(1);
29 /* Get the overall linear combination class and set properties */
30 f = kernels.KernelExpansion;
31 f.Kernel= k;
32 f.Centers.xi= c;
33 f.Ma= a;
34 
35 /* % Plot the expansion and its centers/single elements
36  * More plot functions illustrating kernels can be found at
37  * kernels.Wendland.test_WendlandKernel and
38  * kernels.GaussKernel.test_GaussKernel */
39 pm = PlotManager;
40 h = pm.nextPlot(" rkhs_demo "," Example kernel expansion "," x "," f(x) ");
41 x = -3:.01:3;
42 plot(h,x,f.evaluate(x)," r "," LineWidth ",lw);
43 hold(h," on ");
44 plot(h,x,0," k "," LineWidth ",lw);
45 for i = 1:length(c)
46  f.Centers.xi= c(i);
47  f.Ma= a(i);
48  plot(h,x,f.evaluate(x)," r-- ");
49  plot(h,c(i),0," b. "," MarkerSize ",20);
50  plot(h,[c(i) c(i)+eps],[0 a(i)]," k-- ");
51 end
52 pm.done;
53 
54 /* % Run a VKOGA algorithm */
55 fprintf(" Just ignore the following two warnings about file locations!\n ");
56 load(fullfile(" +demos "," spine_training_data_set.mat "));
57 
58 /* Get VKOGA instance */
59 alg = approx.algorithms.VKOGA;
60 /* Set maximal size */
61 alg.MaxExpansionSize= 600;
62 /* Choose variant */
63 alg.UsefPGreedy= false;
64 
65 nG = 10;
66 k = [1 3];
67 
68 /* Create configuration for VKOGA */
69 gammas = linspace(15,70,nG);
70 comb = Utils.createCombinations(gammas,k);
71 wc = kernels.config.WendlandConfig(" G ",comb(1,:)," S ",comb(2,:));
72 wc.Dimension= 3;
73 ec = kernels.config.ExpansionConfig;
74 ec.StateConfig= wc;
75 alg.ExpConfig= ec;
76 
77 /* % Execute computations */
78 kexp = alg.computeApproximation(atd);
79 kexp_dbase = kexp.toTranslateBase;
80 save basics5_kernelsandapprox;
81 
82 /* % Plot the results */
83 FunVis2D(kexp, atd, [], [], lbl);
84 
85 }
109 };
Collection of generally useful functions.
Definition: Utils.m:17
static function comb = createCombinations(ranges, varargin)
Creates the cartesian product of the vectors passed as a matrix containing elements of each vector pe...
Definition: Utils.m:114
function varargout = FunVis2D(varargin)
User interface to visualize highdimensional functions using two input dimensions and one output dimen...
Definition: FunVis2D.m:17
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Definition: PlotManager.m:17
function axes ax_handle = nextPlot(char tag,char caption,char xlab,char ylab,cell< char > leg_str,integer numsubplots)
Creates a new axis to plot in. Depending on the property tools.PlotMananger.Single this will either a...
Definition: PlotManager.m:365
function Basics5_KernelsAndApprox()
Basics5_KernelsAndApprox: