hops
SquaredExponentialKernel.hpp
Go to the documentation of this file.
1 #ifndef HOPS_SQUAREDEXPONENTIALKERNEL_HPP
2 #define HOPS_SQUAREDEXPONENTIALKERNEL_HPP
3 
4 #include <cmath>
5 
6 namespace hops {
7  template<typename MatrixType, typename VectorType>
9  public:
10  SquaredExponentialKernel (double m_sigma = 1, double length = 1) :
12  length(length) {
13  //
14  }
15 
17  MatrixType covariance(x.rows(), y.rows());
18  for (long i = 0; i < x.rows(); ++i) {
19  for (long j = 0; j < y.rows(); ++j) {
20  VectorType diff = (x.row(i) - y.row(j)).transpose();
21  double squaredDistance = diff.transpose() * diff;
22  double val = m_sigma * m_sigma * std::exp(-0.5 * squaredDistance / (length * length));
23  covariance(i, j) = val;
24  //TODO
25  //covariance(j, i) = val;
26  }
27  }
28  return covariance;
29  }
30 
31  double m_sigma;
32  double length;
33  };
34 }
35 
36 #endif // HOPS_SQUAREDEXPONENTIALKERNEL_HPP
hops::SquaredExponentialKernel::SquaredExponentialKernel
SquaredExponentialKernel(double m_sigma=1, double length=1)
Definition: SquaredExponentialKernel.hpp:10
hops::SquaredExponentialKernel
Definition: SquaredExponentialKernel.hpp:8
hops::MatrixType
Eigen::MatrixXd MatrixType
Definition: MatrixType.hpp:7
hops
Definition: CsvReader.hpp:8
hops::SquaredExponentialKernel::operator()
MatrixType operator()(const MatrixType &x, const MatrixType &y)
Definition: SquaredExponentialKernel.hpp:16
hops::VectorType
Eigen::VectorXd VectorType
Definition: VectorType.hpp:7
hops::SquaredExponentialKernel::m_sigma
double m_sigma
Definition: SquaredExponentialKernel.hpp:31
hops::SquaredExponentialKernel::length
double length
Definition: SquaredExponentialKernel.hpp:32