Skip to content
Snippets Groups Projects
Commit af1fa3d1 authored by Sander, Oliver's avatar Sander, Oliver
Browse files

[cleanup] More container types can be constructed from initializer lists

parent c47b4d03
No related branches found
No related tags found
No related merge requests found
...@@ -32,13 +32,12 @@ class ValueFactory<RealTuple<double,1> > ...@@ -32,13 +32,12 @@ class ValueFactory<RealTuple<double,1> >
public: public:
static void get(std::vector<RealTuple<double,1> >& values) { static void get(std::vector<RealTuple<double,1> >& values) {
int nTestPoints = 5; std::vector<double> testPoints = {-3, -1, 0, 2, 4};
double testPoints[5] = {-3, -1, 0, 2, 4};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) for (size_t i=0; i<values.size(); i++)
values[i] = RealTuple<double,1>(testPoints[i]); values[i] = RealTuple<double,1>(testPoints[i]);
} }
...@@ -55,23 +54,16 @@ class ValueFactory<RealTuple<double,3> > ...@@ -55,23 +54,16 @@ class ValueFactory<RealTuple<double,3> >
public: public:
static void get(std::vector<RealTuple<double,3> >& values) { static void get(std::vector<RealTuple<double,3> >& values) {
int nTestPoints = 10; std::vector<Dune::FieldVector<double,3> > testPoints = {{1,0,0}, {0,1,0}, {-0.838114,0.356751,-0.412667},
double testPoints[10][3] = {{1,0,0}, {0,1,0}, {-0.838114,0.356751,-0.412667},
{-0.490946,-0.306456,0.81551},{-0.944506,0.123687,-0.304319}, {-0.490946,-0.306456,0.81551},{-0.944506,0.123687,-0.304319},
{-0.6,0.1,-0.2},{0.45,0.12,0.517}, {-0.6,0.1,-0.2},{0.45,0.12,0.517},
{-0.1,0.3,-0.1},{-0.444506,0.123687,0.104319},{-0.7,-0.123687,-0.304319}}; {-0.1,0.3,-0.1},{-0.444506,0.123687,0.104319},{-0.7,-0.123687,-0.304319}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (size_t i=0; i<values.size(); i++)
values[i] = RealTuple<double,3>(testPoints[i]);
Dune::FieldVector<double,3> w;
for (int j=0; j<3; j++)
w[j] = testPoints[i][j];
values[i] = RealTuple<double,3>(w);
}
} }
...@@ -87,18 +79,13 @@ class ValueFactory<UnitVector<double,2> > ...@@ -87,18 +79,13 @@ class ValueFactory<UnitVector<double,2> >
public: public:
static void get(std::vector<UnitVector<double,2> >& values) { static void get(std::vector<UnitVector<double,2> >& values) {
int nTestPoints = 10; std::vector<std::array<double,2> > testPoints = {{1,0}, {0.5,0.5}, {0,1}, {-0.5,0.5}, {-1,0}, {-0.5,-0.5}, {0,-1}, {0.5,-0.5}, {0.1,1}, {1,.1}};
double testPoints[10][2] = {{1,0}, {0.5,0.5}, {0,1}, {-0.5,0.5}, {-1,0}, {-0.5,-0.5}, {0,-1}, {0.5,-0.5}, {0.1,1}, {1,.1}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (size_t i=0; i<values.size(); i++)
values[i] = UnitVector<double,2>(testPoints[i]);
Dune::array<double,2> w = {{testPoints[i][0], testPoints[i][1]}};
values[i] = UnitVector<double,2>(w);
}
} }
...@@ -115,21 +102,16 @@ class ValueFactory<UnitVector<double,3> > ...@@ -115,21 +102,16 @@ class ValueFactory<UnitVector<double,3> >
public: public:
static void get(std::vector<UnitVector<double,3> >& values) { static void get(std::vector<UnitVector<double,3> >& values) {
int nTestPoints = 10; std::vector<std::array<double,3> > testPoints = {{1,0,0}, {0,1,0}, {-0.838114,0.356751,-0.412667},
double testPoints[10][3] = {{1,0,0}, {0,1,0}, {-0.838114,0.356751,-0.412667},
{-0.490946,-0.306456,0.81551},{-0.944506,0.123687,-0.304319}, {-0.490946,-0.306456,0.81551},{-0.944506,0.123687,-0.304319},
{-0.6,0.1,-0.2},{0.45,0.12,0.517}, {-0.6,0.1,-0.2},{0.45,0.12,0.517},
{-0.1,0.3,-0.1},{-0.444506,0.123687,0.104319},{-0.7,-0.123687,-0.304319}}; {-0.1,0.3,-0.1},{-0.444506,0.123687,0.104319},{-0.7,-0.123687,-0.304319}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (size_t i=0; i<values.size(); i++)
values[i] = UnitVector<double,3>(testPoints[i]);
Dune::array<double,3> w = {{testPoints[i][0], testPoints[i][1], testPoints[i][2]}};
values[i] = UnitVector<double,3>(w);
}
} }
...@@ -146,22 +128,17 @@ class ValueFactory<UnitVector<double,4> > ...@@ -146,22 +128,17 @@ class ValueFactory<UnitVector<double,4> >
public: public:
static void get(std::vector<UnitVector<double,4> >& values) { static void get(std::vector<UnitVector<double,4> >& values) {
int nTestPoints = 10; std::vector<std::array<double,4> > testPoints = {{1,0,0,0}, {0,1,0,0}, {-0.838114,0.356751,-0.412667,0.5},
double testPoints[10][4] = {{1,0,0,0}, {0,1,0,0}, {-0.838114,0.356751,-0.412667,0.5},
{-0.490946,-0.306456,0.81551,0.23},{-0.944506,0.123687,-0.304319,-0.7}, {-0.490946,-0.306456,0.81551,0.23},{-0.944506,0.123687,-0.304319,-0.7},
{-0.6,0.1,-0.2,0.8},{0.45,0.12,0.517,0}, {-0.6,0.1,-0.2,0.8},{0.45,0.12,0.517,0},
{-0.1,0.3,-0.1,0.73},{-0.444506,0.123687,0.104319,-0.23},{-0.7,-0.123687,-0.304319,0.72}}; {-0.1,0.3,-0.1,0.73},{-0.444506,0.123687,0.104319,-0.23},{-0.7,-0.123687,-0.304319,0.72}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (size_t i=0; i<values.size(); i++)
values[i] = UnitVector<double,4>(testPoints[i]);
Dune::array<double,4> w = {{testPoints[i][0], testPoints[i][1], testPoints[i][2], testPoints[i][3]}};
values[i] = UnitVector<double,4>(w);
}
} }
...@@ -178,22 +155,17 @@ class ValueFactory<Rotation<double,3> > ...@@ -178,22 +155,17 @@ class ValueFactory<Rotation<double,3> >
public: public:
static void get(std::vector<Rotation<double,3> >& values) { static void get(std::vector<Rotation<double,3> >& values) {
int nTestPoints = 10; std::vector<std::array<double,4> > testPoints = {{1,0,0,0}, {0,1,0,0}, {-0.838114,0.356751,-0.412667,0.5},
double testPoints[10][4] = {{1,0,0,0}, {0,1,0,0}, {-0.838114,0.356751,-0.412667,0.5},
{-0.490946,-0.306456,0.81551,0.23},{-0.944506,0.123687,-0.304319,-0.7}, {-0.490946,-0.306456,0.81551,0.23},{-0.944506,0.123687,-0.304319,-0.7},
{-0.6,0.1,-0.2,0.8},{0.45,0.12,0.517,0}, {-0.6,0.1,-0.2,0.8},{0.45,0.12,0.517,0},
{-0.1,0.3,-0.1,0.73},{-0.444506,0.123687,0.104319,-0.23},{-0.7,-0.123687,-0.304319,0.72}}; {-0.1,0.3,-0.1,0.73},{-0.444506,0.123687,0.104319,-0.23},{-0.7,-0.123687,-0.304319,0.72}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (std::size_t i=0; i<values.size(); i++)
values[i] = Rotation<double,3>(testPoints[i]);
Dune::array<double,4> w = {{testPoints[i][0], testPoints[i][1], testPoints[i][2], testPoints[i][3]}};
values[i] = Rotation<double,3>(w);
}
} }
...@@ -314,23 +286,16 @@ class ValueFactory<HyperbolicHalfspacePoint<double,2> > ...@@ -314,23 +286,16 @@ class ValueFactory<HyperbolicHalfspacePoint<double,2> >
public: public:
static void get(std::vector<HyperbolicHalfspacePoint<double,2> >& values) { static void get(std::vector<HyperbolicHalfspacePoint<double,2> >& values) {
int nTestPoints = 10; std::vector<Dune::FieldVector<double,2> > testPoints = {{0,2}, {0,1}, {0,0.5},
double testPoints[10][2] = {{0,2}, {0,1}, {0,0.5},
{-0.490946,0.81551},{-0.944506,0.304319}, {-0.490946,0.81551},{-0.944506,0.304319},
{-0.6,0.2},{0.45,0.517}, {-0.6,0.2},{0.45,0.517},
{-0.1,0.1},{-0.444506,0.104319},{-0.7,0.304319}}; {-0.1,0.1},{-0.444506,0.104319},{-0.7,0.304319}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (size_t i=0; i<values.size(); i++)
values[i] = HyperbolicHalfspacePoint<double,2>(testPoints[i]);
Dune::FieldVector<double,2> w;
for (int j=0; j<2; j++)
w[j] = testPoints[i][j];
values[i] = HyperbolicHalfspacePoint<double,2>(w);
}
} }
...@@ -346,23 +311,16 @@ class ValueFactory<HyperbolicHalfspacePoint<double,3> > ...@@ -346,23 +311,16 @@ class ValueFactory<HyperbolicHalfspacePoint<double,3> >
public: public:
static void get(std::vector<HyperbolicHalfspacePoint<double,3> >& values) { static void get(std::vector<HyperbolicHalfspacePoint<double,3> >& values) {
int nTestPoints = 10; std::vector<Dune::FieldVector<double,3> > testPoints = {{1,0,0.01}, {0,1,0.01}, {-0.838114,0.356751,0.412667},
double testPoints[10][3] = {{1,0,0.01}, {0,1,0.01}, {-0.838114,0.356751,0.412667},
{-0.490946,-0.306456,0.81551},{-0.944506,0.123687,0.304319}, {-0.490946,-0.306456,0.81551},{-0.944506,0.123687,0.304319},
{-0.6,0.1,0.2},{0.45,0.12,0.517}, {-0.6,0.1,0.2},{0.45,0.12,0.517},
{-0.1,0.3,0.1},{-0.444506,0.123687,0.104319},{-0.7,-0.123687,0.304319}}; {-0.1,0.3,0.1},{-0.444506,0.123687,0.104319},{-0.7,-0.123687,0.304319}};
values.resize(nTestPoints); values.resize(testPoints.size());
// Set up elements of S^1 // Set up elements of S^1
for (int i=0; i<nTestPoints; i++) { for (size_t i=0; i<values.size(); i++)
values[i] = HyperbolicHalfspacePoint<double,3>(testPoints[i]);
Dune::FieldVector<double,3> w;
for (int j=0; j<3; j++)
w[j] = testPoints[i][j];
values[i] = HyperbolicHalfspacePoint<double,3>(w);
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment