Mackey  V3.3
A C++ library for computing RO(G) graded homology
SFINAE.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <type_traits>
5 
6 
7 namespace Eigen {
8  //forward declaration for SFINAE
9  template<typename>
10  class MatrixBase;
11 
12  template<typename>
13  class SparseMatrixBase;
14 
15  template<typename, int, typename>
16  class SparseMatrix;
17 }
18 
19 
20 namespace mackey {
21 
22  //forward declaration for SFINAE
23  template<int64_t, typename>
24  class Z_mod;
25 
26 
32  namespace SFINAE {
33 
34  //If the test functions are not public then Graph CRTP may fail leading to segfault
35 
37  constexpr std::false_type test_Dense(...);
38 
40  template<typename T>
41  constexpr std::true_type test_Dense(Eigen::MatrixBase<T>*);
42 
44  constexpr std::false_type test_Sparse(...);
45 
47  template <typename T>
48  constexpr std::true_type test_Sparse(Eigen::SparseMatrixBase<T>*);
49 
51  constexpr std::false_type test_SRM(...);
52 
54  template <typename T, typename S>
55  constexpr std::true_type test_SRM(Eigen::SparseMatrix<T,1,S>*);
56 
58  constexpr std::false_type test_finite_cyclic(...);
59 
61  template <int64_t N, typename T>
62  constexpr std::true_type test_finite_cyclic(Z_mod<N,T>);
63 
65  template<typename T>
66  constexpr std::false_type test_operator_evaluation_int_int(...);
67 
69  template<typename T>
70  constexpr decltype(std::declval<T>().operator()(std::declval<int>(), std::declval<int>()), std::true_type()) test_operator_evaluation_int_int(int);
71 
73  template<typename T>
74  using is_Dense = decltype(test_Dense(std::declval<T*>()));
75 
77  template<typename T>
78  using is_Sparse = decltype(test_Sparse(std::declval<T*>()));
79 
81  template<typename T>
82  using is_sparse_row_major = decltype(test_SRM(std::declval<T*>()));
83 
85  template<typename T>
86  using is_finite_cyclic = decltype(test_finite_cyclic(std::declval<T>()));
87 
89  template<typename T>
91 
92  };
93 
94 
95 }
The class of Z/N coefficients where N is prime.
Definition: Z_n.hpp:17
constexpr std::false_type test_finite_cyclic(...)
Detects if T=Z<N>
decltype(test_operator_evaluation_int_int< T >(0)) has_operator_evaluation_int_int
Detects if T has an operator()(int,int)
Definition: SFINAE.hpp:90
constexpr std::false_type test_Dense(...)
Detects if T is a dense matrix.
constexpr std::false_type test_SRM(...)
Detects if T is sparse row major matrix.
decltype(test_finite_cyclic(std::declval< T >())) is_finite_cyclic
Detects if T=Z<N>
Definition: SFINAE.hpp:86
decltype(test_Dense(std::declval< T * >())) is_Dense
Detects if T is a dense matrix.
Definition: SFINAE.hpp:74
decltype(test_SRM(std::declval< T * >())) is_sparse_row_major
Detects if T is sparse row major matrix.
Definition: SFINAE.hpp:82
constexpr std::false_type test_operator_evaluation_int_int(...)
Detects if T has an operator()(int,int)
constexpr std::false_type test_Sparse(...)
Detects if T is a sparse matrix.
decltype(test_Sparse(std::declval< T * >())) is_Sparse
Detects if T is a sparse matrix.
Definition: SFINAE.hpp:78
Everything in this library is under this namespace.
Definition: Box.hpp:9