9 std::vector<Eigen::MatrixXd>
const& seedPts,
10 std::vector<Eigen::VectorXd>
const& seedWts,
11 boost::property_tree::ptree options)
14 const unsigned int numComps = kernels.size();
17 assert(numComps == seedPts.size());
18 assert(seedPts.size() == seedWts.size());
20 const unsigned int inputDim = kernels.at(0).inputDim;
22 for(
int i=1; i<kernels.size(); ++i)
23 assert(kernels.at(i).inputDim == inputDim);
26 components.resize(numComps);
30 Eigen::RowVectorXi allNumModes(numComps);
32 for(
int i=0; i<numComps; ++i){
33 Eigen::MatrixXd newPts = Eigen::MatrixXd::Zero(inputDim, seedPts.at(i).cols());
35 for(
int j=0; j<kernels.at(i).dimInds.size(); ++j)
36 newPts.row(kernels.at(i).dimInds.at(j)) = seedPts.at(i).row(j);
38 components.at(i) = std::make_shared<KarhuneLoeveExpansion>(kernels.at(i), newPts, seedWts.at(i), options);
40 allNumModes(i) = components.at(i)->NumModes();
41 numModes *= components.at(i)->NumModes();
44 modeInds = MultiIndexFactoryCreateFullTensor(allNumModes);
55 std::vector<Eigen::MatrixXd> allModes(components.size());
56 for(
int i=0; i<components.size(); ++i)
57 allModes.at(i) = components.at(i)->GetModes(pts);
59 Eigen::MatrixXd output = Eigen::MatrixXd::Ones(pts.cols(), numModes);
61 for(
int i=0; i<modeInds->Size(); ++i){
62 for(
auto nzIt = modeInds->at(i)->GetNzBegin(); nzIt != modeInds->at(i)->GetNzEnd(); ++nzIt){
63 output.col(i) *= allModes.at(nzIt->first).col(nzIt->second);
virtual unsigned int NumModes() const override
virtual Eigen::MatrixXd GetModes(Eigen::Ref< const Eigen::MatrixXd > const &pts) const override
SeparableKarhunenLoeve(std::vector< std::shared_ptr< KernelBase >> kernelsIn, std::vector< Eigen::MatrixXd > const &seedPtsIn, std::vector< Eigen::VectorXd > const &seedWtsIn, boost::property_tree::ptree options=boost::property_tree::ptree())