30 #ifndef SACADO_FAD_SCALARTRAITSIMP_HPP
31 #define SACADO_FAD_SCALARTRAITSIMP_HPP
35 #ifdef HAVE_SACADO_TEUCHOSCORE
46 template <
typename FadType>
47 struct ScalarTraitsImp {
50 typedef typename mpl::apply<FadType,typename Teuchos::ScalarTraits<ValueT>::magnitudeType>::type magnitudeType;
51 typedef typename mpl::apply<FadType,typename Teuchos::ScalarTraits<ValueT>::halfPrecision>::type halfPrecision;
52 typedef typename mpl::apply<FadType,typename Teuchos::ScalarTraits<ValueT>::doublePrecision>::type doublePrecision;
56 static const bool isComparable =
58 static const bool hasMachineParameters =
90 static magnitudeType magnitude(
const FadType&
a) {
92 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
93 a,
"Error, the input value to magnitude(...) a = " << a <<
96 "Complex magnitude is not a differentiable "
97 "function of complex inputs.");
100 magnitudeType b(a.size(),
103 for (
int i=0; i<a.size(); i++)
107 for (
int i=0; i<a.size(); i++)
112 static ValueT zero() {
115 static ValueT one() {
123 "Complex conjugate is not a differentiable "
124 "function of complex inputs.");
135 "Real component is not a differentiable "
136 "function of complex inputs.");
147 "Imaginary component is not a differentiable "
148 "function of complex inputs.");
153 static ValueT nan() {
156 static bool isnaninf(
const FadType& x) {
159 for (
int i=0; i<x.size(); i++)
164 static void seedrandom(
unsigned int s) {
167 static ValueT random() {
170 static std::string name() {
175 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
176 x,
"Error, the input value to squareroot(...) a = " << x <<
177 " can not be NaN!" );
186 static bool is_complex_real(
const ValueT& x) {
192 static bool is_fad_real(
const FadType& x) {
196 if (!is_complex_real(x.val()))
198 for (
int i=0; i<x.size(); i++)
199 if (!is_complex_real(x.fastAccessDx(i)))
211 #endif // HAVE_SACADO_TEUCHOSCORE
213 #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()
KOKKOS_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 prec()
static magnitudeType rmin()
static void seedrandom(unsigned int s)
static magnitudeType magnitude(T a)
Sacado::Random< double > rnd
static magnitudeType emin()
static magnitudeType rnd()