RFFGen
 All Classes Namespaces Files Functions Typedefs Enumerations Groups
conceptCheck.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_CONCEPT_CHECK_HH
22 #define RFFGEN_CONCEPT_CHECK_HH
23 
24 #include "LinearAlgebra/extractRowsAndCols.hh"
25 #include "Util/consistencyCheck.hh"
26 #include "Util/staticChecks.hh"
27 
28 namespace RFFGen
29 {
30  namespace Concepts
31  {
37  template < class Arg >
39  {
40  static_assert(std::is_copy_constructible<Arg>(), "CopyConcept: Input types must be copy-constructible.");
41  static_assert(std::is_copy_assignable<Arg>(), "CopyConcept: Input types must be copy-assignable.");
42  };
43 
44 
50  template < class Arg >
52  {
53  static_assert(Checks::multiplicationWithArithmeticFromLeft< Arg , double > () ||
54  Checks::inPlaceMultiplicationWithArithmetic< Arg , double >(),
55  "MultiplyWithArithmeticFromLeftConcept: Input types must support multiplication with double from the left (operator*(double,const Arg&))");
56  static_assert(Checks::multiplicationWithArithmeticFromLeft< Arg , int > () ||
57  Checks::inPlaceMultiplicationWithArithmetic< Arg , int >(),
58  "MultiplyWithArithmeticFromLeftConcept: Input types must support multiplication with int from the left (operator*(int,const Arg&))");
59  };
60 
61 
67  template < class Arg >
69  {
70  static_assert(Checks::summation< Arg >() ||
71  Checks::inPlaceSummation< Arg >(),
72  "SummationConcept: Input types must support summation (operator+(const Arg&, const Arg&)");
73  };
74 
75 
80  template < class Arg1 , class Arg2 >
82  {
83  static_assert(Checks::multiplication< Arg1 , Arg2 >() ||
84  Checks::callToRightMultiply< Arg1 , Arg2 >() ||
85  Checks::inPlaceMultiplication< Arg1 , Arg2 >(),
86  "MultiplicationConcept: Input types must support multiplication (operator*(const Arg&, const Arg&");
87  };
88 
89 
94  template <class Arg>
96  : CopyConceptCheck<Arg> ,
99  {};
100 
101 
106  template < class Matrix >
108  {
109  static_assert(Checks::accessViaSquareBrackets<Matrix>() ||
110  Checks::accessViaRoundBrackets<Matrix>(),
111  "MatrixConcept: Currently only matrices that allow access to their elements via A[i][j] or A(i,j) are supported.\nYou may contact the developer to ask for further access or provide your own patch.");
112  };
113 
114 
119  template < class Vector >
121  {
122  static_assert(Checks::accessViaSquareBrackets<Vector>() ||
123  Checks::accessViaRoundBrackets<Vector>(),
124  "VectorConcept: Currently only vectors that allow access to their elements via v[i] or v(i) are supported.\nYou may contact the developer to ask for further access or provide your own patch.");
125  };
126 
131  template < class Matrix >
133  {
135  static_assert( LinearAlgebra::numberOfRows<Matrix>() == LinearAlgebra::numberOfColumns<Matrix>(),
136  "SymmetricMatrixConcept: Input matrix must be symmetric.");
137  };
138 
139 
144  template <class F>
146  {
147  static_assert( hasD0MemberFunction<F>() ,
148  "FunctionConcept: Functions must provide a member function d0() to access its value." );
149  };
150  }
151 }
152 
153 #endif // RFFGEN_CONCEPT_CHECK_HH
Static check if the requirements of SummationConcept are satisfied.
Definition: conceptCheck.hh:68
Static check if the requirements of VectorConcept are satisfied.
Definition: conceptCheck.hh:120
Static checks for detection of presence of different operators and functions.
Static check if the requirements of MultiplyWithArithmeticFromLeftConcept are satisfied.
Definition: conceptCheck.hh:51
Static check if the requirements of ArithmeticConcept are satisfied.
Definition: conceptCheck.hh:95
Static check if the requirements of SymmetricMatrixConcept are satisfied.
Definition: conceptCheck.hh:132
Static check if the requirements of CopyConcept are satisfied.
Definition: conceptCheck.hh:38
Static check if the requirements of MultiplicationConcept are satisfied.
Definition: conceptCheck.hh:81
Static check if the requirements of MatrixConcept are satisfied.
Definition: conceptCheck.hh:107
Static check if the requirements of FunctionConcept are satisfied.
Definition: conceptCheck.hh:145