Algorith sandbox
traits.hpp
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "algo/ad/dual.hpp"
11 #include "algo/ad/fwd.h"
12 #include <boost/numeric/ublas/traits.hpp>
13 #include <boost/numeric/ublas/vector.hpp>
14 #include <boost/numeric/ublas/vector_expression.hpp>
15 #include <boost/type_traits/is_base_of.hpp>
16 
17 namespace algo { namespace ad {
18  /*--------------------------------------------------------------------------
19  * is_scalar
20  *------------------------------------------------------------------------*/
26  template <typename T>
27  struct is_scalar
28  : boost::mpl::bool_<boost::is_scalar<T>::value> {
29  };
30  /*--------------------------------------------------------------------------
31  * is_vector
32  *------------------------------------------------------------------------*/
38  template <typename T>
39  struct is_vector
40  : boost::mpl::bool_<
41  boost::is_base_of<boost::numeric::ublas::vector_expression<T>, T>::value> {
42  };
43  /*--------------------------------------------------------------------------
44  * is_dual
45  *------------------------------------------------------------------------*/
51  template <typename T>
52  struct is_scalar_dual
53  : boost::mpl::bool_<boost::is_base_of<dual_expression<T>, T>::value>
54  {
55  };
61  template <typename T>
62  struct is_vector_dual<T, true>
63  : boost::mpl::bool_<is_scalar_dual<typename T::value_type>::value> {
64  };
70  template <typename T>
71  struct is_vector_dual<T, false> : boost::mpl::bool_<false> {
72  };
78  template <typename T>
79  struct is_dual : boost::mpl::bool_<
80  boost::mpl::or_<
81  is_vector_dual<T>,
82  is_scalar_dual<T> >::value> {
83  };
84  /*--------------------------------------------------------------------------
85  * const_closure_type_traits
86  *------------------------------------------------------------------------*/
92  template <typename T>
93  struct const_closure_type_traits_impl<T, false> {
94  typedef T type;
95  };
101  template <typename T>
103  typedef const T& type;
104  };
110  template <typename T>
112  };
113 } } // namespace algo { namespace ad {
114 
forward declarations.
Definition: fwd.h:29
Definition: ublas_matrix_expression_concept.hpp:5
Definition: fwd.h:26
dual class.