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

cell count and internal counter fix

parent 505c0a23
Pipeline #145622 failed with stages
in 11 minutes and 22 seconds
......@@ -26,8 +26,8 @@ RMatrix Downsample(const RMatrix &fSample) {
*/
RVector CirculantEmbedding1D::ComputeSqrtEV() {
RVector toepRow(meshes.fine().CellCountGeometry());
RVector toepCol(meshes.fine().CellCountGeometry());
RVector toepRow(cellCount);
RVector toepCol(cellCount);
RVector circRow = covariance.EmbeddedToeplitzMatrix(toepRow, toepCol);
RVector eigenVal(circRow);
......@@ -59,12 +59,14 @@ RVector CirculantEmbedding1D::GenerateLogNormalField(const SampleID &id) {
if (internalCounter == 0)
fineComplexField = GenerateField(id);
RVector logNormalField(0.0, meshes.fine().CellCountGeometry());
RVector logNormalField(0.0, cellCount);
for (int i = 0; i < logNormalField.size(); i++)
if (internalCounter == 0)
logNormalField[i] = exp(fineComplexField[i].real() + mean);
else
logNormalField[i] = exp(fineComplexField[i].imag() + mean);
internalCounter++;
internalCounter = internalCounter % 2;
return logNormalField;
}
......@@ -72,12 +74,14 @@ RVector CirculantEmbedding1D::GenerateGaussianField(const SampleID &id) {
if (internalCounter == 0)
fineComplexField = GenerateField(id);
RVector gaussianField(0.0, meshes.fine().CellCountGeometry());
RVector gaussianField(0.0, cellCount);
for (int i = 0; i < gaussianField.size(); i++)
if (internalCounter == 0)
gaussianField[i] = fineComplexField[i].real() + mean;
else
gaussianField[i] = fineComplexField[i].imag() + mean;
internalCounter++;
internalCounter = internalCounter % 2;
return gaussianField;
}
......@@ -92,7 +96,10 @@ void CirculantEmbedding1D::initVec(const SampleID &id) {
}
void CirculantEmbedding1D::plotSample(const SampleID &id) {
mpp::plot(id.IdString("Kappa")) << *sampleVec << mpp::endp;
if (sampleVec != nullptr)
mpp::plot(id.IdString("Kappa")) << *sampleVec << mpp::endp;
else
Exit("Vector is nullptr")
}
void CirculantEmbedding1D::drawSample(const SampleID &id) {
......@@ -112,8 +119,8 @@ void CirculantEmbedding1D::drawSample(const SampleID &id) {
*/
RMatrix CirculantEmbedding2D::ComputeSqrtEV() {
RMatrix toepRows((int) sqrt(meshes.fine().CellCountGeometry()));
RMatrix toepCols((int) sqrt(meshes.fine().CellCountGeometry()));
RMatrix toepRows((int) sqrt(cellCount));
RMatrix toepCols((int) sqrt(cellCount));
RMatrix circRows = covariance.EmbeddedToeplitzMatrix(toepRows, toepCols);
RMatrix eigenVal(circRows);
......@@ -146,13 +153,15 @@ RMatrix CirculantEmbedding2D::GenerateLogNormalField(const SampleID &id) {
if (internalCounter == 0)
fineComplexField = GenerateField(id);
RMatrix logNormalField(0.0, (int) sqrt(meshes.fine().CellCountGeometry()));
RMatrix logNormalField(0.0, (int) sqrt(cellCount));
for (int i = 0; i < logNormalField.rows(); i++)
for (int j = 0; j < logNormalField.cols(); j++)
if (internalCounter == 0)
logNormalField[i][j] = exp(fineComplexField[i][j].real() + mean);
else
logNormalField[i][j] = exp(fineComplexField[i][j].imag() + mean);
internalCounter++;
internalCounter = internalCounter % 2;
return logNormalField;
}
......@@ -160,13 +169,15 @@ RMatrix CirculantEmbedding2D::GenerateGaussianField(const SampleID &id) {
if (internalCounter == 0)
fineComplexField = GenerateField(id);
RMatrix gaussianField(0.0, (int) sqrt(meshes.fine().CellCountGeometry()));
RMatrix gaussianField(0.0, (int) sqrt(cellCount));
for (int i = 0; i < gaussianField.rows(); i++)
for (int j = 0; j < gaussianField.cols(); j++)
if (internalCounter == 0)
gaussianField[i][j] = fineComplexField[i][j].real() + mean;
else
gaussianField[i][j] = fineComplexField[i][j].imag() + mean;
internalCounter++;
internalCounter = internalCounter % 2;
return gaussianField;
}
......
......@@ -36,6 +36,8 @@ private:
RVector sample;
int cellCount;
protected:
void initVec(const SampleID &id);
......@@ -51,6 +53,7 @@ public:
config.get("StochasticField", fieldType);
config.get("Mean", mean);
cellCount = meshes.fine().CellCountGeometry();
sqrtEigenvalues = ComputeSqrtEV();
}
......@@ -91,6 +94,8 @@ private:
RMatrix sample;
int cellCount;
protected:
void initVec(const SampleID &id);
......@@ -107,6 +112,7 @@ public:
config.get("StochasticField", fieldType);
config.get("Mean", mean);
cellCount = meshes.fine().CellCountGeometry();
sqrtEigenvalues = ComputeSqrtEV();
}
......
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