10 #ifndef SACADO_FAD_SCALARTRAITSIMP_HPP
11 #define SACADO_FAD_SCALARTRAITSIMP_HPP
15 #ifdef HAVE_SACADO_TEUCHOSCORE
26 template <
typename FadType>
27 struct ScalarTraitsImp {
30 typedef typename mpl::apply<FadType,typename Teuchos::ScalarTraits<ValueT>::magnitudeType>::type magnitudeType;
31 typedef typename mpl::apply<FadType,typename Teuchos::ScalarTraits<ValueT>::halfPrecision>::type halfPrecision;
32 typedef typename mpl::apply<FadType,typename Teuchos::ScalarTraits<ValueT>::doublePrecision>::type doublePrecision;
36 static const bool isComparable =
38 static const bool hasMachineParameters =
70 static magnitudeType magnitude(
const FadType&
a) {
72 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
73 a,
"Error, the input value to magnitude(...) a = " << a <<
76 "Complex magnitude is not a differentiable "
77 "function of complex inputs.");
80 magnitudeType b(a.size(),
83 for (
int i=0;
i<a.size();
i++)
87 for (
int i=0;
i<a.size();
i++)
92 static ValueT zero() {
103 "Complex conjugate is not a differentiable "
104 "function of complex inputs.");
115 "Real component is not a differentiable "
116 "function of complex inputs.");
127 "Imaginary component is not a differentiable "
128 "function of complex inputs.");
133 static ValueT nan() {
136 static bool isnaninf(
const FadType& x) {
139 for (
int i=0;
i<x.size();
i++)
144 static void seedrandom(
unsigned int s) {
147 static ValueT random() {
150 static std::string name() {
155 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
156 x,
"Error, the input value to squareroot(...) a = " << x <<
157 " can not be NaN!" );
166 static bool is_complex_real(
const ValueT& x) {
172 static bool is_fad_real(
const FadType& x) {
176 if (!is_complex_real(x.val()))
178 for (
int i=0;
i<x.size();
i++)
179 if (!is_complex_real(x.fastAccessDx(
i)))
191 #endif // HAVE_SACADO_TEUCHOSCORE
193 #endif // SACADO_FAD_SCALARTRAITSIMP_HPP
static std::string eval()
static magnitudeType eps()
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static magnitudeType real(T a)
Sacado::Fad::DFad< double > FadType
static magnitudeType emax()
static magnitudeType base()
static magnitudeType rmax()
static magnitudeType sfmin()
static magnitudeType prec()
static magnitudeType rmin()
static void seedrandom(unsigned int s)
static magnitudeType magnitude(T a)
Sacado::Random< double > rnd
SACADO_INLINE_FUNCTION mpl::enable_if_c< ExprLevel< Expr< T1 > >::value==ExprLevel< Expr< T2 > >::value, Expr< PowerOp< Expr< T1 >, Expr< T2 > > > >::type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
static magnitudeType emin()
static magnitudeType rnd()