diff --git a/include/fcarouge/utility.hpp b/include/fcarouge/utility.hpp index 256d8e209..99e15dcae 100644 --- a/include/fcarouge/utility.hpp +++ b/include/fcarouge/utility.hpp @@ -244,12 +244,12 @@ inline constexpr auto first_v{internal::first_v}; //! //! @details User-defined. template -inline constexpr Type identity{internal::not_implemented{ +inline constexpr void identity{internal::not_implemented{ "Implement the linear algebra identity matrix for this type."}}; //! @brief The singleton identity matrix specialization. template -inline constexpr Arithmetic identity{1}; +inline constexpr auto identity{Arithmetic{1}}; template requires requires { Type::Identity(); } @@ -263,20 +263,20 @@ inline auto identity{Type::identity()}; //! //! @details User-defined. template -inline constexpr Type zero{internal::not_implemented{ +inline constexpr void zero{internal::not_implemented{ "Implement the linear algebra zero matrix for this type."}}; //! @brief The singleton zero matrix specialization. template -inline constexpr Arithmetic zero{0}; +inline constexpr auto zero{Arithmetic{0}}; template requires requires { Type::Zero(); } -inline auto zero{Type::Zero()}; +inline auto zero{Type{Type::Zero()}}; template requires requires { Type::zero(); } -inline auto zero{Type::zero()}; +inline auto zero{Type{Type::zero()}}; //! @} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8cc19ded5..1770f89ec 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -76,8 +76,8 @@ test(NAME "linalg_multiplication_rxc" BACKENDS "eigen" "naive") test(NAME "linalg_multiplication_sxc" BACKENDS "eigen" "naive") test(NAME "linalg_operator_bracket" BACKENDS "eigen" "naive") test(NAME "linalg_operator_equality" BACKENDS "eigen" "naive") -test(NAME "linalg_zero_default" BACKENDS "eigen" "naive") test(NAME "linalg_zero" BACKENDS "eigen" "naive") test(NAME "printer_1x1x0") test(NAME "printer_2x3x4" BACKENDS "eigen") test(NAME "units_kf_1x1x0_building_height") +test(NAME "utility_zero_default") diff --git a/test/kalman_f_5x4x3.cpp b/test/kalman_f_5x4x3.cpp index a6131b258..d6e807d83 100644 --- a/test/kalman_f_5x4x3.cpp +++ b/test/kalman_f_5x4x3.cpp @@ -51,7 +51,6 @@ template using matrix = matrix; [[maybe_unused]] auto test{[] { const auto i5x5{identity>}; const auto z5x5{zero>}; - const vector<3> z3{zero>}; kalman filter{state{vector<5>{0., 0., 0., 0., 0.}}, output>, input>, update_types, prediction_types}; diff --git a/test/kalman_format_1x4x3.cpp b/test/kalman_format_1x4x3.cpp index a32e68aa1..42c5bc3ea 100644 --- a/test/kalman_format_1x4x3.cpp +++ b/test/kalman_format_1x4x3.cpp @@ -42,6 +42,8 @@ For more information, please refer to */ #include #include +#include ////////////////////////////////////////////////////////////// + namespace fcarouge::test { namespace { template using vector = column_vector; @@ -51,6 +53,8 @@ template using vector = column_vector; [[maybe_unused]] auto test{[] { kalman filter{state{vector<1>{0.}}, output>, input>}; + std::println("{}", filter); ///////////////////////////////////////////////// + assert(std::format("{}", filter) == R"({"f": 1,)" R"( "g": [1, 0, 0],)" diff --git a/test/kalman_format_5x4x3.cpp b/test/kalman_format_5x4x3.cpp index f6992646d..c5ed8bdaf 100644 --- a/test/kalman_format_5x4x3.cpp +++ b/test/kalman_format_5x4x3.cpp @@ -42,6 +42,8 @@ For more information, please refer to */ #include #include +#include ///////////////////////////////////////////////////////////// + namespace fcarouge::test { namespace { template using vector = column_vector; @@ -52,6 +54,8 @@ template using vector = column_vector; kalman filter{state{vector<5>{0., 0., 0., 0., 0.}}, output>, input>}; + std::println("{}", filter); ///////////////////////////////////////////////// + assert( std::format("{}", filter) == R"({"f": [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],)" diff --git a/test/linalg_multiplication_sxc.cpp b/test/linalg_multiplication_sxc.cpp index b964f8e01..cc0aa70c8 100644 --- a/test/linalg_multiplication_sxc.cpp +++ b/test/linalg_multiplication_sxc.cpp @@ -44,9 +44,9 @@ namespace fcarouge::test { namespace { //! @test Verifies the assignment operator. [[maybe_unused]] auto test{[] { - matrix a{{1.0, 2.0}, {3.0, 4.0}}; - matrix b{3.0, 4.0}; - auto r{a * b}; + const matrix a{{1.0, 2.0}, {3.0, 4.0}}; + const matrix b{3.0, 4.0}; + const matrix r{a * b}; assert(r(0, 0) == 11.0); assert(r(1, 0) == 25.0); diff --git a/test/linalg_operator_equality.cpp b/test/linalg_operator_equality.cpp index c35019a4a..df254a480 100644 --- a/test/linalg_operator_equality.cpp +++ b/test/linalg_operator_equality.cpp @@ -44,9 +44,9 @@ namespace fcarouge::test { namespace { //! @test Verifies the equality operator. [[maybe_unused]] auto test{[] { - auto m{zero>}; - auto i{identity>}; - auto z{zero>}; + const matrix m{zero>}; + const matrix i{identity>}; + const matrix z{zero>}; assert(m == z); assert(m != i); diff --git a/test/linalg_zero.cpp b/test/linalg_zero.cpp index a59509a50..a735e5545 100644 --- a/test/linalg_zero.cpp +++ b/test/linalg_zero.cpp @@ -44,7 +44,7 @@ namespace fcarouge::test { namespace { //! @test Verifies the zero matrices values are null. [[maybe_unused]] auto test{[] { - auto z{zero>}; + const matrix z{zero>}; assert(z(0, 0) == 0.0); assert(z(0, 1) == 0.0); diff --git a/test/linalg_zero_default.cpp b/test/utility_zero_default.cpp similarity index 92% rename from test/linalg_zero_default.cpp rename to test/utility_zero_default.cpp index abf8fcfd7..eaa3a0182 100644 --- a/test/linalg_zero_default.cpp +++ b/test/utility_zero_default.cpp @@ -36,7 +36,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ -#include "fcarouge/linalg.hpp" +#include "fcarouge/utility.hpp" #include #include @@ -45,10 +45,11 @@ namespace fcarouge::test { namespace { //! @test Verifies the 1x1 zero matrix deduced default value is a null double. [[maybe_unused]] auto test{[] { - auto z{zero<>}; + const double z{zero<>}; + const auto a{zero<>}; assert(z == 0.0); - static_assert(std::is_same_v); + static_assert(std::is_same_v); return 0; }()};