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//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef _TEUCHOS_SCALARTRAITS_DECL_HPP_
43#define _TEUCHOS_SCALARTRAITS_DECL_HPP_
44
50
51
52namespace Teuchos {
53
54
55template <typename T>
56struct UndefinedScalarTraits
57{
59 static inline T notDefined() { return T::this_type_is_missing_a_specialization(); }
60};
61
62
63/* This is the default structure used by ScalarTraits<T> to produce a compile time
64 error when the specialization does not exist for type <tt>T</tt>.
65*/
66
67
89template <typename T>
91{
101 static const bool isComplex = false;
103 static const bool isOrdinal = false;
105 static const bool isComparable = false;
110 static const bool hasMachineParameters = false;
112 static inline magnitudeType eps() { return UndefinedScalarTraits<T>::notDefined(); }
114 static inline magnitudeType sfmin() { return UndefinedScalarTraits<T>::notDefined(); }
116 static inline magnitudeType base() { return UndefinedScalarTraits<T>::notDefined(); }
118 static inline magnitudeType prec() { return UndefinedScalarTraits<T>::notDefined(); }
120 static inline magnitudeType t() { return UndefinedScalarTraits<T>::notDefined(); }
122 static inline magnitudeType rnd() { return UndefinedScalarTraits<T>::notDefined(); }
124 static inline magnitudeType emin() { return UndefinedScalarTraits<T>::notDefined(); }
126 static inline magnitudeType rmin() { return UndefinedScalarTraits<T>::notDefined(); }
128 static inline magnitudeType emax() { return UndefinedScalarTraits<T>::notDefined(); }
130 static inline magnitudeType rmax() { return UndefinedScalarTraits<T>::notDefined(); }
132 static inline magnitudeType magnitude(T a) { return UndefinedScalarTraits<T>::notDefined(); }
134 static inline T zero() { return UndefinedScalarTraits<T>::notDefined(); }
136 static inline T one() { return UndefinedScalarTraits<T>::notDefined(); }
138 static inline magnitudeType real(T a) { return UndefinedScalarTraits<T>::notDefined(); }
140 static inline magnitudeType imag(T a) { return UndefinedScalarTraits<T>::notDefined(); }
142 static inline T conjugate(T a) { return UndefinedScalarTraits<T>::notDefined(); }
144 static inline T nan() { return UndefinedScalarTraits<T>::notDefined(); }
146 static inline bool isnaninf(const T& x) { return UndefinedScalarTraits<T>::notDefined(); }
148 static inline void seedrandom(unsigned int s) { int i; T t = &i; }
150 static inline T random() { return UndefinedScalarTraits<T>::notDefined(); }
152 static inline std::string name() { (void)UndefinedScalarTraits<T>::notDefined(); return 0; }
154 static inline T squareroot(T x) { return UndefinedScalarTraits<T>::notDefined(); }
156 static inline T pow(T x, T y) { return UndefinedScalarTraits<T>::notDefined(); }
158 static inline T pi() { return UndefinedScalarTraits<T>::notDefined();}
159};
160
161
162} // Teuchos namespace
163
164
165#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.