Commit 18d5c8c8 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

using rvector and cvector

parent 387cf9bb
...@@ -36,6 +36,7 @@ void CirculantEmbedding1D::generateCoarseSample(const SampleID &id, ...@@ -36,6 +36,7 @@ void CirculantEmbedding1D::generateCoarseSample(const SampleID &id,
coarseSample = new Vector(disc[id.level.coarse]); coarseSample = new Vector(disc[id.level.coarse]);
(*coarseSample) = 0; (*coarseSample) = 0;
// for (cell r = coarseSample->rows(); r != coarseSample->rows_end(); r++) {
for (cell c = coarseSample->cells(); c != coarseSample->cells_end(); c++) { for (cell c = coarseSample->cells(); c != coarseSample->cells_end(); c++) {
row coarseRow = coarseSample->find_row(c()); row coarseRow = coarseSample->find_row(c());
for (int k = 0; k < c.Children(); ++k) { for (int k = 0; k < c.Children(); ++k) {
...@@ -71,7 +72,7 @@ ComplexSequence1D CirculantEmbedding1D::generateField(const SampleID &id) { ...@@ -71,7 +72,7 @@ ComplexSequence1D CirculantEmbedding1D::generateField(const SampleID &id) {
return Xf; return Xf;
} }
void CirculantEmbedding1D::createCovarianceMatrix(ToeplitzRow &ar, ToeplitzColumn &ac) { void CirculantEmbedding1D::createCovarianceMatrix(RVector &ar, RVector &ac) {
const vector<double> &coordinate1 = linspace(domain_start, domain_end, numberOfCells); const vector<double> &coordinate1 = linspace(domain_start, domain_end, numberOfCells);
ar.resize(numberOfCells); ar.resize(numberOfCells);
ac.resize(numberOfCells); ac.resize(numberOfCells);
...@@ -91,21 +92,20 @@ void CirculantEmbedding1D::createCovarianceMatrix(ToeplitzRow &ar, ToeplitzColum ...@@ -91,21 +92,20 @@ void CirculantEmbedding1D::createCovarianceMatrix(ToeplitzRow &ar, ToeplitzColum
} }
} }
void CirculantEmbedding1D::embedCovarianceMatrix(const ToeplitzRow &ar, void CirculantEmbedding1D::embedCovarianceMatrix(const RVector &ar,
const ToeplitzColumn &ac, const RVector &ac,
CirculantRow &br) { RVector &br) {
br.reserve(2 * ar.size() - 1); br.append(ar);
br.insert(br.end(), ar.begin(), ar.end()); br.append(RVector(std::vector<double>(ac.rbegin(), ac.rend() - 1)));
br.insert(br.end(), ac.rbegin(), ac.rend() - 1);
} }
void CirculantEmbedding1D::computeEV(const CirculantRow &br, void CirculantEmbedding1D::computeEV(const RVector &br,
EigenValues1D &ev) { RVector &ev) {
fft(br, ev); fft(br, ev);
} }
void CirculantEmbedding1D::padding(ToeplitzRow &ar, void CirculantEmbedding1D::padding(RVector &ar,
ToeplitzColumn &ac) { RVector &ac) {
double delta = (domain_end - domain_start) / (numberOfCells - 1); double delta = (domain_end - domain_start) / (numberOfCells - 1);
// Add 50% more points // Add 50% more points
...@@ -133,8 +133,8 @@ void CirculantEmbedding1D::padding(ToeplitzRow &ar, ...@@ -133,8 +133,8 @@ void CirculantEmbedding1D::padding(ToeplitzRow &ar,
} }
} }
SqrtEigenValues1D CirculantEmbedding1D::computeSqrtEV() { RVector CirculantEmbedding1D::computeSqrtEV() {
vector<double> sqrt_ev_return, ar, ac, br, ev; RVector sqrt_ev_return, ar, ac, br, ev;
createCovarianceMatrix(ar, ac); createCovarianceMatrix(ar, ac);
embedCovarianceMatrix(ar, ac, br); embedCovarianceMatrix(ar, ac, br);
......
...@@ -9,16 +9,6 @@ ...@@ -9,16 +9,6 @@
#include "basics/PlotMap.hpp" #include "basics/PlotMap.hpp"
typedef std::vector<double> EigenValues1D;
typedef std::vector<double> SqrtEigenValues1D;
typedef std::vector<double> ToeplitzRow;
typedef std::vector<double> ToeplitzColumn;
typedef std::vector<double> CirculantRow;
typedef std::vector<std::vector<double>> EigenValues2D; typedef std::vector<std::vector<double>> EigenValues2D;
typedef std::vector<std::vector<double>> SqrtEigenValues2D; typedef std::vector<std::vector<double>> SqrtEigenValues2D;
...@@ -69,9 +59,9 @@ class CirculantEmbedding1D : public CirculantEmbedding, public CovarianceFunctio ...@@ -69,9 +59,9 @@ class CirculantEmbedding1D : public CirculantEmbedding, public CovarianceFunctio
public: public:
NormalDistributionComplexSequence1D generator; NormalDistributionComplexSequence1D generator;
ComplexSequence1D fineComplexField; CVector fineComplexField;
SqrtEigenValues1D sqrtEigenvalues; RVector sqrtEigenvalues;
int numberOfCellsEmbedded = 0; int numberOfCellsEmbedded = 0;
int numberOfCells = 0; int numberOfCells = 0;
...@@ -96,22 +86,22 @@ public: ...@@ -96,22 +86,22 @@ public:
Vector *&fineSample, Vector *&fineSample,
Vector *&coarseSample) override; Vector *&coarseSample) override;
ComplexSequence1D generateField(const SampleID &id); CVector generateField(const SampleID &id);
void createCovarianceMatrix(ToeplitzRow &ar, void createCovarianceMatrix(RVector &ar,
ToeplitzColumn &ac); RVector &ac);
static void embedCovarianceMatrix(const ToeplitzRow &ar, static void embedCovarianceMatrix(const RVector &ar,
const ToeplitzColumn &ac, const RVector &ac,
CirculantRow &br); RVector &br);
static void computeEV(const CirculantRow &br, static void computeEV(const RVector &br,
EigenValues1D &ev); RVector &ev);
void padding(ToeplitzRow &ar, void padding(RVector &ar,
ToeplitzColumn &ac); RVector &ac);
SqrtEigenValues1D computeSqrtEV(); RVector computeSqrtEV();
}; };
class CirculantEmbedding2D : public CirculantEmbedding, public CovarianceFunction2D { class CirculantEmbedding2D : public CirculantEmbedding, public CovarianceFunction2D {
......
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