Commit b67bed4a authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

added SumOfWeights

parent 3c231a21
......@@ -5,7 +5,6 @@
#include "SampleGenerator.hpp"
//template<typename T>
class SparseGridGenerator : public SampleGenerator<RVector> {
protected:
TasGrid::TasmanianSparseGrid grid;
......@@ -35,6 +34,8 @@ protected:
void drawSample(const SampleID &id) override {
sample = samples[id.number];
weight = weights[id.number];
// Todo clarify how to treat the fact that the weights add up to 2*dimension
// weight = weights[id.number] / (2.0 * dimension);
};
public:
......@@ -61,6 +62,8 @@ public:
}
double SampleWeight(const SampleID &id) {
// Todo clarify how to treat the fact that the weights add up to 2*dimension
// return weights[id.number] / (2.0 * dimension);
return weights[id.number];
}
......@@ -68,6 +71,10 @@ public:
return grid.getNumPoints();
}
double SumOfWeights() const {
return 2.0 * dimension;
}
int GetStochDimension() {
return grid.getNumDimensions();
}
......@@ -76,20 +83,6 @@ public:
return sample;
}
// todo move to stochastic collocation class
double Quadrature(double func(double, double)) {
double I = 0.0;
std::vector<double> points = grid.getPoints();
std::vector<double> weights = GetWeights();
int num_points = GetNumPoints();
for (int i = 0; i < num_points; i++) {
double x = points[i * dimension];
double y = points[i * dimension + 1];
I += weights[i] * func(x, y);
}
return I;
}
string Name() const override { return "SparseGridGenerator"; };
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment