Skip to content

Commit

Permalink
[test] add 1x1 matrix type equality
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed Apr 18, 2024
1 parent e6fba18 commit 12a2abc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
6 changes: 6 additions & 0 deletions linalg/eigen/fcarouge/linalg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ inline const auto identity_v<Matrix>{Matrix::Identity()};
//! @brief The zero matrix Eigen specialization.
template <eigen Matrix> inline const auto zero_v<Matrix>{Matrix::Zero()};
//! @}

template <typename Type>
[[nodiscard]] inline bool operator==(const matrix<Type, 1, 1> &lhs,
const Type &rhs) {
return lhs(0, 0) == rhs;
}
} // namespace fcarouge

#endif // FCAROUGE_LINALG_HPP
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ foreach(BACKEND IN ITEMS "eigen" "lazy" "naive")
"linalg_multiplication_rxc.cpp"
"linalg_multiplication_sxc.cpp"
"linalg_operator_bracket.cpp"
"linalg_operator_equality_1x1.cpp"
"linalg_operator_equality.cpp"
"linalg_zero_default.cpp"
"linalg_zero.cpp")
Expand Down
56 changes: 56 additions & 0 deletions test/linalg_operator_equality_1x1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* __ _ __ __ _ _
| |/ / /\ | | | \/ | /\ | \ | |
| ' / / \ | | | \ / | / \ | \| |
| < / /\ \ | | | |\/| | / /\ \ | . ` |
| . \ / ____ \| |____| | | |/ ____ \| |\ |
|_|\_\/_/ \_\______|_| |_/_/ \_\_| \_|
Kalman Filter
Version 0.2.0
https://github.com/FrancoisCarouge/Kalman
SPDX-License-Identifier: Unlicense
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org> */

#include "fcarouge/linalg.hpp"

#include <cassert>

namespace fcarouge::test {
namespace {
//! @test Verifies the 1x1 matrix equates to its element type.
//!
//! @todo Rewrite this test as a property-based test.
[[maybe_unused]] auto test{[] {
matrix<double, 1, 1> m{42.0};

assert(m == 42.0);

return 0;
}()};
} // namespace
} // namespace fcarouge::test

0 comments on commit 12a2abc

Please sign in to comment.