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