255 this.
fSK= kernels.GaussKernel;
272 fx = this.
Ma * (this.Base \ this.getKernelVector(x)^
t);
322 J = this.
Ma * (this.Base \ this.fSK.getNabla(x, this.
Centers.xi)^
t);
368 if ~isa(f,
" kernels.KernelExpansion ")
369 error(
" f argument must be another KernelExpansion ");
371 if size(this.
Centers.xi,1) ~= size(f.Centers.xi,1)
372 error(
" Function input dimension mismatch ");
374 if size(this.
Ma,1) ~= size(f.Ma,1)
375 error(
" Function output dimension mismatch ");
377 v = sum(sum(this.
Ma .* f.evaluate(
this.Centers.xi),2));
404 if kexp.HasCustomBase
405 kexp.Ma= kexp.Ma/kexp.Base;
436 subexp.Ma= subexp.Ma(:,sel);
437 subexp.Centers.xi= subexp.Centers.xi(:,sel);
439 subexp.Centers.ti= this.
Centers.ti(sel);
442 subexp.Centers.mui= this.
Centers.mui(:,sel);
444 if subexp.HasCustomBase
445 subexp.Base= subexp.Base(sel,sel);
461 target.Centers.xi= W^
t * this.
Centers.xi;
463 if all(
all(abs(PG - eye(size(PG,1))) < 100*eps))
468 target.Centers.xi= V^
t * (
k.G * this.
Centers.xi);
471 target.Ma= W^
t*this.
Ma;
477 copy = kernels.KernelExpansion;
482 copy.Base= this.
Base;
499 sum = compose(A, B, 1);
511 diff = compose(A, B, -1);
534 if isa(
k,
" kernels.GaussKernel ")
536 elseif isa(
k,
" kernels.Wendland ")
537 kdata = [2
k.Gamma
k.d
k.k];
539 error(
" Cannot export a kernel of type %s yet. ",
class(this.
Kernel));
557 fh = fopen(filename,
" w+ ");
558 fprintf(fh,
" %s ",json);
566 xdim = size(this.
Centers.xi,1);
567 meanx = mean(this.
Centers.xi,2);
568 rs = RandStream(
" mt19937ar ",
" Seed ",round(rand*1000));
569 allX = bsxfun(@
plus,meanx,rs.rand(xdim,n));
570 allX = [this.
Centers.xi(:,1) allX];
574 dx = ones(xdim,1)*sqrt(eps(
class(x))).*max(abs(x),1);
575 X = repmat(x,1,xdim);
578 maxrel = max(max(abs((J-Jc)./Jc)));
580 fprintf(
" %s: Max relative error: %g\n ",
class(this.
Kernel),maxrel);
591 #if 0 //mtoc++: 'set.Centers'
593 C = [
" xi ",
" ti ",
" mui "];
594 if isempty(value) || any(isfield(value, C))
600 error(" Value passed is not a valid
struct. Only the field names xi, ti, mui are allowed ");
608 #if 0 //mtoc++: 'get.Kernel'
617 #if 0 //mtoc++: 'get.Size'
618 function value =
Size() {
621 value = size(this.
Centers.xi,2);
629 #if 0 //mtoc++: 'set.Kernel'
631 if isa(value,
" kernels.BaseKernel ")
635 error("
Kernel must be a subclass of kernels.BaseKernel. ");
643 #if 0 //mtoc++: 'get.Ma_norms'
645 m = sqrt(sum(this.
Ma.^2,1));
652 #if 0 //mtoc++: 'get.ComponentNorms'
659 n = sqrt(sum(c
" .* (this.getKernelMatrix * c "),1))^
t;
666 #if 0 //mtoc++: 'get.NativeNorm'
675 n = sqrt(sum(sum(c
" .* (this.getKernelMatrix * c "))));
686 #if 0 //mtoc++: 'get.MBnd'
687 function M =
MBnd() {
693 M = max(sum(abs(c),2));
700 #if 0 //mtoc++: 'get.HasCustomBase'
702 v = ~isempty(this.
Base) && (numel(this.
Base) > 1 || this.
Base ~= 1);
710 function c = compose(B,sgn) {
711 if ~isa(A,
" kernels.KernelExpansion ") || ~isa(B,
" kernels.KernelExpansion ")
712 error(" Both arguments must be at least kernels.
KernelExpansion subclasses ");
715 error(" Cannot add kernel expansions: different state space kernels ");
716 elseif ~isempty(A.
Ma) && ~isempty(B.
Ma) && size(A.
Ma,1) ~= size(B.Ma,1)
717 error(" Cannot add kernel expansions: different output dimensions ");
719 error(" Cannot add kernel expansions: different statespace center dimensions ");
723 c.Ma= [A.Ma sgn*B.Ma];
730 rs = RandStream(
" mt19937ar ",
" Seed ",0);
731 ke = kernels.KernelExpansion;
732 k1 = kernels.GaussKernel(1);
733 k2 = kernels.Wendland;
736 d = [1 20 1 20 1 20];
739 nc = round(rs.rand(1,6)*100);
743 ke.Centers.xi= rs.rand(d(
k),nc(
k));
744 ke.Ma= rs.rand(d(
k)+1,nc(
k));
748 res = res & ke.test_getStateJacobianInstance;
754 res = res & ke.test_getStateJacobianInstance;
766 if isfield(from,
" Base ")
767 this.
Base= from.Base;
770 elseif ~isa(
this,
" kernels.KernelExpansion ")
771 newinst = kernels.KernelExpansion;
772 newinst.Kernel= this.
fSK;
775 if isfield(
this,
" Base ")
776 newinst.Base= this.
Base;
Collection of generally useful functions.
matrix< double > Ma
The coefficient data for each dimension.
data.FileMatrix xi
The state space samples , stored row-wise in a data.FileMatrix instance.
function kernels.KernelExpansion kexp = toTranslateBase()
Returns the same kernel expansion with the canonical translate base used.
function phi = getKernelVector(matrix x, varargin)
Evaluates the kernel expansion.
function c = getGlobalLipschitz(double t,colvec< double > mu)
For some error estimators, a global Lipschitz constant estimation is performed. This function has to ...
static function this = loadobj(this, from)
As the constant properties are transient, they have to be re-computed upon loading.
logical HasCustomBase
Flag that indicates if a base other than the direct translate base is used for this kernel expansion...
function subexp = getSubExpansion(arg)
Interface for all components that can be projected.
function v = scalarProductWith(f)
Base class for any KerMor class.
colvec< double > ComponentNorms
Returns the native space norms for each component function size(Ma,1)
function registerProps(varargin)
Call this method at any class that defines DPCM observed properties.
virtual function c = getGlobalLipschitz()
Returns the global lipschitz constant of this kernel.
function target = project(V, W)
function fx = evaluate(matrix x, varargin)
Evaluates the kernel expansion.
kernels.BaseKernel fSK
The inner (state) kernel object.
KerMorObject()
Constructs a new KerMor object.
A variable number of input arguments.
function sum = plus(B)
Adds two kernel expansions and will clone the frist argument's class as result type.
rowvec Ma_norms
The norms of the coefficient matrix of the kernel expansion.
KernelExpansion()
Default constructor.
static function saveRealVector(vec, file, folder)
Stores a real double vector in little endian format.
function res = test_getStateJacobianInstance()
kernels.BaseKernel Kernel
The Kernel to use for system variables.
function J = getStateJacobian(x, varargin)
Evaluates the jacobian matrix of this function at the given point.
function K = getKernelMatrix()
Computes the kernel matrix for the currently set center data.
V
The matrix of the biorthogonal pair .
function setCentersFromATD(data.ApproxTrainData atd,rowvec< integer > idx)
Sets the centers according to the indices idx of the data.ApproxTrainData.
Size
The size of the kernel expansion.
MBnd
Returns the M upper bound for this KernelExpansion, which is .
function copy = clone(copy)
The interface method with returns a copy of the current class instance.
function clear()
Removes all centers and coefficients from the expansion and leaves the associated kernels untouched...
static function logical success = ensureDir(char dir)
Ensures that a directory exists.
static function char jsonobj = matrixToJSON(double value)
Takes a matrix and returns a JSON representation as JSONObject with the fields "dim" and "values"...
function json = toJSON(filename)
IGLOBALLIPSCHITZ Interface for all functions that have a global lipschitz constant for the state/spat...
function exportToDirectory(dir)
function diff = minus(B)
Adds two kernel expansions and will clone the frist argument's class as result type.
static function res = test_getStateJacobian()
function copy = clone(copy)
The interface method with returns a copy of the current class instance.
double NativeNorm
Returns the norm of in the RKHS .
ApproxTrainData: Data class for approximation training data, containing several useful bounding box p...
struct Centers
The kernel centers used in the approximation.
Util: Utility functions for export of matrices and vectors to files.
W
The matrix of the biorthogonal pair .
matrix< double > Base
This property lets the user store a custom base, for which the coefficients are set. The custom base tells which linear combinations of center elements belong to which base.
virtual function K = evaluate(matrix< double > x,matrix< double > y)
Evaluation method for the current kernel.
Base class for all KerMor Kernels.
KernelExpansion: Base class for state-space kernel expansions.
static function saveRealMatrix(mat, file, folder)
Stores a real double matrix in little endian format.
function row = getKernelMatrixColumn(integer idx,matrix x, varargin)
Evaluates the kernel expansion.