30 #ifndef SACADO_TAY_SCALARTRAITSIMP_HPP
31 #define SACADO_TAY_SCALARTRAITSIMP_HPP
35 #ifdef HAVE_SACADO_TEUCHOSCORE
46 template <
typename TayType>
47 struct ScalarTraitsImp {
50 typedef typename mpl::apply<TayType,typename Teuchos::ScalarTraits<ValueT>::magnitudeType>::type magnitudeType;
51 typedef typename mpl::apply<TayType,typename Teuchos::ScalarTraits<ValueT>::halfPrecision>::type halfPrecision;
52 typedef typename mpl::apply<TayType,typename Teuchos::ScalarTraits<ValueT>::doublePrecision>::type doublePrecision;
56 static const bool isComparable =
58 static const bool hasMachineParameters =
90 static magnitudeType magnitude(
const TayType&
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.degree(),
103 for (
int i=1; i<=a.degree(); i++)
104 b.fastAccessCoeff(i) =
107 for (
int i=1; i<=a.degree(); i++)
108 b.fastAccessCoeff(i) =
112 static ValueT zero() {
115 static ValueT one() {
120 static TayType conjugate(
const TayType& x) {
123 "Complex conjugate is not a differentiable "
124 "function of complex inputs.");
133 static TayType real(
const TayType& x) {
136 "Real component is not a differentiable "
137 "function of complex inputs.");
146 static TayType imag(
const TayType& x) {
149 "Imaginary component is not a differentiable "
150 "function of complex inputs.");
155 static ValueT nan() {
158 static bool isnaninf(
const TayType& x) {
159 for (
int i=0; i<=x.degree(); i++)
164 static void seedrandom(
unsigned int s) {
167 static ValueT random() {
170 static std::string name() {
173 static TayType squareroot(
const TayType& x) {
175 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
176 x,
"Error, the input value to squareroot(...) a = " << x <<
177 " can not be NaN!" );
181 static TayType
pow(
const TayType& x,
const TayType& y) {
186 static bool is_complex_real(
const ValueT& x) {
192 static bool is_tay_real(
const TayType& x) {
196 for (
int i=0; i<=x.degree(); i++)
197 if (!is_complex_real(x.fastAccessCoeff(i)))
209 #endif // HAVE_SACADO_TEUCHOSCORE
211 #endif // SACADO_FAD_SCALARTRAITSIMP_HPP
static std::string eval()
static magnitudeType eps()
PowExprType< Expr< T1 >, Expr< T2 > >::expr_type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static magnitudeType real(T a)
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()