Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_LFad_LogicalSparseTraits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_LFAD_LOGICALSPARSETRAITS_HPP
11 #define SACADO_LFAD_LOGICALSPARSETRAITS_HPP
12 
13 #include "Sacado_Traits.hpp"
14 
15 // Forward declarations
16 namespace Sacado {
17  namespace LFad {
18  template <typename T1, typename T2> class LogicalSparse;
19  }
20 }
21 
22 namespace Sacado {
23 
24  namespace LFad {
25  template <typename T> class Expr;
26  }
27 
29  SACADO_AD_PROMOTE_SPEC2( LFad, LogicalSparse )
30 
31 
32  template <typename ValT, typename LogT>
33  struct ScalarType< LFad::LogicalSparse<ValT,LogT> > {
35  };
36 
38  template <typename ValT, typename LogT>
39  struct ValueType< LFad::LogicalSparse<ValT,LogT> > {
41  };
42 
44  template <typename ValT, typename LogT>
45  struct IsADType< LFad::LogicalSparse<ValT,LogT> > {
46  static const bool value = true;
47  };
48 
50  template <typename ValT, typename LogT>
51  struct IsScalarType< LFad::LogicalSparse<ValT,LogT> > {
52  static const bool value = false;
53  };
54 
56  template <typename ValT, typename LogT>
57  struct Value< LFad::LogicalSparse<ValT,LogT> > {
60  return x.val(); }
61  };
62 
64  template <typename ValT, typename LogT>
65  struct ScalarValue< LFad::LogicalSparse<ValT,LogT> > {
69  return ScalarValue<value_type>::eval(x.val()); }
70  };
71 
73  template <typename ValT, typename LogT>
74  struct StringName< LFad::LogicalSparse<ValT,LogT> > {
75  static std::string eval() {
76  return std::string("Sacado::LFad::LoginalSparse< ") +
77  StringName<ValT>::eval() + ", " +
78  StringName<LogT>::eval() + " >"; }
79  };
80 
82  template <typename ValT, typename LogT>
83  struct IsEqual< LFad::LogicalSparse<ValT,LogT> > {
86  return x.isEqualTo(y);
87  }
88  };
89 
91  template <typename ValT, typename LogT>
92  struct IsStaticallySized< LFad::LogicalSparse<ValT,LogT> > {
93  static const bool value = false;
94  };
95 
96 } // namespace Sacado
97 
98 //
99 // Define Teuchos traits classes
100 //
101 
102 // Promotion traits
103 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
105 namespace Teuchos {
106  template <typename ValT, typename LogT>
107  struct PromotionTraits< Sacado::LFad::LogicalSparse<ValT,LogT>,
108  Sacado::LFad::LogicalSparse<ValT,LogT> > {
111  promote;
112  };
113 
114  template <typename ValT, typename LogT, typename R>
115  struct PromotionTraits< Sacado::LFad::LogicalSparse<ValT,LogT>, R > {
117  promote;
118  };
119 
120  template <typename L, typename ValT, typename LogT>
121  struct PromotionTraits< L, Sacado::LFad::LogicalSparse<ValT,LogT> > {
122  public:
124  promote;
125  };
126 }
127 #endif
128 
129 //
130 // These specialization implementations don't work for LFad because
131 // the value type (e.g., double) is different from the dx() type (e.g., bool)
132 //
133 
134 // // Scalar traits
135 // #ifdef HAVE_SACADO_TEUCHOSCORE
136 // #include "Sacado_Fad_ScalarTraitsImp.hpp"
137 // namespace Teuchos {
138  // template <typename ValT, typename LogT>
139  // struct ScalarTraits< Sacado::LFad::LogicalSparse<ValT,LogT> > :
140  // public Sacado::Fad::ScalarTraitsImp< Sacado::LFad::LogicalSparse<ValT,LogT> >
141  // {};
142 // }
143 // #endif
144 
145 // // Serialization traits
146 // #ifdef HAVE_SACADO_TEUCHOSCOMM
147 // #include "Sacado_Fad_SerializationTraitsImp.hpp"
148 // namespace Teuchos {
149  // template <typename Ordinal, typename ValT, typename LogT>
150  // struct SerializationTraits<Ordinal, Sacado::LFad::LogicalSparse<ValT,LogT> > :
151  // public Sacado::Fad::SerializationTraitsImp< Ordinal,
152  // Sacado::LFad::LogicalSparse<ValT,LogT> >
153  // {};
154 // }
155 // #endif
156 
157 #endif // SACADO_LFAD_LOGICALSPARSETRAITS_HPP
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
static std::string eval()
Base template specification for ScalarValue.
Base template specification for ScalarType.
Base template specification for string names of types.
Base template specification for IsADType.
static bool eval(const LFad::LogicalSparse< ValT, LogT > &x, const LFad::LogicalSparse< ValT, LogT > &y)
Base template specification for Value.
static const value_type & eval(const LFad::LogicalSparse< ValT, LogT > &x)
static const bool value
ScalarType< LFad::LogicalSparse< ValT, LogT > >::type scalar_type
Base template specification for testing equivalence.
ValueType< LFad::LogicalSparse< ValT, LogT > >::type value_type
static const scalar_type & eval(const LFad::LogicalSparse< ValT, LogT > &x)
#define SACADO_AD_PROMOTE_SPEC2(NS, AD)
SACADO_INLINE_FUNCTION const ValT & val() const
Returns value.
User inteface class for computing the logical sparsity pattern of a derivative via forward-mode AD...
ValueType< LFad::LogicalSparse< ValT, LogT > >::type value_type
ExprType::value_type value_type
Typename of values.
static const bool value
Base template specification for IsScalarType.
Base template specification for ValueType.
Base template specification for Promote.
const double y
Base template specification for testing whether type is statically sized.
ScalarType< typename LFad::LogicalSparse< ValT, LogT >::value_type >::type type