Skip to content

Commit adb7749

Browse files
[linalg] Cleanup
1 parent dc4da23 commit adb7749

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

include/etl/_linalg/concepts.hpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -78,37 +78,35 @@ template <typename T>
7878
concept has_adl_imag = linalg_adl_checks::has_imag<T>;
7979

8080
inline constexpr auto abs_if_needed = []<typename T>(T const& val) {
81-
if constexpr (has_adl_abs<T>) {
82-
using etl::abs;
81+
if constexpr (unsigned_integral<T>) {
82+
return val;
83+
} else if constexpr (is_arithmetic_v<T>) {
84+
return etl::abs(val);
85+
} else if constexpr (has_adl_abs<T>) {
8386
return abs(val);
8487
} else {
85-
return val;
88+
static_assert(always_false<T>);
8689
}
8790
};
8891

8992
inline constexpr auto conj_if_needed = []<typename T>(T const& val) {
90-
if constexpr (has_adl_conj<T>) {
91-
using etl::conj;
93+
if constexpr (not is_arithmetic_v<T> and has_adl_conj<T>) {
9294
return conj(val);
9395
} else {
9496
return val;
9597
}
9698
};
9799

98100
inline constexpr auto real_if_needed = []<typename T>(T const& val) {
99-
if constexpr (has_adl_real<T>) {
100-
using etl::real;
101+
if constexpr (not is_arithmetic_v<T> and has_adl_real<T>) {
101102
return real(val);
102103
} else {
103104
return val;
104105
}
105106
};
106107

107108
inline constexpr auto imag_if_needed = []<typename T>(T const& val) {
108-
if constexpr (is_arithmetic_v<T>) {
109-
return val;
110-
} else if constexpr (has_adl_imag<T>) {
111-
using etl::imag;
109+
if constexpr (not is_arithmetic_v<T> and has_adl_imag<T>) {
112110
return imag(val);
113111
} else {
114112
return T{};

tests/linalg/blas1_vector_idx_abs_max.t.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ template <typename IndexType>
8484
CHECK(test_linalg_vector_idx_abs_max_real<unsigned long, IndexType>());
8585
CHECK(test_linalg_vector_idx_abs_max_real<unsigned long long, IndexType>());
8686

87-
// CHECK(test_linalg_vector_idx_abs_max_real<signed char, IndexType>());
88-
// CHECK(test_linalg_vector_idx_abs_max_real<signed short, IndexType>());
87+
CHECK(test_linalg_vector_idx_abs_max_real<signed char, IndexType>());
88+
CHECK(test_linalg_vector_idx_abs_max_real<signed short, IndexType>());
8989
CHECK(test_linalg_vector_idx_abs_max_real<signed int, IndexType>());
9090
CHECK(test_linalg_vector_idx_abs_max_real<signed long, IndexType>());
9191
CHECK(test_linalg_vector_idx_abs_max_real<signed long long, IndexType>());

0 commit comments

Comments
 (0)