18 # include <catch2/catch_all.hpp>
20 TEST_CASE(
"Internal consistency checks and example use cases for MatrixMath.h",
"[MatrixMath]") {
24 std::vector<double> cHeat;
26 cHeat.push_back(+1.1562261074E+03);
27 cHeat.push_back(+2.0994549103E+00);
28 cHeat.push_back(+7.7175381057E-07);
29 cHeat.push_back(-3.7008444051E-20);
31 std::vector<std::vector<double>> cHeat2D;
32 cHeat2D.push_back(cHeat);
33 cHeat2D.push_back(cHeat);
35 SECTION(
"Pretty printing tests") {
37 Eigen::MatrixXd matrix = Eigen::MatrixXd::Random(4, 1);
39 if (PRINT) std::cout << std::endl;
42 if (PRINT) std::cout << tmpStr << std::endl;
44 if (PRINT) std::cout << tmpStr << std::endl;
46 if (PRINT) std::cout << tmpStr << std::endl;
49 if (PRINT) std::cout << tmpStr << std::endl;
51 if (PRINT) std::cout << tmpStr << std::endl;
53 if (PRINT) std::cout << tmpStr << std::endl;
55 if (PRINT) std::cout << tmpStr << std::endl;
58 SECTION(
"Matrix modifications") {
73 SECTION(
"std::vector to Eigen::Matrix and back") {
74 std::vector<std::vector<double>> vec2D(cHeat2D);
76 for (
size_t i = 0; i < static_cast<size_t>(matrix.cols()); ++i) {
77 for (
size_t j = 0; j < static_cast<size_t>(matrix.rows()); ++j) {
78 CHECK(std::abs(matrix(j, i) - vec2D[j][i]) <= 1e-10);
82 for (
size_t i = 0; i < static_cast<size_t>(matrix.cols()); ++i) {
83 for (
size_t j = 0; j < static_cast<size_t>(matrix.rows()); ++j) {
84 CHECK(std::abs(matrix(j, i) - vec2D[j][i]) <= 1e-10);
87 std::vector<double> vec1D(cHeat);
89 for (
size_t i = 0; i < static_cast<size_t>(matrix.cols()); ++i) {
90 for (
size_t j = 0; j < static_cast<size_t>(matrix.rows()); ++j) {
91 CHECK(std::abs(matrix(j, i) - vec1D[j]) <= 1e-10);
95 for (
size_t i = 0; i < static_cast<size_t>(matrix.cols()); ++i) {
96 for (
size_t j = 0; j < static_cast<size_t>(matrix.rows()); ++j) {
97 CHECK(std::abs(matrix(j, i) - vec1D[j]) <= 1e-10);