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