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
 Madatory typedef for result of magnitude.

Static Public Member Functions

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


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-complex then ScalarTraits also has a parital specialization for all complex numbers of the form complex<T>.

Definition at line 91 of file Teuchos_ScalarTraits.hpp.


Member Typedef Documentation

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

Madatory typedef for result of magnitude.

Definition at line 94 of file Teuchos_ScalarTraits.hpp.


Member Function Documentation

template<class T>
bool Teuchos::ScalarTraits< T >::haveMachineParameters  )  [inline, static]
 

Does this scalar type have machine-specific parameters.

Definition at line 96 of file Teuchos_ScalarTraits.hpp.

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

Returns relative machine precision.

Definition at line 98 of file Teuchos_ScalarTraits.hpp.

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

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

Definition at line 100 of file Teuchos_ScalarTraits.hpp.

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

Returns the base of the machine.

Definition at line 102 of file Teuchos_ScalarTraits.hpp.

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

Returns eps*base.

Definition at line 104 of file Teuchos_ScalarTraits.hpp.

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

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

Definition at line 106 of file Teuchos_ScalarTraits.hpp.

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

Returns 1.0 when rounding occurs in addition, 0.0 otherwise.

Definition at line 108 of file Teuchos_ScalarTraits.hpp.

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

Returns the minimum exponent before (gradual) underflow.

Definition at line 110 of file Teuchos_ScalarTraits.hpp.

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

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

Definition at line 112 of file Teuchos_ScalarTraits.hpp.

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

Returns the largest exponent before overflow.

Definition at line 114 of file Teuchos_ScalarTraits.hpp.

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

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

Definition at line 116 of file Teuchos_ScalarTraits.hpp.

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

Returns the magnitudeType of the scalar type a.

Definition at line 118 of file Teuchos_ScalarTraits.hpp.

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

Returns representation of zero for this scalar type.

Definition at line 120 of file Teuchos_ScalarTraits.hpp.

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

Returns representation of one for this scalar type.

Definition at line 122 of file Teuchos_ScalarTraits.hpp.

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

Returns the conjugate of the scalar type a.

Definition at line 124 of file Teuchos_ScalarTraits.hpp.

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

Returns a number that represents NaN.

Definition at line 126 of file Teuchos_ScalarTraits.hpp.

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

Returns true if x is NaN or Inf.

Definition at line 128 of file Teuchos_ScalarTraits.hpp.

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

Seed the random number generator returned by random().

Definition at line 130 of file Teuchos_ScalarTraits.hpp.

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

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

Definition at line 132 of file Teuchos_ScalarTraits.hpp.

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

Returns the name of this scalar type.

Definition at line 134 of file Teuchos_ScalarTraits.hpp.

template<class T>
magnitudeType 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 136 of file Teuchos_ScalarTraits.hpp.


The documentation for this struct was generated from the following file:
Generated on Thu Sep 18 12:41:20 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1