Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 67bfe22

Browse files
committed
Assertions updated #3
1 parent 6d1bf42 commit 67bfe22

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

include/nil/algebra/matrix/math.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ namespace nil {
151151
template <typename T, std::size_t M, std::size_t N>
152152
constexpr std::tuple<matrix<T, M, N>, std::size_t, T>
153153
gauss_jordan_impl(matrix<T, M, N> m, T tolerance) {
154-
COTILA_DETAIL_ASSERT_FLOATING_POINT(T)
155-
COTILA_DETAIL_ASSERT_REAL(T)
154+
CRYPTO3_DETAIL_ASSERT_FLOATING_POINT(T)
155+
CRYPTO3_DETAIL_ASSERT_REAL(T)
156156

157157
// Define function for determining if an element is negligible
158158
auto negligible = [&tolerance](const T &v) { return abs(v) < tolerance; };

include/nil/algebra/matrix/matrix.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <nil/algebra/vector/utility.hpp>
1818
#include <nil/algebra/vector/vector.hpp>
1919

20-
#include <nil/algebra/detail/assert.hpp>
21-
2220
namespace nil {
2321
namespace algebra {
2422

@@ -34,7 +32,7 @@ namespace nil {
3432
template <typename T, std::size_t N, std::size_t M> struct matrix {
3533
static_assert(N != 0 && M != 0,
3634
"matrix must have have positive dimensions");
37-
COTILA_DETAIL_ASSERT_ARITHMETIC(T)
35+
CRYPTO3_DETAIL_ASSERT_ARITHMETIC(T)
3836

3937
using value_type = T;
4038
using size_type = std::size_t;

include/nil/algebra/matrix/utility.hpp

+28
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,34 @@
1717

1818
namespace nil {
1919
namespace algebra {
20+
namespace detail {
21+
22+
#define CRYPTO3_DETAIL_ASSERT_FLOATING_POINT(T) \
23+
static_assert(std::is_floating_point<typename cotila::detail::remove_complex<T>::type>::value, \
24+
"argument must be a (real or complex) floating point type");
25+
26+
#define CRYPTO3_DETAIL_ASSERT_INTEGRAL(T) \
27+
static_assert(std::is_integral<T>::value, "argument must be a real integral type");
28+
29+
#define CRYPTO3_DETAIL_ASSERT_VALID_COMPLEX(T) \
30+
static_assert(!cotila::detail::is_complex<T>::value || \
31+
std::is_floating_point<typename cotila::detail::remove_complex<T>::type>::value, \
32+
"invalid complex type argument (valid types are " \
33+
"complex<float>, complex<double>, and complex<long double>)");
34+
35+
#define CRYPTO3_DETAIL_ASSERT_ARITHMETIC(T) \
36+
CRYPTO3_DETAIL_ASSERT_VALID_COMPLEX(T) \
37+
static_assert(std::is_arithmetic<typename cotila::detail::remove_complex<T>::type>::value, \
38+
"argument must be a (real or complex) arithmetic type");
39+
40+
#define CRYPTO3_DETAIL_ASSERT_REAL(T) \
41+
static_assert(std::is_arithmetic<T>::value, "argument must be a real arithmetic type");
42+
43+
#define CRYPTO3_DETAIL_ASSERT_COMPLEX(T) \
44+
CRYPTO3_DETAIL_ASSERT_VALID_COMPLEX(T) \
45+
static_assert(cotila::detail::is_complex<T>::value, "argument must be a complex type");
46+
}
47+
2048

2149
/** \addtogroup matrix
2250
* @{

include/nil/algebra/vector/vector.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace nil {
2929
*/
3030
template <typename T, std::size_t N> struct vector {
3131
static_assert(N != 0, "vector must contain at least one element");
32-
COTILA_DETAIL_ASSERT_ARITHMETIC(T)
32+
CRYPTO3_DETAIL_ASSERT_ARITHMETIC(T)
3333

3434
using value_type = T;
3535
using size_type = std::size_t;

0 commit comments

Comments
 (0)