10 CountCoDims(kernelsIn),
11 CountParams(kernelsIn)),
15 for(
int i=1; i<
kernels.size(); ++i)
21 for(
int i=0; i<
kernels.size(); ++i){
23 paramCnt +=
kernels.at(i)->numParams;
29 Eigen::Ref<const Eigen::VectorXd>
const& x2,
30 Eigen::Ref<const Eigen::VectorXd>
const& params,
31 Eigen::Ref<Eigen::MatrixXd> block)
const
37 for(
int i=0; i<
kernels.size(); ++i){
41 params.segment(paramCnt,
kernels.at(i)->numParams),
42 block.block(codimCnt,codimCnt,
kernels.at(i)->coDim,
kernels.at(i)->coDim));
44 codimCnt +=
kernels.at(i)->coDim;
45 paramCnt +=
kernels.at(i)->numParams;
50 Eigen::Ref<const Eigen::VectorXd>
const& x2,
51 Eigen::Ref<const Eigen::VectorXd>
const& params,
52 std::vector<int>
const& wrts,
53 Eigen::Ref<Eigen::MatrixXd> block)
const
59 for(
int i=0; i<
kernels.size(); ++i){
61 kernels.at(i)->FillPosDerivBlock(x1,
63 params.segment(paramCnt,
kernels.at(i)->numParams),
65 block.block(codimCnt,codimCnt,
kernels.at(i)->coDim,
kernels.at(i)->coDim));
67 codimCnt +=
kernels.at(i)->coDim;
68 paramCnt +=
kernels.at(i)->numParams;
75 for(
auto& kernel : kernelsIn)
82 for(
auto& kernel : kernelsIn)
83 cnt += kernel->numParams;
88 std::tuple<std::shared_ptr<muq::Modeling::LinearSDE>, std::shared_ptr<muq::Modeling::LinearOperator>, Eigen::MatrixXd>
ConcatenateKernel::GetStateSpace(boost::property_tree::ptree sdeOptions)
const
90 unsigned int numKernels =
kernels.size();
91 std::vector<std::shared_ptr<muq::Modeling::LinearSDE>> sdes(numKernels);
92 std::vector<std::shared_ptr<muq::Modeling::LinearOperator>> obsOps(numKernels);
93 std::vector<Eigen::MatrixXd> statCovs(numKernels);
95 unsigned int totalStatSize = 0;
96 unsigned int totalProcSize = 0;
97 for(
unsigned int i=0; i<numKernels; ++i){
98 std::tie(sdes.at(i), obsOps.at(i), statCovs.at(i)) =
kernels.at(i)->GetStateSpace(sdeOptions);
99 totalStatSize += statCovs.at(i).rows();
100 if(sdes.at(i)->GetL())
101 totalProcSize += sdes.at(i)->GetL()->cols();
104 std::shared_ptr<muq::Modeling::LinearOperator> combinedObsOp = std::make_shared<BlockDiagonalOperator>(obsOps);
107 std::vector<std::shared_ptr<muq::Modeling::LinearOperator>> allFs;
108 std::vector<std::shared_ptr<muq::Modeling::LinearOperator>> allLs;
109 Eigen::MatrixXd newProcessCov = Eigen::MatrixXd::Zero(totalProcSize, totalProcSize);
110 Eigen::MatrixXd newStatCov = Eigen::MatrixXd::Zero(totalStatSize, totalStatSize);
112 unsigned int currStatRow = 0;
113 unsigned int currProcRow = 0;
114 for(
unsigned int i=0; i<numKernels; ++i){
117 if(sdes.at(i)->GetL()){
118 allLs.push_back(sdes.at(i)->GetL());
120 newProcessCov.block(currProcRow,currProcRow, allLs.back()->cols(), allLs.back()->cols()) = sdes.at(i)->GetQ();
121 currProcRow += allLs.back()->cols();
123 allLs.push_back(std::make_shared<ZeroOperator>(sdes.at(i)->GetF()->rows(),0));
127 allFs.push_back( sdes.at(i)->GetF() );
128 newStatCov.block(currStatRow,currStatRow, statCovs.at(i).rows(), statCovs.at(i).cols()) = statCovs.at(i);
129 currStatRow += statCovs.at(i).rows();
132 std::shared_ptr<muq::Modeling::LinearOperator> combinedF = std::make_shared<BlockDiagonalOperator>(allFs);
133 std::shared_ptr<muq::Modeling::LinearOperator> combinedL = std::make_shared<BlockDiagonalOperator>(allLs);
136 auto combinedSDE = std::make_shared<muq::Modeling::LinearSDE>(combinedF, combinedL, newProcessCov, sdeOptions);
138 return std::make_tuple(combinedSDE, combinedObsOp, newStatCov);
std::vector< std::shared_ptr< KernelBase > > kernels
static unsigned int CountParams(std::vector< std::shared_ptr< KernelBase >> kernels)
ConcatenateKernel(std::shared_ptr< KernelBase > const &kernel1In, std::shared_ptr< KernelBase > const &kernel2In)
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 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
static unsigned int CountCoDims(std::vector< std::shared_ptr< KernelBase >> kernels)
Base class for all covariance kernels.
const unsigned int numParams
Eigen::VectorXd cachedParams