RFFGen
 All Classes Namespaces Files Functions Typedefs Enumerations Groups
extractRowsAndCols.hh
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the C++-library RFFGen. */
4 /* Copyright 2015 Lars Lubkoll */
5 /* */
6 /* RFFGen is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* RFFGen is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with RFFGen. If not, see <http://www.gnu.org/licenses/>. */
18 /* */
19 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20 
21 #ifndef RFFGEN_LINEAR_ALGEBRA_EXTRACTROWSANDCOLS_HH
22 #define RFFGEN_LINEAR_ALGEBRA_EXTRACTROWSANDCOLS_HH
23 
24 #include <type_traits>
25 
26 namespace RFFGen
27 {
31  namespace Concepts { template <class> struct MatrixConceptCheck; }
36  namespace LinearAlgebra
37  {
39  template < class Matrix , class = Concepts::MatrixConceptCheck<Matrix> > struct NumberOfRows : std::integral_constant<int,-1> {};
40 
42  template < class Matrix , class = Concepts::MatrixConceptCheck<Matrix> > struct NumberOfColumns : std::integral_constant<int,-1> {};
43 
45 
46 
48  template < template <class,int,int...> class Matrix, class T, int n, class MatrixConceptCheck, int... m>
49  struct NumberOfRows< Matrix<T,n,m...> , MatrixConceptCheck > : std::integral_constant<int,n> {};
50 
52  template < template <class,unsigned,unsigned> class Matrix, class T, unsigned n, unsigned m, class MatrixConceptCheck>
53  struct NumberOfRows< Matrix<T,n,m> , MatrixConceptCheck > : std::integral_constant<unsigned,n> {};
54 
56  template < template <int,int> class Matrix, int n, int m, class MatrixConceptCheck>
57  struct NumberOfRows< Matrix<n,m> , MatrixConceptCheck > : std::integral_constant<int,n> {};
58 
60  template < template <unsigned,unsigned> class Matrix, unsigned n, unsigned m, class MatrixConceptCheck>
61  struct NumberOfRows< Matrix<n,m> , MatrixConceptCheck > : std::integral_constant<unsigned,n> {};
62 
63 
65  template < template <class,int> class Vector, class T, int n, class MatrixConceptCheck>
66  struct NumberOfRows< Vector<T,n> , MatrixConceptCheck > : std::integral_constant<int,n> {};
67 
69  template < template <class,unsigned> class Vector, class T, unsigned n, class MatrixConceptCheck>
70  struct NumberOfRows< Vector<T,n> , MatrixConceptCheck > : std::integral_constant<unsigned,n> {};
71 
73  template < template <int> class Vector, int n, class MatrixConceptCheck>
74  struct NumberOfRows< Vector<n> , MatrixConceptCheck > : std::integral_constant<int,n> {};
75 
77  template < template <unsigned> class Vector, unsigned n, class MatrixConceptCheck>
78  struct NumberOfRows< Vector<n> , MatrixConceptCheck > : std::integral_constant<unsigned,n> {};
79 
80 
82  template < template <class,int,int> class Matrix, class T, int n, int m, class MatrixConceptCheck>
83  struct NumberOfColumns< Matrix<T,n,m> , MatrixConceptCheck > : std::integral_constant<int,m> {};
84 
86  template < template <class,int,int,int...> class Matrix, class T, int n, int m, class MatrixConceptCheck, int... other>
87  struct NumberOfColumns< Matrix<T,n,m,other...> , MatrixConceptCheck > : std::integral_constant<int,m> {};
88 
90  template < template <class,unsigned,unsigned> class Matrix, class T, unsigned n, unsigned m, class MatrixConceptCheck>
91  struct NumberOfColumns< Matrix<T,n,m> , MatrixConceptCheck > : std::integral_constant<unsigned,m> {};
92 
93 
95  template < template <int,int> class Matrix, int n, int m, class MatrixConceptCheck>
96  struct NumberOfColumns< Matrix<n,m> , MatrixConceptCheck > : std::integral_constant<int,m> {};
97 
99  template < template <unsigned,unsigned> class Matrix, unsigned n, unsigned m, class MatrixConceptCheck>
100  struct NumberOfColumns< Matrix<n,m> , MatrixConceptCheck > : std::integral_constant<unsigned,m> {};
101 
102 
104  template <class Matrix>
105  constexpr int numberOfRows()
106  {
107  return NumberOfRows<Matrix>::value;
108  }
109 
111  template <class Matrix>
112  constexpr int numberOfColumns()
113  {
114  return NumberOfColumns<Matrix>::value;
115  }
116  }
117 }
118 
119 #endif // RFFGEN_LINEAR_ALGEBRA_EXTRACTROWSANDCOLS_HH
Specialize this for your matrix class. Number of columns must be provided by a static member variable...
Definition: extractRowsAndCols.hh:42
Specialize this for your matrix class. Number of rows must be provided by a static member variable ca...
Definition: extractRowsAndCols.hh:39