tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
compare_utils.hpp
Go to the documentation of this file.
1#ifndef TATAMI_COMPARE_UTILS_HPP
2#define TATAMI_COMPARE_UTILS_HPP
3
4#include <cmath>
5
12namespace tatami {
13
17enum class CompareOperation : char {
18 EQUAL,
19 GREATER_THAN,
20 LESS_THAN,
21 GREATER_THAN_OR_EQUAL,
22 LESS_THAN_OR_EQUAL,
23 NOT_EQUAL
24};
25
29template<CompareOperation op_, typename Value_>
31 if constexpr(op_ == CompareOperation::EQUAL) {
32 return val == scalar;
33 } else if constexpr(op_ == CompareOperation::GREATER_THAN) {
34 return val > scalar;
35 } else if constexpr(op_ == CompareOperation::LESS_THAN) {
36 return val < scalar;
37 } else if constexpr(op_ == CompareOperation::GREATER_THAN_OR_EQUAL) {
38 return val >= scalar;
39 } else if constexpr(op_ == CompareOperation::LESS_THAN_OR_EQUAL) {
40 return val <= scalar;
41 } else { // NOT EQUAL.
42 return val != scalar;
43 }
44}
52enum class SpecialCompareOperation : char {
53 ISNAN,
54 ISINF,
55 ISFINITE
56};
57
61template<SpecialCompareOperation op_, bool pass_, typename Value_>
63 if constexpr(op_ == SpecialCompareOperation::ISNAN) {
64 return pass_ == std::isnan(val);
65 } else if constexpr(op_ == SpecialCompareOperation::ISINF) {
66 return pass_ == std::isinf(val);
67 } else {
68 return pass_ == std::isfinite(val);
69 }
70}
75}
76
77#endif
Flexible representations for matrix data.
Definition Extractor.hpp:15
SpecialCompareOperation
Definition compare_utils.hpp:52
CompareOperation
Definition compare_utils.hpp:17
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35