MUQ  0.4.3
SquaredExpKernel.h
Go to the documentation of this file.
1 #ifndef SQUAREDEXPKERNEL_H
2 #define SQUAREDEXPKERNEL_H
3 
5 
6 
7 namespace muq
8 {
9 namespace Approximation
10 {
11 
12 
24 class SquaredExpKernel : public KernelImpl<SquaredExpKernel>
25 {
26 
27 public:
28 
29  SquaredExpKernel(unsigned dimIn,
30  std::vector<unsigned> dimInds,
31  double sigma2In,
32  double lengthIn) : SquaredExpKernel(dimIn,
33  dimInds,
34  sigma2In,
35  lengthIn,
36  {0.0, std::numeric_limits<double>::infinity()},
37  {1e-10, std::numeric_limits<double>::infinity()})
38  {};
39 
40  SquaredExpKernel(unsigned dimIn,
41  std::vector<unsigned> dimInds,
42  double sigma2In,
43  double lengthIn,
44  Eigen::Vector2d sigmaBounds,
45  Eigen::Vector2d lengthBounds) : KernelImpl<SquaredExpKernel>(dimIn, dimInds, 1, 2)
46  {
47  paramBounds.resize(2,2);
48  paramBounds(0,0) = sigmaBounds(0);
49  paramBounds(1,0) = sigmaBounds(1);
50  paramBounds(0,1) = lengthBounds(0);
51  paramBounds(1,1) = lengthBounds(1);
52 
53  cachedParams.resize(2);
54  cachedParams(0) = sigma2In;
55  cachedParams(1) = lengthIn;
56  };
57 
58  SquaredExpKernel(unsigned dimIn,
59  double sigma2In,
60  double lengthIn) : SquaredExpKernel(dimIn,
61  sigma2In,
62  lengthIn,
63  {0.0, std::numeric_limits<double>::infinity()},
64  {1e-10, std::numeric_limits<double>::infinity()} )
65  {};
66 
67  SquaredExpKernel(unsigned dimIn,
68  double sigma2In,
69  double lengthIn,
70  Eigen::Vector2d sigmaBounds,
71  Eigen::Vector2d lengthBounds) : KernelImpl<SquaredExpKernel>(dimIn, 1, 2)
72  {
73  paramBounds.resize(2,2);
74  paramBounds(0,0) = sigmaBounds(0);
75  paramBounds(1,0) = sigmaBounds(1);
76  paramBounds(0,1) = lengthBounds(0);
77  paramBounds(1,1) = lengthBounds(1);
78 
79  cachedParams.resize(2);
80  cachedParams(0) = sigma2In;
81  cachedParams(1) = lengthIn;
82  };
83 
84  virtual ~SquaredExpKernel(){};
85 
86  template<typename ScalarType1, typename ScalarType2, typename ScalarType3>
87  void FillBlockImpl(Eigen::Ref<const Eigen::Matrix<ScalarType1, Eigen::Dynamic, 1>> const& x1,
88  Eigen::Ref<const Eigen::Matrix<ScalarType1, Eigen::Dynamic, 1>> const& x2,
89  Eigen::Ref<const Eigen::Matrix<ScalarType2, Eigen::Dynamic, 1>> const& params,
90  Eigen::Ref<Eigen::Matrix<ScalarType3,Eigen::Dynamic, Eigen::Dynamic>> block) const
91  {
92  ScalarType1 squaredDist = (x1-x2).squaredNorm();
93  block(0,0) = params(0)*exp(-0.5*squaredDist/(params(1)*params(1)));
94  }
95 };
96 
97 }
98 }
99 
100 
101 #endif
Eigen::VectorXd cachedParams
Definition: KernelBase.h:156
const std::vector< unsigned int > dimInds
Definition: KernelBase.h:126
Base class in CRTP pattern for covariance kernels.
Definition: KernelImpl.h:26
void FillBlockImpl(Eigen::Ref< const Eigen::Matrix< ScalarType1, Eigen::Dynamic, 1 >> const &x1, Eigen::Ref< const Eigen::Matrix< ScalarType1, Eigen::Dynamic, 1 >> const &x2, Eigen::Ref< const Eigen::Matrix< ScalarType2, Eigen::Dynamic, 1 >> const &params, Eigen::Ref< Eigen::Matrix< ScalarType3, Eigen::Dynamic, Eigen::Dynamic >> block) const
SquaredExpKernel(unsigned dimIn, double sigma2In, double lengthIn, Eigen::Vector2d sigmaBounds, Eigen::Vector2d lengthBounds)
SquaredExpKernel(unsigned dimIn, double sigma2In, double lengthIn)
SquaredExpKernel(unsigned dimIn, std::vector< unsigned > dimInds, double sigma2In, double lengthIn)
SquaredExpKernel(unsigned dimIn, std::vector< unsigned > dimInds, double sigma2In, double lengthIn, Eigen::Vector2d sigmaBounds, Eigen::Vector2d lengthBounds)