17 scalarRules(scalarRulesIn)
30 std::shared_ptr<MultiIndexSet> multis =
BuildMultis(orders);
39 int minOrder = orders.minCoeff();
42 auto multis = MultiIndexFactory::CreateTotalOrder(
dim,minOrder);
63 auto tensorQuad = std::make_shared<FullTensorQuadrature>(
scalarRules);
66 std::map<Eigen::VectorXd, double, muq::Utilities::VectorLessThan<double>> quadParts;
68 for(
int i=0; i<multis->Size(); ++i)
71 if(std::abs(smolyWts(i))>5.0*std::numeric_limits<double>::epsilon()){
72 Eigen::RowVectorXi multiVec = multis->IndexToMulti(i)->GetVector();
74 tensorQuad->Compute(multiVec);
76 auto& tensorPts = tensorQuad->Points();
77 auto& tensorWts = tensorQuad->Weights();
80 for(
int ptInd = 0; ptInd<tensorPts.cols(); ++ptInd){
82 auto iter = quadParts.find(tensorPts.col(ptInd));
83 if(iter!=quadParts.end()){
84 iter->second += smolyWts(i)*tensorWts(ptInd);
86 quadParts[tensorPts.col(ptInd)] = smolyWts(i)*tensorWts(ptInd);
93 unsigned int numNz = 0;
94 double weightTol = 5.0*std::numeric_limits<double>::epsilon();
95 for(
auto& keyVal : quadParts)
96 numNz += (std::abs(keyVal.second)>weightTol) ? 1.0 : 0.0;
101 unsigned int ind = 0;
102 for(
auto& part : quadParts){
103 if(std::abs(part.second)>weightTol){
104 pts.col(ind) = part.first;
105 wts(ind) = part.second;
113 std::shared_ptr<MultiIndexSet>
const& multis,
114 Eigen::VectorXd & multiWeights)
116 unsigned int dim = multis->GetMultiLength();
117 auto optMultis = MultiIndexFactory::CreateFullTensor(
dim,1);
119 auto& activeMulti = multis->IndexToMulti(activeInd);
122 auto&
k = multis->IndexToMulti(activeInd);
124 for(
unsigned int j=0; j<optMultis->Size(); ++j){
126 auto newMulti = MultiIndex::Copy(activeMulti);
127 double weightIncr = 1.0;
130 for(
auto it = optMultis->IndexToMulti(j)->GetNzBegin(); it != optMultis->IndexToMulti(j)->GetNzEnd(); ++it) {
131 if((it->second>0)&&(activeMulti->GetValue(it->first)>0)){
133 newMulti->SetValue(it->first, activeMulti->GetValue(it->first)-1);
134 }
else if(
k->GetValue(it->first)==0){
139 multiWeights(multis->MultiToIndex(newMulti)) += weightIncr;
146 Eigen::VectorXd multiWeights = Eigen::VectorXd::Zero(multis->Size());
148 for(
unsigned int i = 0; i<multis->Size(); ++i) {
Base class for multivariate quadrature rules. @detail An abstract class for computing nodes and weigh...
Computes static Smolyak quadrature rules for multivariate integration.
std::vector< std::shared_ptr< Quadrature > > scalarRules
SmolyakQuadrature(unsigned int dim, std::shared_ptr< Quadrature > const &scalarRule)
static void UpdateWeights(unsigned int activeInd, std::shared_ptr< muq::Utilities::MultiIndexSet > const &multis, Eigen::VectorXd &multiWeights)
virtual void Compute(unsigned int order) override
static Eigen::VectorXd ComputeWeights(std::shared_ptr< muq::Utilities::MultiIndexSet > const &multis)
std::shared_ptr< muq::Utilities::MultiIndexSet > BuildMultis(Eigen::RowVectorXi const &orders) const