1 #include "AllClassWrappers.h"
16 #include <pybind11/pybind11.h>
17 #include <pybind11/stl.h>
18 #include <pybind11/eigen.h>
33 std::shared_ptr<KernelBase>> kernBase(m,
"CovarianceKernelBase");
39 .def(
"BuildCovariance", (Eigen::MatrixXd (
KernelBase::*)
40 (Eigen::MatrixXd
const&)
const)
42 .def(
"BuildCovariance", (Eigen::MatrixXd (
KernelBase::*)
43 (Eigen::MatrixXd
const&,
44 Eigen::MatrixXd
const&)
const)
47 (Eigen::MatrixXd
const&,
48 Eigen::MatrixXd
const&,
49 Eigen::Ref<Eigen::MatrixXd>)
const)
52 (Eigen::MatrixXd
const&,
53 Eigen::Ref<Eigen::MatrixXd>)
const)
68 .def(
"__mul__", [](std::shared_ptr<KernelBase> a, std::shared_ptr<KernelBase> b) {
return a * b;}, py::is_operator())
69 .def(
"__add__", [](std::shared_ptr<KernelBase> a, std::shared_ptr<KernelBase> b) {
return a + b;}, py::is_operator());
72 py::class_<ConcatenateKernel, KernelBase, std::shared_ptr<ConcatenateKernel>>
73 concatKern(m,
"ConcatenateKernel");
75 .def(py::init<std::vector<std::shared_ptr<KernelBase>>
const&>())
76 .def(py::init<std::shared_ptr<KernelBase>
const&,
77 std::shared_ptr<KernelBase>
const&>())
83 py::class_<KernelImpl<ConstantKernel>,
KernelBase,
84 std::shared_ptr<KernelImpl<ConstantKernel>>>
85 kernImplConst(m,
"ConstantKernelImpl");
87 .def(py::init<unsigned, unsigned, unsigned>())
88 .def(py::init<
unsigned, std::vector<unsigned>,
unsigned,
unsigned>())
95 py::class_<ConstantKernel, KernelImpl<ConstantKernel>, std::shared_ptr<ConstantKernel>>
96 constKern(m,
"ConstantKernel");
98 .def(py::init<unsigned, const double>())
99 .def(py::init<unsigned, const double, const Eigen::Vector2d>())
100 .def(py::init<
unsigned, std::vector<unsigned>,
const double>())
101 .def(py::init<
unsigned, std::vector<unsigned>,
const double,
102 const Eigen::Vector2d>())
103 .def(py::init<unsigned, Eigen::MatrixXd const&>())
104 .def(py::init<unsigned, Eigen::MatrixXd const&, const Eigen::Vector2d>())
105 .def(py::init<
unsigned, std::vector<unsigned>, Eigen::MatrixXd
const&>())
106 .def(py::init<
unsigned, std::vector<unsigned>, Eigen::MatrixXd
const&,
107 const Eigen::Vector2d>());
112 std::shared_ptr<LinearTransformKernel>>
113 linTransKern(m,
"LinearTransformKernel");
115 .def(py::init<Eigen::MatrixXd
const&, std::shared_ptr<KernelBase>>())
121 py::class_<KernelImpl<MaternKernel>,
KernelBase,
122 std::shared_ptr<KernelImpl<MaternKernel>>>
123 kernImplMat(m,
"MaternKernelImpl");
125 .def(py::init<unsigned, unsigned, unsigned>())
126 .def(py::init<
unsigned, std::vector<unsigned>,
unsigned,
unsigned>())
133 py::class_<MaternKernel, KernelImpl<MaternKernel>,
134 std::shared_ptr<MaternKernel>>
135 matKern(m,
"MaternKernel");
137 .def(py::init<
unsigned, std::vector<unsigned>,
double,
double,
double>())
138 .def(py::init<
unsigned, std::vector<unsigned>,
double,
double,
double,Eigen::Vector2d, Eigen::Vector2d>())
139 .def(py::init<unsigned, double, double, double>())
140 .def(py::init<unsigned, double, double, double, Eigen::Vector2d,Eigen::Vector2d>())
144 py::class_<KernelImpl<PeriodicKernel>,
KernelBase,
145 std::shared_ptr<KernelImpl<PeriodicKernel>>>
146 kernImplPer(m,
"PeriodicKernelImpl");
148 .def(py::init<unsigned, unsigned, unsigned>())
149 .def(py::init<
unsigned, std::vector<unsigned>,
unsigned,
unsigned>())
156 py::class_<PeriodicKernel, KernelImpl<PeriodicKernel>,
157 std::shared_ptr<PeriodicKernel>>
158 periodKern(m,
"PeriodicKernel");
160 .def(py::init<
unsigned, std::vector<unsigned>,
double,
double,
double>())
161 .def(py::init<
unsigned, std::vector<unsigned>,
double,
double,
double, Eigen::Vector2d, Eigen::Vector2d, Eigen::Vector2d>())
162 .def(py::init<unsigned, double, double, double>())
163 .def(py::init<unsigned, double, double, double,Eigen::Vector2d, Eigen::Vector2d, Eigen::Vector2d>())
165 .def(
"GetStateSpace", &PeriodicKernel::GetStateSpace);
168 py::class_<ProductKernel, KernelBase, std::shared_ptr<ProductKernel>>
169 productKern(m,
"ProductKernel");
171 .def(py::init<std::shared_ptr<KernelBase>, std::shared_ptr<KernelBase>>())
179 py::class_<KernelImpl<SquaredExpKernel>,
KernelBase,
180 std::shared_ptr<KernelImpl<SquaredExpKernel>>>
181 kernImplSE(m,
"SquaredExpKernelImpl");
183 .def(py::init<unsigned, unsigned, unsigned>())
184 .def(py::init<
unsigned, std::vector<unsigned>,
unsigned,
unsigned>())
191 py::class_<SquaredExpKernel, KernelImpl<SquaredExpKernel>,
192 std::shared_ptr<SquaredExpKernel>>
193 sqExpKern(m,
"SquaredExpKernel");
195 .def(py::init<
unsigned, std::vector<unsigned>,
double,
double>())
196 .def(py::init<
unsigned, std::vector<unsigned>,
double,
double, Eigen::Vector2d, Eigen::Vector2d>())
197 .def(py::init<unsigned, double, double, Eigen::Vector2d, Eigen::Vector2d>())
198 .def(py::init<unsigned, double, double>());
202 py::class_<SumKernel, KernelBase, std::shared_ptr<SumKernel>>
203 sumKern(m,
"SumKernel");
205 .def(py::init<std::shared_ptr<KernelBase>, std::shared_ptr<KernelBase>>())
212 py::class_<KernelImpl<WhiteNoiseKernel>,
KernelBase,
213 std::shared_ptr<KernelImpl<WhiteNoiseKernel>>>
214 kernImplWN(m,
"WhiteNoiseKernelImpl");
216 .def(py::init<unsigned, unsigned, unsigned>())
217 .def(py::init<
unsigned, std::vector<unsigned>,
unsigned,
unsigned>())
224 py::class_<WhiteNoiseKernel, KernelImpl<WhiteNoiseKernel>,
225 std::shared_ptr<WhiteNoiseKernel>>
226 whiteNoiseKern(m,
"WhiteNoiseKernel");
228 .def(py::init<unsigned, const double>())
229 .def(py::init<unsigned, const double, const Eigen::Vector2d >());
virtual std::shared_ptr< KernelBase > Clone() const override
virtual void FillBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, Eigen::Ref< Eigen::MatrixXd > block) const override
virtual void FillPosDerivBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, std::vector< int > const &wrts, Eigen::Ref< Eigen::MatrixXd > block) const override
Base class for all covariance kernels.
const unsigned int inputDim
virtual Eigen::MatrixXd BuildCovariance(Eigen::MatrixXd const &x) const
virtual std::tuple< std::shared_ptr< muq::Modeling::LinearSDE >, std::shared_ptr< muq::Modeling::LinearOperator >, Eigen::MatrixXd > GetStateSpace(boost::property_tree::ptree sdeOptions=boost::property_tree::ptree()) const
Returns a state space representation of the covariance kernel.
virtual Eigen::MatrixXd GetPosDerivative(Eigen::VectorXd const &x1, Eigen::VectorXd const &x2, std::vector< int > const &wrts) const
Returns derivatives of the kernel with respect to the first input, x1.
virtual void SetParams(Eigen::VectorXd const ¶ms)
const unsigned int numParams
virtual void FillPosDerivBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, std::vector< int > const &wrts, Eigen::Ref< Eigen::MatrixXd > block) const =0
virtual Eigen::MatrixXd Evaluate(Eigen::VectorXd const &x1, Eigen::VectorXd const &x2) const
virtual Eigen::VectorXd GetParams() const
const std::vector< unsigned int > dimInds
virtual void FillDerivCovariance(Eigen::MatrixXd const &xs, Eigen::MatrixXd const &ys, std::vector< int > const &wrts, Eigen::Ref< Eigen::MatrixXd > cov) const
virtual Eigen::MatrixXd GetParamBounds() const
virtual std::vector< std::shared_ptr< KernelBase > > GetSeperableComponents()
Overridden by ProductKernel.
virtual void FillCovariance(Eigen::MatrixXd const &xs, Eigen::MatrixXd const &ys, Eigen::Ref< Eigen::MatrixXd > cov) const
virtual std::shared_ptr< KernelBase > Clone() const =0
virtual void FillBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, Eigen::Ref< Eigen::MatrixXd > block) const =0
Base class in CRTP pattern for covariance kernels.
virtual std::tuple< std::shared_ptr< muq::Modeling::LinearSDE >, std::shared_ptr< muq::Modeling::LinearOperator >, Eigen::MatrixXd > GetStateSpace(boost::property_tree::ptree sdeOptions=boost::property_tree::ptree()) const override
Returns a state space representation of the covariance kernel.
virtual std::vector< std::shared_ptr< KernelBase > > GetSeperableComponents() override
Overridden by ProductKernel.
virtual void FillBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, Eigen::Ref< Eigen::MatrixXd > block) const override
virtual std::tuple< std::shared_ptr< muq::Modeling::LinearSDE >, std::shared_ptr< muq::Modeling::LinearOperator >, Eigen::MatrixXd > GetStateSpace(boost::property_tree::ptree sdeOptions=boost::property_tree::ptree()) const override
Returns a state space representation of the covariance kernel.
virtual std::shared_ptr< KernelBase > Clone() const override
virtual void FillPosDerivBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, std::vector< int > const &wrts, Eigen::Ref< Eigen::MatrixXd > block) const override
virtual std::shared_ptr< KernelBase > Clone() const override
virtual void FillPosDerivBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, std::vector< int > const &wrts, Eigen::Ref< Eigen::MatrixXd > block) const override
virtual void FillBlock(Eigen::Ref< const Eigen::VectorXd > const &x1, Eigen::Ref< const Eigen::VectorXd > const &x2, Eigen::Ref< const Eigen::VectorXd > const ¶ms, Eigen::Ref< Eigen::MatrixXd > block) const override
virtual std::tuple< std::shared_ptr< muq::Modeling::LinearSDE >, std::shared_ptr< muq::Modeling::LinearOperator >, Eigen::MatrixXd > GetStateSpace(boost::property_tree::ptree sdeOptions=boost::property_tree::ptree()) const override
Returns a state space representation of the covariance kernel.
void KernelWrapper(pybind11::module &m)