Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_ScalarFlopCounterTraits.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 // ***********************************************************************
9 //
10 // The forward-mode AD classes in Sacado are a derivative work of the
11 // expression template classes in the Fad package by Nicolas Di Cesare.
12 // The following banner is included in the original Fad source code:
13 //
14 // ************ DO NOT REMOVE THIS BANNER ****************
15 //
16 // Nicolas Di Cesare <Nicolas.Dicesare@ann.jussieu.fr>
17 // http://www.ann.jussieu.fr/~dicesare
18 //
19 // CEMRACS 98 : C++ courses,
20 // templates : new C++ techniques
21 // for scientific computing
22 //
23 //********************************************************
24 //
25 // NumericalTraits class to illustrate TRAITS
26 //
27 //********************************************************
28 // @HEADER
29 
30 #ifndef SACADO_SCALARFLOPCOUNTERTRAITS_HPP
31 #define SACADO_SCALARFLOPCOUNTERTRAITS_HPP
32 
33 #include "Sacado_Traits.hpp"
34 
35 // Forward declarations
36 namespace Sacado {
37  namespace FlopCounterPack {
38  template <typename T> class ScalarFlopCounter;
39  }
40 }
41 
42 namespace Sacado {
43 
45  SACADO_AD_PROMOTE_SPEC( FlopCounterPack, ScalarFlopCounter )
46 
47 
48  template <typename ScalarT>
49  struct ScalarType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
50  typedef typename ScalarType<ScalarT>::type type;
51  };
52 
54  template <typename ScalarT>
55  struct ValueType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
56  typedef ScalarT type;
57  };
58 
60  template <typename ScalarT>
61  struct IsADType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
62  static const bool value = true;
63  };
64 
66  template <typename ScalarT>
67  struct IsScalarType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
68  static const bool value = false;
69  };
70 
72  template <typename ScalarT>
73  struct Value< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
76  return x.val(); }
77  };
78 
80  template <typename ScalarT>
81  struct ScalarValue< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
85  return ScalarValue<value_type>::eval(x.val()); }
86  };
87 
89  template <typename ScalarT>
90  struct StringName< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
91  static std::string eval() {
92  return std::string("Sacado::FlopCounterPack::ScalarFlopCounter< ") +
93  StringName<ScalarT>::eval() + " >"; }
94  };
95 
96  // Need specialization for IsEqual
97 
99  template <typename ScalarT>
100  struct IsStaticallySized< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
101  static const bool value = true;
102  };
103 
104 } // namespace Sacado
105 
106 #endif // SACADO_SCALARFLOPCOUNTERTRAITS_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.
ValueType< FlopCounterPack::ScalarFlopCounter< ScalarT > >::type value_type
Base template specification for IsADType.
const T & val() const
Return the current value.
Base template specification for Value.
#define SACADO_AD_PROMOTE_SPEC(NS, AD)
static const bool value
ValueType< FlopCounterPack::ScalarFlopCounter< ScalarT > >::type value_type
static const value_type & eval(const FlopCounterPack::ScalarFlopCounter< ScalarT > &x)
static const scalar_type & eval(const FlopCounterPack::ScalarFlopCounter< ScalarT > &x)
static const bool value
Base template specification for IsScalarType.
ScalarType< FlopCounterPack::ScalarFlopCounter< ScalarT > >::type scalar_type
Base template specification for ValueType.
Base template specification for testing whether type is statically sized.