Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jandom committed Nov 4, 2020
1 parent 6afc19e commit a06c676
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 40 deletions.
4 changes: 2 additions & 2 deletions regtest/core/rt-make-value/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ using namespace PLMD;

int testConstructor(std::ofstream &ofs) {
ofs << "testConstructor" << std::endl;
Value *value = new Value();
std::unique_ptr<Value> value (new Value());
ofs << value->get() << std::endl;
return 0;
}

int testConstructorWithName(std::ofstream &ofs) {
ofs << "testConstructorWithName" << std::endl;
Value *value = new Value("name");
std::unique_ptr<Value> value (new Value());
ofs << value->get() << std::endl;
return 0;
}
Expand Down
12 changes: 6 additions & 6 deletions regtest/tools/rt-make-angle/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ int testCompute4Vectors45Degrees(std::ofstream &ofs) {
Angle angle;
double result = angle.compute(vector1, vector2, d1, d2);
ofs << result << std::endl;
ofs << d1[0] << " " << d1[1] << " " << d1[2] << std::endl;
ofs << d2[0] << " " << d2[1] << " " << d2[2] << std::endl;
ofs << d1 << std::endl;
ofs << d2 << std::endl;
return 0;
}

Expand All @@ -46,8 +46,8 @@ int testCompute4VectorsParallel(std::ofstream &ofs) {
Angle angle;
double result = angle.compute(vector1, vector2, d1, d2);
ofs << result << std::endl;
ofs << d1[0] << " " << d1[1] << " " << d1[2] << std::endl;
ofs << d2[0] << " " << d2[1] << " " << d2[2] << std::endl;
ofs << d1 << std::endl;
ofs << d2 << std::endl;
return 0;
}

Expand All @@ -59,8 +59,8 @@ int testCompute4VectorsAntiParallel(std::ofstream &ofs) {
Angle angle;
double result = angle.compute(vector1, vector2, d1, d2);
ofs << result << std::endl;
ofs << d1[0] << " " << d1[1] << " " << d1[2] << std::endl;
ofs << d2[0] << " " << d2[1] << " " << d2[2] << std::endl;
ofs << d1 << std::endl;
ofs << d2 << std::endl;
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions regtest/tools/rt-make-grid/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ std::unique_ptr<GridBase> createGrid() {
const std::vector<Value *> grid_args_ = {value};
std::unique_ptr<GridBase> gridBase = GridBase::create(
"external.bias", grid_args_, gridfile, false, false, false);
delete value;
return gridBase;
}

Expand Down
8 changes: 4 additions & 4 deletions regtest/tools/rt-make-lattice-reduction/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace PLMD;

int testReduce(std::ofstream &ofs) {
ofs << "testReduce2" << std::endl;
Tensor *tensor = new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0);
std::unique_ptr<Tensor> tensor (new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0));
LatticeReduction::reduce(*tensor);
ofs << tensor->getRow(0)[0] << " " << tensor->getRow(0)[1] << " " << tensor->getRow(0)[2] << std::endl;
ofs << tensor->getRow(1)[0] << " " << tensor->getRow(1)[1] << " " << tensor->getRow(1)[2] << std::endl;
Expand All @@ -17,7 +17,7 @@ int testReduce(std::ofstream &ofs) {

int testReduceSlow(std::ofstream &ofs) {
ofs << "testReduceSlow" << std::endl;
Tensor *tensor = new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0);
std::unique_ptr<Tensor> tensor (new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0));
LatticeReduction::reduceSlow(*tensor);
ofs << tensor->getRow(0)[0] << " " << tensor->getRow(0)[1] << " " << tensor->getRow(0)[2] << std::endl;
ofs << tensor->getRow(1)[0] << " " << tensor->getRow(1)[1] << " " << tensor->getRow(1)[2] << std::endl;
Expand All @@ -27,7 +27,7 @@ int testReduceSlow(std::ofstream &ofs) {

int testReduceFast(std::ofstream &ofs) {
ofs << "testReduceFast" << std::endl;
Tensor *tensor = new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0);
std::unique_ptr<Tensor> tensor (new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0));
LatticeReduction::reduceFast(*tensor);
ofs << tensor->getRow(0)[0] << " " << tensor->getRow(0)[1] << " " << tensor->getRow(0)[2] << std::endl;
ofs << tensor->getRow(1)[0] << " " << tensor->getRow(1)[1] << " " << tensor->getRow(1)[2] << std::endl;
Expand All @@ -37,7 +37,7 @@ int testReduceFast(std::ofstream &ofs) {

int testIsReduced(std::ofstream &ofs) {
ofs << "testIsReduced" << std::endl;
Tensor *tensor = new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0);
std::unique_ptr<Tensor> tensor (new Tensor(1.0, 2.0, 3.0, 5.0, 4.0, 3.0, 10.0, 8.0, 2.0));
bool result1 = LatticeReduction::isReduced(*tensor);
ofs << result1 << std::endl;
LatticeReduction::reduce(*tensor);
Expand Down
69 changes: 46 additions & 23 deletions regtest/tools/rt-make-random/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,93 @@ int testConstructor(std::ofstream &ofs) {

int testRandU01(std::ofstream &ofs) {
ofs << "testRandU01" << std::endl;
Random *random = new Random("random");
ofs << random->RandU01() << std::endl;
random->IncreasedPrecis(true);
ofs << random->RandU01() << std::endl;
Random random("random");
ofs << random.RandU01() << std::endl;
random.IncreasedPrecis(true);
ofs << random.RandU01() << std::endl;
return 0;
}

int testU01d(std::ofstream &ofs) {
ofs << "testU01d" << std::endl;
Random *random = new Random("random");
ofs << random->U01d() << std::endl;
Random random("random");
ofs << random.U01d() << std::endl;
return 0;
}

int testU01(std::ofstream &ofs) {
ofs << "testU01" << std::endl;
Random *random = new Random("random");
ofs << random->U01() << std::endl;
Random random("random");
ofs << random.U01() << std::endl;
return 0;
}

int testWriteStateFull(std::ofstream &ofs) {
ofs << "testWriteStateFull" << std::endl;
Random *random = new Random("random");
random->WriteStateFull(ofs);
Random random("random");
random.WriteStateFull(ofs);
return 0;
}

int testString(std::ofstream &ofs) {
ofs << "testString" << std::endl;
Random *random = new Random("random");
int testStringSimple(std::ofstream &ofs) {
ofs << "testStringSimple" << std::endl;
Random random("random");
std::string str = "";
random->toString(str);
random.U01();
random.toString(str);
ofs << str << std::endl;
random->fromString(str);
random.fromString(str);
return 0;
}

int testStringComplex(std::ofstream &ofs) {
ofs << "testStringComplex" << std::endl;
Random random("random");
std::string str = "";
random.toString(str);
ofs << str << std::endl;
random.fromString(str);
return 0;
}

int testGaussian(std::ofstream &ofs) {
ofs << "testGaussian" << std::endl;
Random *random = new Random("random");
double result = random->Gaussian();
Random random("random");
double result = random.Gaussian();
ofs << result << std::endl;
return 0;
}

int testShuffle(std::ofstream &ofs) {
ofs << "testShuffle" << std::endl;
Random *random = new Random("random");
int testShuffleSimple(std::ofstream &ofs) {
ofs << "testShuffleSimple" << std::endl;
Random random("random");
std::vector<unsigned> vector = {1, 2};
random->Shuffle(vector);
random.Shuffle(vector);
ofs << vector[0] << " " << vector[1] << std::endl;
return 0;
}

int testShuffleComplex(std::ofstream &ofs) {
ofs << "testShuffleComplex" << std::endl;
Random random("random");
std::vector<unsigned> vector = {1, 2, 3, 4};
random.Shuffle(vector);
ofs << vector[0] << " " << vector[1] << " " << vector[2] << " " << vector[3] << std::endl;
return 0;
}


int main() {
std::ofstream ofs("output");
testConstructor(ofs);
testRandU01(ofs);
testU01d(ofs);
testU01(ofs);
testWriteStateFull(ofs);
testString(ofs);
testStringSimple(ofs);
testStringComplex(ofs);
testGaussian(ofs);
testShuffle(ofs);
testShuffleSimple(ofs);
testShuffleComplex(ofs);
return 0;
}
12 changes: 8 additions & 4 deletions regtest/tools/rt-make-random/output.reference
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ testU01
0.415999
testWriteStateFull
random
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
testString
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
0 0 0 2128236579 1624379149 1358580979 704877633 1580723810 101929267 563613512 1636807826 1954899097 1505795335 530511967 1404280278 197493099 1131570933 1817129560 1998097157 1264817709 1474833169 896544303 143542612 823378840 16531729 1441282327 1137522503 114807987 74243042 1784484492 1115438165 823564440 2007237709 1458777923 0 0
testStringSimple
530511967|893351816|784558821|2128236579|1624379149|1358580979|704877633|1580723810|101929267|563613512|1636807826|1954899097|1505795335|530511967|1404280278|197493099|1131570933|1817129560|1998097157|1264817709|1474833169|896544303|143542612|823378840|16531729|1441282327|1137522503|114807987|74243042|1784484492|1115438165|823564440|2007237709|1458777923
testStringComplex
0|0|0|2128236579|1624379149|1358580979|704877633|1580723810|101929267|563613512|1636807826|1954899097|1505795335|530511967|1404280278|197493099|1131570933|1817129560|1998097157|1264817709|1474833169|896544303|143542612|823378840|16531729|1441282327|1137522503|114807987|74243042|1784484492|1115438165|823564440|2007237709|1458777923
testGaussian
-0.836854
testShuffle
testShuffleSimple
2 1
testShuffleComplex
4 1 2 3
1 change: 0 additions & 1 deletion src/ves/TargetDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "tools/Keywords.h"

#include "GridProjWeights.h"
#include <iostream>

namespace PLMD {
namespace ves {
Expand Down

0 comments on commit a06c676

Please sign in to comment.