14 #include <unsupported/Eigen/Polynomials>
15 #include <Eigen/SparseCore>
17 #include <boost/property_tree/ptree.hpp>
24 std::vector<unsigned> dimInds,
28 Eigen::Vector2d sigmaBounds,
31 scale(boost::math::tgamma(nuIn+0.5)/boost::math::tgamma(2.0*nuIn)),
32 weights(BuildWeights(nu-0.5))
52 Eigen::Vector2d sigmaBounds,
55 scale(boost::math::tgamma(nuIn+0.5)/boost::math::tgamma(2.0*nuIn)),
56 weights(BuildWeights(nu-0.5))
76 throw std::invalid_argument(
"The value of nu must be greater than 0.");
78 if((std::round(
nu-0.5)-(
nu-0.5)) > 4.0*std::numeric_limits<double>::epsilon())
79 throw std::invalid_argument(
"The value of nu must take the form nu=i-0.5 for a positive integer i.");
84 std::tuple<std::shared_ptr<muq::Modeling::LinearSDE>, std::shared_ptr<muq::Modeling::LinearOperator>, Eigen::MatrixXd>
MaternKernel::GetStateSpace(boost::property_tree::ptree sdeOptions)
const
90 double lambda = sqrt(2.0*
nu)/length;
92 double q = 2.0*sigma2*boost::math::constants::root_pi<double>() * std::pow(lambda, 2*p+1) * tgamma(p+1) / tgamma(p+0.5);
94 Eigen::VectorXd roots = -lambda*Eigen::VectorXd::Ones(p+1);
97 Eigen::roots_to_monicPolynomial( roots, poly );
99 poly = poly.head(poly.size()-1).eval();
101 std::shared_ptr<muq::Modeling::LinearOperator> F = std::make_shared<muq::Modeling::CompanionMatrix>(-1.0*poly);
103 std::vector<Eigen::Triplet<double>> Lcoeffs;
104 Lcoeffs.push_back(Eigen::Triplet<double>(poly.size()-1,0,1.0));
106 Eigen::SparseMatrix<double> Lmat(poly.size(), 1);
107 Lmat.setFromTriplets(Lcoeffs.begin(), Lcoeffs.end());
109 auto L = muq::Modeling::LinearOperator::Create(Lmat);
111 Eigen::MatrixXd Q(1,1);
115 auto sde = std::make_shared<muq::Modeling::LinearSDE>(F, L, Q, sdeOptions);
119 std::vector<Eigen::Triplet<double>> Hcoeffs;
120 Hcoeffs.push_back(Eigen::Triplet<double>(0,0,1.0));
122 Eigen::SparseMatrix<double> Hmat(1,poly.size());
123 Hmat.setFromTriplets(Hcoeffs.begin(), Hcoeffs.end());
125 std::shared_ptr<muq::Modeling::LinearOperator> H = muq::Modeling::LinearOperator::Create(Hmat);
128 Q = L->Apply(L->Apply(q*Eigen::VectorXd::Ones(1)).transpose());
132 return std::make_tuple(sde, H, Pinf);
138 Eigen::VectorXd output(p+1);
139 for(
int i=0; i<=p; ++i){
Eigen::VectorXd cachedParams
Eigen::MatrixXd paramBounds
Base class in CRTP pattern for covariance kernels.
static Eigen::VectorXd BuildWeights(int p)
static int Factorial(int n)
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.
MaternKernel(unsigned dimIn, std::vector< unsigned > dimInds, double sigma2In, double lengthIn, double nuIn)
ComplexMatrixType const & matrixX() const
LyapunovSolver & compute(MatrixType const &A, MatrixType const &C)