Commit 0e78411b authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

trying out things

parent cc29d01d
......@@ -2,11 +2,11 @@
#define SPARSEGRIDGENERATOR_HPP
#include "TasmanianSparseGrid.hpp"
#include "SampleGenerator.hpp"
// Todo Use RVector and such
class SparseGridGenerator {
//template<typename T>
class SparseGridGenerator : public SampleGenerator<RVector> {
protected:
TasGrid::TasmanianSparseGrid grid;
......@@ -18,11 +18,23 @@ protected:
int outputs;
RVector sample;
std::vector<double> points;
void drawSample(const SampleID &id) override {
for (int i = 0; i < dimension; i++) {
sample[i] = points.front();
points.erase(points.begin());
}
};
public:
SparseGridGenerator(int dimension, int outputs,
SparseGridGenerator(const Meshes &meshes, int dimension, int outputs,
TasGrid::TypeDepth depth = TasGrid::type_level,
TasGrid::TypeOneDRule rule = TasGrid::rule_clenshawcurtis) :
dimension(dimension), outputs(outputs), depth(depth), rule(rule) {
SampleGenerator(meshes), dimension(dimension), outputs(outputs),
depth(depth), rule(rule), sample(RVector(dimension)) {
}
void CreateGlobalGrid(int level) {
......@@ -41,7 +53,11 @@ public:
return grid.getNumPoints();
}
double Quadrature(double func (double, double)) {
int GetStochDimension() {
return grid.getNumDimensions();
}
double Quadrature(double func(double, double)) {
double I = 0.0;
std::vector<double> points = GetPoints();
std::vector<double> weights = GetWeights();
......@@ -53,6 +69,8 @@ public:
}
return I;
}
string Name() const override { return "SparseGridGenerator"; };
};
#endif //SPARSEGRIDGENERATOR_HPP
#include "TestEnvironment.hpp"
#include "MeshesCreator.hpp"
#include "SparseGridGenerator.hpp"
......@@ -6,10 +7,13 @@ const double TEST_TOLERANCE = 1e-10;
class TestSparseGridGenerator : public Test {
protected:
std::unique_ptr<Meshes> meshes;
SparseGridGenerator generator;
TestSparseGridGenerator(int dimension, int outputs) :
generator(dimension, outputs) {
meshes(MeshesCreator("Interval").CreateUnique()),
generator(SparseGridGenerator(*meshes, dimension, outputs)) {
int level = 6;
double exact = 2.513723354063905e+00;
generator.CreateGlobalGrid(level);
......@@ -18,10 +22,6 @@ protected:
void TearDown() override {}
};
double TestFunction(std::vector<double> x) {
return 1.0;
}
class Test1DSparseGridGenerator : public TestSparseGridGenerator {
public:
Test1DSparseGridGenerator() : TestSparseGridGenerator(1, 0) {}
......
Supports Markdown
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