Teuchos::ScalarTraits< T > Struct Template Reference

This structure defines some basic traits for a scalar field type. More...

#include <Teuchos_ScalarTraits.hpp>

List of all members.

Public Types

typedef T magnitudeType
 Mandatory typedef for result of magnitude.
typedef T halfPrecision
 Typedef for half precision.
typedef T doublePrecision
 Typedef for double precision.

Static Public Member Functions

static magnitudeType eps ()
 Returns relative machine precision.
static magnitudeType sfmin ()
 Returns safe minimum (sfmin), such that 1/sfmin does not overflow.
static magnitudeType base ()
 Returns the base of the machine.
static magnitudeType prec ()
 Returns eps*base.
static magnitudeType t ()
 Returns the number of (base) digits in the mantissa.
static magnitudeType rnd ()
 Returns 1.0 when rounding occurs in addition, 0.0 otherwise.
static magnitudeType emin ()
 Returns the minimum exponent before (gradual) underflow.
static magnitudeType rmin ()
 Returns the underflow threshold - base^(emin-1).
static magnitudeType emax ()
 Returns the largest exponent before overflow.
static magnitudeType rmax ()
 Overflow theshold - (base^emax)*(1-eps).
static magnitudeType magnitude (T a)
 Returns the magnitudeType of the scalar type a.
static T zero ()
 Returns representation of zero for this scalar type.
static T one ()
 Returns representation of one for this scalar type.
static magnitudeType real (T a)
 Returns the real part of the scalar type a.
static magnitudeType imag (T a)
 Returns the imaginary part of the scalar type a.
static T conjugate (T a)
 Returns the conjugate of the scalar type a.
static T nan ()
 Returns a number that represents NaN.
static bool isnaninf (const T &x)
 Returns true if x is NaN or Inf.
static void seedrandom (unsigned int s)
 Seed the random number generator returned by random().
static T random ()
 Returns a random number (between -one() and +one()) of this scalar type.
static std::string name ()
 Returns the name of this scalar type.
static T squareroot (T x)
 Returns a number of magnitudeType that is the square root of this scalar type x.
static T pow (T x, T y)
 Returns the result of raising one scalar x to the power y.

Static Public Attributes

static const bool isComplex = false
 Determines if scalar type is std::complex.
static const bool isOrdinal = false
 Determines if scalar type is an ordinal type.
static const bool isComparable = false
 Determines if scalar type supports relational operators such as <, >, <=, >=.
static const bool hasMachineParameters = false
 Determines if scalar type have machine-specific parameters (i.e. eps(), sfmin(), base(), prec(), t(), rnd(), emin(), rmin(), emax(), rmax() are supported).


Detailed Description

template<class T>
struct Teuchos::ScalarTraits< T >

This structure defines some basic traits for a scalar field type.

Scalar traits are an essential part of templated codes. This structure offers the basic traits of the templated scalar type, like defining zero and one, and basic functions on the templated scalar type, like performing a square root.

The functions in the templated base unspecialized struct are designed not to compile (giving a nice compile-time error message) and therefore specializations must be written for Scalar types actually used.

Note:
  1. The default defined specializations are provided for int, float, and double.
  2. ScalarTraits can be used with the Arbitrary Precision Library ( http://crd.lbl.gov/~dhbailey/mpdist/ ) by configuring Teuchos with --enable-teuchos-arprec and giving the appropriate paths to ARPREC. Then ScalarTraits has the specialization: mp_real.
  3. If Teuchos is configured with --enable-teuchos-stdcomplex then ScalarTraits also has a parital specialization for all std::complex numbers of the form std::complex<T>.

Definition at line 100 of file Teuchos_ScalarTraits.hpp.


Member Typedef Documentation

template<class T>
typedef T Teuchos::ScalarTraits< T >::magnitudeType

Mandatory typedef for result of magnitude.

Definition at line 103 of file Teuchos_ScalarTraits.hpp.

template<class T>
typedef T Teuchos::ScalarTraits< T >::halfPrecision

Typedef for half precision.

Definition at line 105 of file Teuchos_ScalarTraits.hpp.

template<class T>
typedef T Teuchos::ScalarTraits< T >::doublePrecision

Typedef for double precision.

Definition at line 107 of file Teuchos_ScalarTraits.hpp.


Member Function Documentation

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::eps (  )  [inline, static]

Returns relative machine precision.

Definition at line 117 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::sfmin (  )  [inline, static]

Returns safe minimum (sfmin), such that 1/sfmin does not overflow.

Definition at line 119 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::base (  )  [inline, static]

Returns the base of the machine.

Definition at line 121 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::prec (  )  [inline, static]

Returns eps*base.

Definition at line 123 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::t (  )  [inline, static]

Returns the number of (base) digits in the mantissa.

Definition at line 125 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::rnd (  )  [inline, static]

Returns 1.0 when rounding occurs in addition, 0.0 otherwise.

Definition at line 127 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::emin (  )  [inline, static]

Returns the minimum exponent before (gradual) underflow.

Definition at line 129 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::rmin (  )  [inline, static]

Returns the underflow threshold - base^(emin-1).

Definition at line 131 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::emax (  )  [inline, static]

Returns the largest exponent before overflow.

Definition at line 133 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::rmax (  )  [inline, static]

Overflow theshold - (base^emax)*(1-eps).

Definition at line 135 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::magnitude ( a  )  [inline, static]

Returns the magnitudeType of the scalar type a.

Definition at line 137 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::zero (  )  [inline, static]

Returns representation of zero for this scalar type.

Definition at line 139 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::one (  )  [inline, static]

Returns representation of one for this scalar type.

Definition at line 141 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::real ( a  )  [inline, static]

Returns the real part of the scalar type a.

Definition at line 143 of file Teuchos_ScalarTraits.hpp.

template<class T>
static magnitudeType Teuchos::ScalarTraits< T >::imag ( a  )  [inline, static]

Returns the imaginary part of the scalar type a.

Definition at line 145 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::conjugate ( a  )  [inline, static]

Returns the conjugate of the scalar type a.

Definition at line 147 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::nan (  )  [inline, static]

Returns a number that represents NaN.

Definition at line 149 of file Teuchos_ScalarTraits.hpp.

template<class T>
static bool Teuchos::ScalarTraits< T >::isnaninf ( const T &  x  )  [inline, static]

Returns true if x is NaN or Inf.

Definition at line 151 of file Teuchos_ScalarTraits.hpp.

template<class T>
static void Teuchos::ScalarTraits< T >::seedrandom ( unsigned int  s  )  [inline, static]

Seed the random number generator returned by random().

Definition at line 153 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::random (  )  [inline, static]

Returns a random number (between -one() and +one()) of this scalar type.

Definition at line 155 of file Teuchos_ScalarTraits.hpp.

template<class T>
static std::string Teuchos::ScalarTraits< T >::name (  )  [inline, static]

Returns the name of this scalar type.

Definition at line 157 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::squareroot ( x  )  [inline, static]

Returns a number of magnitudeType that is the square root of this scalar type x.

Definition at line 159 of file Teuchos_ScalarTraits.hpp.

template<class T>
static T Teuchos::ScalarTraits< T >::pow ( x,
y 
) [inline, static]

Returns the result of raising one scalar x to the power y.

Definition at line 161 of file Teuchos_ScalarTraits.hpp.


Member Data Documentation

template<class T>
const bool Teuchos::ScalarTraits< T >::isComplex = false [static]

Determines if scalar type is std::complex.

Definition at line 109 of file Teuchos_ScalarTraits.hpp.

template<class T>
const bool Teuchos::ScalarTraits< T >::isOrdinal = false [static]

Determines if scalar type is an ordinal type.

Definition at line 111 of file Teuchos_ScalarTraits.hpp.

template<class T>
const bool Teuchos::ScalarTraits< T >::isComparable = false [static]

Determines if scalar type supports relational operators such as <, >, <=, >=.

Definition at line 113 of file Teuchos_ScalarTraits.hpp.

template<class T>
const bool Teuchos::ScalarTraits< T >::hasMachineParameters = false [static]

Determines if scalar type have machine-specific parameters (i.e. eps(), sfmin(), base(), prec(), t(), rnd(), emin(), rmin(), emax(), rmax() are supported).

Definition at line 115 of file Teuchos_ScalarTraits.hpp.


The documentation for this struct was generated from the following file:
Generated on Wed May 12 21:24:43 2010 for Teuchos - Trilinos Tools Package by  doxygen 1.4.7