5#define BOOST_TEST_DYN_LINK
7#include <boost/test/unit_test.hpp>
8#include <Space/Shape/Point.hpp>
9#include <DCPSE/MonomialBasis.hpp>
11BOOST_AUTO_TEST_SUITE(MonomialBasis_tests)
13 BOOST_AUTO_TEST_CASE(Monomial_3D_test)
18 BOOST_REQUIRE_EQUAL(mbe.order(), 6);
19 BOOST_REQUIRE_EQUAL(mbe.getExponent(0), 1);
20 BOOST_REQUIRE_EQUAL(mbe.getExponent(1), 2);
21 BOOST_REQUIRE_EQUAL(mbe.getExponent(2), 3);
25 BOOST_REQUIRE_EQUAL(mbe2.order(), 6);
26 BOOST_REQUIRE_EQUAL(mbe2.getExponent(0), 1);
27 BOOST_REQUIRE_EQUAL(mbe2.getExponent(1), 2);
28 BOOST_REQUIRE_EQUAL(mbe2.getExponent(2), 3);
33 BOOST_REQUIRE_EQUAL(mbe3.order(), 6);
34 BOOST_REQUIRE_EQUAL(mbe3.getExponent(0), 1);
35 BOOST_REQUIRE_EQUAL(mbe3.getExponent(1), 2);
36 BOOST_REQUIRE_EQUAL(mbe3.getExponent(2), 3);
40 BOOST_REQUIRE_EQUAL(mbe0.order(), 0);
41 BOOST_REQUIRE_EQUAL(mbe0.getExponent(0), 0);
42 BOOST_REQUIRE_EQUAL(mbe0.getExponent(1), 0);
43 BOOST_REQUIRE_EQUAL(mbe0.getExponent(2), 0);
46 mbe0.setExponent(0, 5);
47 mbe0.setExponent(1, 5);
48 mbe0.setExponent(2, 5);
49 BOOST_REQUIRE_EQUAL(mbe0.order(), 15);
50 BOOST_REQUIRE_EQUAL(mbe0.getExponent(0), 5);
51 BOOST_REQUIRE_EQUAL(mbe0.getExponent(1), 5);
52 BOOST_REQUIRE_EQUAL(mbe0.getExponent(2), 5);
55 BOOST_AUTO_TEST_CASE(Monomial_evaluate_test)
61 double expected = 5 * 3 * 2;
62 BOOST_REQUIRE_CLOSE(res, expected, 1e-6);
68 double expected = pow(2,5) * pow(2,3) * pow(2,2);
69 BOOST_REQUIRE_CLOSE(res, expected, 1e-6);
73 BOOST_AUTO_TEST_CASE(Monomial_derivative_test)
80 BOOST_REQUIRE_EQUAL(derivative, expected);
86 BOOST_REQUIRE_EQUAL(derivative, expected);
92 BOOST_REQUIRE_EQUAL(derivative, expected);
99 BOOST_REQUIRE_EQUAL(derivative, expected);
105 BOOST_REQUIRE_EQUAL(derivative, expected);
111 BOOST_REQUIRE_EQUAL(derivative, expected);
115 BOOST_AUTO_TEST_CASE(MonomialBasis_2D_test)
121 std::vector<Monomial<2>> control;
129 auto first = mb.getElements().begin();
130 auto last = mb.getElements().end();
131 int foundElements = 0;
132 for (
const auto &item : control)
134 auto pos = std::find(first, last, item);
135 foundElements += (pos != last);
137 BOOST_REQUIRE_EQUAL(foundElements, control.size());
145 std::vector<Monomial<2>> control;
157 BOOST_REQUIRE_EQUAL(mb.size(), control.size());
159 auto first = mb.getElements().begin();
160 auto last = mb.getElements().end();
161 int foundElements = 0;
162 for (
const auto &item : control)
164 auto pos = std::find(first, last, item);
165 foundElements += (pos != last);
167 BOOST_REQUIRE_EQUAL(foundElements, control.size());
171BOOST_AUTO_TEST_SUITE_END()
This class implement the point shape in an N-dimensional space.