10 std::vector<std::shared_ptr<IndexedScalarBasis>>
const& polyTypesIn) : quadTypes(quadTypesIn),
11 polyTypes(polyTypesIn),
15 assert(dim==polyTypesIn.size());
20 std::shared_ptr<muq::Utilities::MultiIndex>
const& quadOrders,
21 std::vector<std::shared_ptr<IndexedScalarBasis>>
const& polyTypesIn) :
PCEFactory(quadTypesIn, polyTypesIn)
23 unsigned int dim = quadTypesIn.size();
24 assert(dim==quadOrders->GetLength());
25 assert(dim==polyTypesIn.size());
37 unsigned int dim = quadOrders->GetLength();
42 Eigen::RowVectorXi orders(dim);
43 for(
unsigned int i=0; i<dim; ++i)
44 orders(i) = std::floor(
quadTypes.at(i)->Exactness(quadOrders->GetValue(i)) / 2.0);
46 polyMultis = MultiIndexFactory::CreateFullTensor(orders);
52 for(
unsigned int i=0; i<
quadPts.size(); ++i)
57 std::shared_ptr<muq::Utilities::MultiIndex>
const& quadOrders,
58 std::vector<std::shared_ptr<IndexedScalarBasis>>
const& polyTypesIn,
59 std::shared_ptr<MultiIndexSet>
const& polyMultisIn) :
PCEFactory(quadTypesIn,polyTypesIn)
65 std::shared_ptr<PolynomialChaosExpansion>
PCEFactory::Compute(std::shared_ptr<muq::Modeling::ModPiece>
const& model)
68 assert(model->outputSizes.size()==1);
69 assert(model->inputSizes.size()==1);
72 std::vector<Eigen::VectorXd> quadEvals(
quadPts.size());
74 quadEvals.at(
k) = model->Evaluate(quadEvals.at(
k)).at(0);
79 std::shared_ptr<PolynomialChaosExpansion>
PCEFactory::Compute(std::vector<Eigen::VectorXd>
const& quadEvals,
80 std::shared_ptr<muq::Utilities::MultiIndex>
const& quadOrders)
86 std::shared_ptr<PolynomialChaosExpansion>
PCEFactory::Compute(std::vector<std::reference_wrapper<const Eigen::VectorXd>>
const& quadEvals,
87 std::shared_ptr<muq::Utilities::MultiIndex>
const& quadOrders)
93 std::shared_ptr<PolynomialChaosExpansion>
PCEFactory::Compute(std::vector<Eigen::VectorXd>
const& quadEvals)
95 std::vector<std::reference_wrapper<const Eigen::VectorXd>> refVec;
96 for(
auto& eval : quadEvals)
97 refVec.push_back(std::ref(eval));
102 std::shared_ptr<PolynomialChaosExpansion>
PCEFactory::Compute(std::vector<std::reference_wrapper<const Eigen::VectorXd>>
const& quadEvals)
104 assert(quadEvals.size()==
quadPts.size());
105 unsigned int outputDim = quadEvals.at(0).get().size();
110 Eigen::MatrixXd coeffs = Eigen::MatrixXd::Zero(quadEvals.at(0).get().size(),
polyMultis->Size());
114 coeffs +=
quadWts(
k) * quadEvals.at(
k).get() * pce->BuildVandermonde(
quadPts.at(
k));
116 Eigen::VectorXd allNorms = pce->GetNormalizationVec().array().square().matrix();
117 coeffs = (coeffs.array().rowwise() / allNorms.transpose().array()).eval();
119 pce->SetCoeffs(coeffs);
125 std::vector<Eigen::VectorXd>
const&
PCEFactory::QuadPts(std::shared_ptr<muq::Utilities::MultiIndex>
const& quadOrders)
virtual void Compute(unsigned int order) override
Factory class for constructing a pseudo-spectral polynomial chaos approximation using a fixed quadrat...
std::shared_ptr< muq::Utilities::MultiIndex > quadOrdersCache
FullTensorQuadrature tensQuad
PCEFactory(std::vector< std::shared_ptr< Quadrature >> const &quadTypesIn, std::vector< std::shared_ptr< IndexedScalarBasis >> const &polyTypesIn)
std::vector< Eigen::VectorXd > const & QuadPts() const
void Setup(std::shared_ptr< muq::Utilities::MultiIndex > const &quadOrders)
std::vector< Eigen::VectorXd > quadPts
std::shared_ptr< PolynomialChaosExpansion > Compute(std::shared_ptr< muq::Modeling::ModPiece > const &model)
std::vector< std::shared_ptr< Quadrature > > quadTypes
std::shared_ptr< muq::Utilities::MultiIndexSet > polyMultis
std::vector< std::shared_ptr< IndexedScalarBasis > > polyTypes
virtual Eigen::MatrixXd const & Points() const
virtual Eigen::VectorXd const & Weights() const