Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Sacado_LFad_LogicalSparseTraits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 // @HEADER
29 
30 #ifndef SACADO_LFAD_LOGICALSPARSETRAITS_HPP
31 #define SACADO_LFAD_LOGICALSPARSETRAITS_HPP
32 
33 #include "Sacado_Traits.hpp"
34 
35 // Forward declarations
36 namespace Sacado {
37  namespace LFad {
38  template <typename T1, typename T2> class LogicalSparse;
39  }
40 }
41 
42 namespace Sacado {
43 
44  namespace LFad {
45  template <typename T> class Expr;
46  }
47 
49  SACADO_AD_PROMOTE_SPEC2( LFad, LogicalSparse )
50 
51 
52  template <typename ValT, typename LogT>
53  struct ScalarType< LFad::LogicalSparse<ValT,LogT> > {
55  };
56 
58  template <typename ValT, typename LogT>
59  struct ValueType< LFad::LogicalSparse<ValT,LogT> > {
61  };
62 
64  template <typename ValT, typename LogT>
65  struct IsADType< LFad::LogicalSparse<ValT,LogT> > {
66  static const bool value = true;
67  };
68 
70  template <typename ValT, typename LogT>
71  struct IsScalarType< LFad::LogicalSparse<ValT,LogT> > {
72  static const bool value = false;
73  };
74 
76  template <typename ValT, typename LogT>
77  struct Value< LFad::LogicalSparse<ValT,LogT> > {
80  return x.val(); }
81  };
82 
84  template <typename ValT, typename LogT>
85  struct ScalarValue< LFad::LogicalSparse<ValT,LogT> > {
89  return ScalarValue<value_type>::eval(x.val()); }
90  };
91 
93  template <typename ValT, typename LogT>
94  struct StringName< LFad::LogicalSparse<ValT,LogT> > {
95  static std::string eval() {
96  return std::string("Sacado::LFad::LoginalSparse< ") +
97  StringName<ValT>::eval() + ", " +
98  StringName<LogT>::eval() + " >"; }
99  };
100 
102  template <typename ValT, typename LogT>
103  struct IsEqual< LFad::LogicalSparse<ValT,LogT> > {
104  static bool eval(const LFad::LogicalSparse<ValT,LogT>& x,
106  return x.isEqualTo(y);
107  }
108  };
109 
111  template <typename ValT, typename LogT>
112  struct IsStaticallySized< LFad::LogicalSparse<ValT,LogT> > {
113  static const bool value = false;
114  };
115 
116 } // namespace Sacado
117 
118 // Define Teuchos traits classes
119 #ifdef HAVE_SACADO_TEUCHOS
121 #include "Teuchos_ScalarTraits.hpp"
124 
125 namespace Teuchos {
126 
128  template <typename ValT, typename LogT>
129  struct PromotionTraits< Sacado::LFad::LogicalSparse<ValT,LogT>,
130  Sacado::LFad::LogicalSparse<ValT,LogT> > {
133  promote;
134  };
135 
137  template <typename ValT, typename LogT, typename R>
138  struct PromotionTraits< Sacado::LFad::LogicalSparse<ValT,LogT>, R > {
140  promote;
141  };
142 
144  template <typename L, typename ValT, typename LogT>
145  struct PromotionTraits< L, Sacado::LFad::LogicalSparse<ValT,LogT> > {
146  public:
148  promote;
149  };
150 
151  //
152  // These specialization implementations don't work for LFad because
153  // the value type (e.g., double) is different from the dx() type (e.g., bool)
154  //
155 
156  // //! Specializtion of %Teuchos::ScalarTraits
157  // template <typename ValT, typename LogT>
158  // struct ScalarTraits< Sacado::LFad::LogicalSparse<ValT,LogT> > :
159  // public Sacado::Fad::ScalarTraitsImp< Sacado::LFad::LogicalSparse<ValT,LogT> >
160  // {};
161 
162  // //! Specialization of %Teuchos::SerializationTraits
163  // template <typename Ordinal, typename ValT, typename LogT>
164  // struct SerializationTraits<Ordinal, Sacado::LFad::LogicalSparse<ValT,LogT> > :
165  // public Sacado::Fad::SerializationTraitsImp< Ordinal,
166  // Sacado::LFad::LogicalSparse<ValT,LogT> >
167  // {};
168 }
169 #endif // HAVE_SACADO_TEUCHOS
170 
171 #endif // SACADO_LFAD_LOGICALSPARSETRAITS_HPP
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)
KOKKOS_INLINE_FUNCTION const ValT & val() const
Returns value.
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)
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.
static KOKKOS_INLINE_FUNCTION const T & eval(const T &x)
Base template specification for testing whether type is statically sized.
ScalarType< typename LFad::LogicalSparse< ValT, LogT >::value_type >::type type