Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ScalarTraitsDecl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef _TEUCHOS_SCALARTRAITS_DECL_HPP_
11#define _TEUCHOS_SCALARTRAITS_DECL_HPP_
12
18
19
20namespace Teuchos {
21
22
23template <typename T>
24struct UndefinedScalarTraits
25{
27 static inline T notDefined() { return T::this_type_is_missing_a_specialization(); }
28};
29
30
31/* This is the default structure used by ScalarTraits<T> to produce a compile time
32 error when the specialization does not exist for type <tt>T</tt>.
33*/
34
35
57template <typename T>
59{
69 static const bool isComplex = false;
71 static const bool isOrdinal = false;
73 static const bool isComparable = false;
78 static const bool hasMachineParameters = false;
80 static inline magnitudeType eps() { return UndefinedScalarTraits<T>::notDefined(); }
82 static inline magnitudeType sfmin() { return UndefinedScalarTraits<T>::notDefined(); }
84 static inline magnitudeType base() { return UndefinedScalarTraits<T>::notDefined(); }
86 static inline magnitudeType prec() { return UndefinedScalarTraits<T>::notDefined(); }
88 static inline magnitudeType t() { return UndefinedScalarTraits<T>::notDefined(); }
90 static inline magnitudeType rnd() { return UndefinedScalarTraits<T>::notDefined(); }
92 static inline magnitudeType emin() { return UndefinedScalarTraits<T>::notDefined(); }
94 static inline magnitudeType rmin() { return UndefinedScalarTraits<T>::notDefined(); }
96 static inline magnitudeType emax() { return UndefinedScalarTraits<T>::notDefined(); }
98 static inline magnitudeType rmax() { return UndefinedScalarTraits<T>::notDefined(); }
100 static inline magnitudeType magnitude(T a) { return UndefinedScalarTraits<T>::notDefined(); }
102 static inline T zero() { return UndefinedScalarTraits<T>::notDefined(); }
104 static inline T one() { return UndefinedScalarTraits<T>::notDefined(); }
106 static inline magnitudeType real(T a) { return UndefinedScalarTraits<T>::notDefined(); }
108 static inline magnitudeType imag(T a) { return UndefinedScalarTraits<T>::notDefined(); }
110 static inline T conjugate(T a) { return UndefinedScalarTraits<T>::notDefined(); }
112 static inline T nan() { return UndefinedScalarTraits<T>::notDefined(); }
114 static inline bool isnaninf(const T& x) { return UndefinedScalarTraits<T>::notDefined(); }
116 static inline void seedrandom(unsigned int s) { int i; T t = &i; }
118 static inline T random() { return UndefinedScalarTraits<T>::notDefined(); }
120 static inline std::string name() { (void)UndefinedScalarTraits<T>::notDefined(); return 0; }
122 static inline T squareroot(T x) { return UndefinedScalarTraits<T>::notDefined(); }
124 static inline T pow(T x, T y) { return UndefinedScalarTraits<T>::notDefined(); }
126 static inline T pi() { return UndefinedScalarTraits<T>::notDefined();}
127};
128
129
130} // Teuchos namespace
131
132
133#endif // _TEUCHOS_SCALARTRAITS_DECL_HPP_
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Smart reference counting pointer class for automatic garbage collection.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
This structure defines some basic traits for a scalar field type.
static magnitudeType rmax()
Overflow theshold - (base^emax)*(1-eps)
static T pow(T x, T y)
Returns the result of raising one scalar x to the power y.
static magnitudeType magnitude(T a)
Returns the magnitudeType of the scalar type a.
static magnitudeType real(T a)
Returns the real part of the scalar type a.
static bool isnaninf(const T &x)
Returns true if x is NaN or Inf.
T halfPrecision
Typedef for half precision.
static T one()
Returns representation of one for this scalar type.
T magnitudeType
Mandatory typedef for result of magnitude.
static T zero()
Returns representation of zero for this scalar type.
static void seedrandom(unsigned int s)
Seed the random number generator returned by random().
static std::string name()
Returns the name of this scalar type.
static T conjugate(T a)
Returns the conjugate of the scalar type a.
T coordinateType
Typedef for coordinates.
static T nan()
Returns a number that represents NaN.
static magnitudeType base()
Returns the base of the machine.
static const bool isComparable
Determines if scalar type supports relational operators such as <, >, <=, >=.
static const bool isOrdinal
Determines if scalar type is an ordinal type.
static magnitudeType emax()
Returns the largest exponent before overflow.
static T random()
Returns a random number (between -one() and +one()) of this scalar type.
static magnitudeType imag(T a)
Returns the imaginary part of the scalar type a.
T doublePrecision
Typedef for double precision.
static const bool hasMachineParameters
Determines if scalar type have machine-specific parameters (i.e. eps(), sfmin(), base(),...
static magnitudeType eps()
Returns relative machine precision.
static magnitudeType rnd()
Returns 1.0 when rounding occurs in addition, 0.0 otherwise.
static T pi()
Returns the value of PI.
static T squareroot(T x)
Returns a number of magnitudeType that is the square root of this scalar type x.
static magnitudeType emin()
Returns the minimum exponent before (gradual) underflow.
static const bool isComplex
Determines if scalar type is std::complex.
static magnitudeType rmin()
Returns the underflow threshold - base^(emin-1)
static magnitudeType sfmin()
Returns safe minimum (sfmin), such that 1/sfmin does not overflow.
static magnitudeType t()
Returns the number of (base) digits in the mantissa.
static magnitudeType prec()
Returns eps*base.