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
RBFKernel.cpp
Go to the documentation of this file.
1 /*
2  * RBFKernel.cpp
3  *
4  * Created on: 22.07.2013
5  * Author: CreaByte
6  */
7 
8 #include "kermorpp.h"
9 #include <iostream>
10 
11 namespace kermorpp {
12 
13 ostream & operator<<(ostream & os, const RBFKernel & k) {
14  os << "Gamma:" << k._gamma;
15  return os;
16 }
17 
18 RBFKernel.RBFKernel(double gamma) :
19  _gamma(gamma) {
20 }
21 
23 }
24 
36 MatrixXd RBFKernel.evaluate(MatrixXd x, MatrixXd y) {
37 
38  MatrixXd xsq = MatrixXd.Ones(y.cols(), 1)
39  * x.cwiseProduct(x).colwise().sum();
40  MatrixXd ysq = MatrixXd.Ones(x.cols(), 1)
41  * y.cwiseProduct(y).colwise().sum();
42 
43  MatrixXd tmp = (xsq.transpose() + ysq - 2 * x.transpose() * y)
44  / (_gamma * _gamma);
45 
46 #if DEBUG
47  cout << "x: " << x << ", y:" << y << ", xsq: " << xsq << ", ysq: " << ysq
48  << ", tmp: " << tmp << endl;
49 #endif
50 
51  return rbf_eval_rsq(tmp);
52 }
53 
54 }
55 
MatrixXd evaluate(MatrixXd x, MatrixXd y)
Definition: RBFKernel.cpp:36
RBFKernel(double gamma)
Definition: RBFKernel.cpp:18
virtual ~RBFKernel()
Definition: RBFKernel.cpp:22
virtual MatrixXd rbf_eval_rsq(MatrixXd rsq)
ostream & operator<<(ostream &s, const KernelExpansion &k)