5#define BOOST_TEST_DYN_LINK
7#include <boost/test/unit_test.hpp>
8#include <DCPSE/MonomialBasis.hpp>
9#include <DCPSE/VandermondeRowBuilder.hpp>
10#include <DCPSE/Vandermonde.hpp>
11#include "../../openfpm_numerics/src/DMatrix/EMatrix.hpp"
13BOOST_AUTO_TEST_SUITE(Vandermonde_tests)
18 BOOST_AUTO_TEST_CASE(VandermondeRowBuilder_AllOnes_test)
21 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> row(1, mb.size());
25 vrb.buildRow(row, 0, x, eps);
27 bool isRowAllOnes =
true;
28 for (
int i = 0; i < mb.size(); ++i)
30 isRowAllOnes = isRowAllOnes && (row(0, i) == 1);
32 BOOST_REQUIRE(isRowAllOnes);
35 BOOST_AUTO_TEST_CASE(VandermondeRowBuilder_OneZero_test)
38 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> row(1, mb.size());
42 vrb.buildRow(row, 0, x, eps);
44 bool areValuesOk =
true;
45 for (
int i = 0; i < mb.size(); ++i)
47 bool isThereY = mb.getElement(i).getExponent(1) > 0;
48 bool curCheck = (row(0, i) == !isThereY);
49 areValuesOk = areValuesOk && curCheck;
51 BOOST_REQUIRE(areValuesOk);
54 BOOST_AUTO_TEST_CASE(VandermondeRowBuilder_ZeroOne_test)
57 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> row(1, mb.size());
61 vrb.buildRow(row, 0, x, eps);
63 bool areValuesOk =
true;
64 for (
int i = 0; i < mb.size(); ++i)
66 bool isThereX = mb.getElement(i).getExponent(0) > 0;
67 bool curCheck = (row(0, i) == !isThereX);
68 areValuesOk = areValuesOk && curCheck;
70 BOOST_REQUIRE(areValuesOk);
73 BOOST_AUTO_TEST_CASE(Vandermonde_KnownValues_test)
78 std::vector<Point<2, double>> neighbours;
79 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> V(mb.size(), mb.size());
80 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> ExpectedV(mb.size(), mb.size());
107 const std::vector<size_t> keys({1,2,3,4,5,6});
113 vandermonde.getMatrix(V);
117 ExpectedV(0, 1) = -0.3;
118 ExpectedV(0, 2) = 0.09;
119 ExpectedV(0, 3) = -0.3;
120 ExpectedV(0, 4) = +0.09;
121 ExpectedV(0, 5) = 0.09;
123 ExpectedV(1, 1) = +0.3;
124 ExpectedV(1, 2) = 0.09;
125 ExpectedV(1, 3) = +0.3;
126 ExpectedV(1, 4) = +0.09;
127 ExpectedV(1, 5) = 0.09;
129 ExpectedV(2, 1) = -0.3;
130 ExpectedV(2, 2) = 0.09;
131 ExpectedV(2, 3) = +0.3;
132 ExpectedV(2, 4) = -0.09;
133 ExpectedV(2, 5) = 0.09;
135 ExpectedV(3, 1) = +0.3;
136 ExpectedV(3, 2) = 0.09;
137 ExpectedV(3, 3) = -0.3;
138 ExpectedV(3, 4) = -0.09;
139 ExpectedV(3, 5) = 0.09;
143 ExpectedV(4, 3) = -0.3;
145 ExpectedV(4, 5) = 0.09;
149 ExpectedV(5, 3) = +0.3;
151 ExpectedV(5, 5) = 0.09;
154 for (
int i = 0; i < mb.size(); ++i)
157 for (
int j = 0; j < mb.size(); ++j)
160 BOOST_REQUIRE_CLOSE(V(i, j), ExpectedV(i, j), 1e-6);
165 BOOST_AUTO_TEST_CASE(Vandermonde_TranslatedSetup_test)
170 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> V(mb.size(), mb.size());
171 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> ExpectedV(mb.size(), mb.size());
199 const std::vector<size_t> keys({1,2,3,4,5,6});
205 vandermonde.getMatrix(V);
209 ExpectedV(0, 1) = -0.3;
210 ExpectedV(0, 2) = 0.09;
211 ExpectedV(0, 3) = -0.3;
212 ExpectedV(0, 4) = +0.09;
213 ExpectedV(0, 5) = 0.09;
215 ExpectedV(1, 1) = +0.3;
216 ExpectedV(1, 2) = 0.09;
217 ExpectedV(1, 3) = +0.3;
218 ExpectedV(1, 4) = +0.09;
219 ExpectedV(1, 5) = 0.09;
221 ExpectedV(2, 1) = -0.3;
222 ExpectedV(2, 2) = 0.09;
223 ExpectedV(2, 3) = +0.3;
224 ExpectedV(2, 4) = -0.09;
225 ExpectedV(2, 5) = 0.09;
227 ExpectedV(3, 1) = +0.3;
228 ExpectedV(3, 2) = 0.09;
229 ExpectedV(3, 3) = -0.3;
230 ExpectedV(3, 4) = -0.09;
231 ExpectedV(3, 5) = 0.09;
235 ExpectedV(4, 3) = -0.3;
237 ExpectedV(4, 5) = 0.09;
241 ExpectedV(5, 3) = +0.3;
243 ExpectedV(5, 5) = 0.09;
246 for (
int i = 0; i < mb.size(); ++i)
249 for (
int j = 0; j < mb.size(); ++j)
252 BOOST_REQUIRE_CLOSE(V(i, j), ExpectedV(i, j), 1e-6);
259BOOST_AUTO_TEST_SUITE_END()
This class implement the point shape in an N-dimensional space.
auto getLastPos() -> decltype(v_pos.template get< 0 >(0))
Get the position of the last element.
void add()
Add local particle.