dune-common  2.2.0
math.hh
Go to the documentation of this file.
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002 // vi: set et ts=4 sw=4 sts=2:
00003 #ifndef DUNE_MATH_HH
00004 #define DUNE_MATH_HH
00005 
00010 #include <cmath>
00011 
00012 namespace Dune
00013 {
00014 
00022   template< class Field >
00023   struct MathematicalConstants;
00024 
00035   template< class T >
00036   struct StandardMathematicalConstants
00037   {
00038     static T e ()
00039     {
00040       static const T e = std::exp( T( 1 ) );
00041       return e;
00042     }
00043 
00044     static T pi ()
00045     {
00046       static const T pi = std::acos( T( -1 ) );
00047       return pi;
00048     }
00049   };
00050 
00051 
00052 #ifndef DOXYGEN
00053   // MathematicalConstants for float
00054   // -------------------------------
00055 
00056   template<>
00057   struct MathematicalConstants< float >
00058   : public StandardMathematicalConstants< float >
00059   {};
00060 
00061 
00062 
00063   // MathematicalConstants for double
00064   // --------------------------------
00065 
00066   template<>
00067   struct MathematicalConstants< double >
00068   : public StandardMathematicalConstants< double >
00069   {};
00070 
00071 
00072 
00073   // MathematicalConstants for long double
00074   // -------------------------------------
00075 
00076   template<>
00077   struct MathematicalConstants< long double >
00078   : public StandardMathematicalConstants< long double >
00079   {};
00080 #endif // DOXYGEN
00081 
00082 }
00083 
00084 #endif // #ifndef DUNE_MATH_HH