1 #ifndef DUNE_FEM_DOUBLE_HH 2 #define DUNE_FEM_DOUBLE_HH 23 template<
class FloatImp >
27 template <
class FloatImp>
30 typedef FlOpSummary< FloatImp > ThisType;
33 ThreadSafeValue< unsigned long > count_;
35 FlOpSummary(
const std::string& name) : name_(name), count_( 0 ) {}
39 unsigned long totalCount = 0;
40 for(
size_t i=0; i<count_.size(); ++i )
42 std::cout << name_ <<
" thread[ " << i <<
" ]: " << count_[ i ] << std::endl;
43 totalCount += count_[ i ];
46 std :: cout <<
"Total number of floating point operations (" << name_ <<
"): " 47 << totalCount << std :: endl;
50 inline void add(
const unsigned long count,
const int thread )
52 count_[ thread ] += count ;
55 inline static ThisType& instance(
const std::string& name )
57 static ThisType instance( name );
63 template<
class FloatImp >
67 typedef FloatImp FloatType;
70 typedef FlOpCounter< FloatType > ThisType;
78 : count_( 0 ), thread_( ThreadManager::thread() )
80 FlOpSummary< FloatImp > :: instance( FloatImp::typeName() ) ;
84 inline ~FlOpCounter ()
86 FlOpSummary< FloatImp > :: instance( FloatImp::typeName() ).add( count_, thread_ );
89 inline ThisType &operator++ ()
95 inline ThisType &operator += (
const unsigned long i )
101 inline static ThisType &instance ()
103 static thread_local ThisType instance;
110 template<
class FloatImp >
125 inline ThisType &operator++ ()
130 inline ThisType &operator += (
const unsigned long i )
137 static thread_local ThisType instance;
156 static inline double min (
const Double& v,
const double p);
158 static inline double min (
const double v,
const Double& p);
160 static inline double max (
const Double& v,
const double p);
162 static inline double max (
const double v,
const Double& p);
256 template<
class Traits >
258 operator<< ( OutStreamInterface< Traits > &,
const Double );
259 template<
class Traits >
263 friend double pow (
const Double& v,
const double p);
270 friend double min(
const Double&,
const double);
271 friend double min(
const double,
const Double&);
272 friend double max(
const Double&,
const double);
273 friend double max(
const double,
const Double&);
275 friend double real(
const std::complex<Double>& );
277 friend double imag(
const std::complex<Double>& );
280 #if DUNE_FEM_COMPATIBILITY 281 friend struct XdrIO< Double >;
284 friend void field_cast (
const Double &,
double & );
297 operator const double ()
const 315 : value_( other.value_ )
318 inline ThisType &operator= (
const ThisType other )
325 inline ThisType &operator+= (
const ThisType other )
332 inline ThisType &operator-= (
const ThisType other )
339 inline ThisType &operator*= (
const ThisType other )
346 inline ThisType &operator/= (
const ThisType other )
356 return Double( -value_ );
367 ++(FlOpCounterType :: instance());
375 static inline double min (
const Double& v,
const double p)
381 static inline double min (
const double v,
const Double& p)
387 static inline double max (
const Double& v,
const double p)
393 static inline double max (
const double v,
const Double& p)
839 template<
class Traits >
841 operator<< ( OutStreamInterface< Traits > &out,
847 template<
class Traits >
872 return std::sqrt(v.
value_);
890 inline double real (
const std::complex<Double>& x)
892 return x.real().value_;
900 inline double imag (
const std::complex<Double>& x)
902 return x.imag().value_;
955 inline double real (
const complex<Dune::Fem::Double>& x)
967 inline double imag (
const complex<Dune::Fem::Double>& x)
984 struct numeric_limits<
Dune::Fem::Double >
986 static const bool is_specialized =
true;
988 static const int radix = numeric_limits< double > :: radix;
989 static const int digits = numeric_limits< double > :: digits;
990 static const int digits10 = numeric_limits< double > :: digits10;
992 static const bool is_signed = numeric_limits< double > :: is_signed;
993 static const bool is_integer = numeric_limits< double > :: is_integer;
994 static const bool is_exact = numeric_limits< double > :: is_exact;
1036 static const int min_exponent = numeric_limits< double > :: min_exponent;
1037 static const int max_exponent = numeric_limits< double > :: max_exponent;
1038 static const int min_exponent10 = numeric_limits< double > :: min_exponent10;
1039 static const int max_exponent10 = numeric_limits< double > :: max_exponent10;
1041 static const bool has_infinity = numeric_limits< double > :: has_infinity;
1042 static const bool has_quiet_NaN = numeric_limits< double > :: has_quiet_NaN;
1043 static const bool has_signaling_NaN = numeric_limits< double > :: has_signaling_NaN;
1044 static const float_denorm_style has_denorm = numeric_limits< double > :: has_denorm;
1045 static const bool has_denorm_loss = numeric_limits< double > :: has_denorm_loss;
1047 static const bool is_iec559 = numeric_limits< double > :: is_iec559;
1048 static const bool is_bounded = numeric_limits< double > :: is_bounded;
1049 static const bool is_modulo = numeric_limits< double > :: is_modulo;
1051 static const bool traps = numeric_limits< double > :: traps;
1052 static const bool tinyness_before = numeric_limits< double > :: tinyness_before;
1053 static const float_round_style round_style
1054 = numeric_limits< double > :: round_style;
1060 #endif // #ifndef DUNE_FEM_DOUBLE_HH double imag(const std::complex< Double > &x)
Definition: double.hh:900
static Dune::Fem::Double epsilon()
Definition: double.hh:1006
static double sqrt(const Double &v)
Definition: double.hh:870
void field_cast(const Double &f1, double &f2)
Definition: double.hh:885
static void flOp()
Definition: double.hh:365
static ThisType & instance()
Definition: double.hh:135
static double sin(const Double &v)
Definition: double.hh:875
static Dune::Fem::Double quiet_NaN()
Definition: double.hh:1021
FloatImp FloatType
Definition: double.hh:114
double value_
Definition: double.hh:290
Double()
Definition: double.hh:302
InStreamInterface< StreamTraits > & operator>>(InStreamInterface< StreamTraits > &in, DiscreteFunctionInterface< Impl > &df)
read a discrete function from an input stream
Definition: discretefunction_inline.hh:395
static Dune::Fem::Double min()
Definition: double.hh:996
static Dune::Fem::Double signaling_NaN()
Definition: double.hh:1026
FlOpCounter< ThisType > FlOpCounterType
Definition: double.hh:287
static double max(const Double &v, const double p)
Definition: double.hh:387
bool operator>(const Double &a, const Double &b)
Definition: double.hh:749
Definition: double.hh:168
static Dune::Fem::Double infinity()
Definition: double.hh:1016
bool operator>=(const Double &a, const Double &b)
Definition: double.hh:789
Double(const ThisType &other)
Definition: double.hh:314
static std::string typeName()
Definition: double.hh:359
Double abs(const Double &a)
Definition: double.hh:860
static double log(const Double &v)
Definition: double.hh:865
bool operator!=(const Double &a, const Double &b)
Definition: double.hh:629
bool operator==(const Double &a, const Double &b)
Definition: double.hh:589
bool operator<=(const Double &a, const Double &b)
Definition: double.hh:709
Definition: coordinate.hh:4
static double cos(const Double &v)
Definition: double.hh:880
abstract interface for an input stream
Definition: streams.hh:177
Definition: double.hh:111
bool operator<(const Double &a, const Double &b)
Definition: double.hh:669
Double operator*(const Double &a, const Double &b)
Definition: double.hh:495
static Dune::Fem::Double max()
Definition: double.hh:1001
FlOpCounter()
Definition: double.hh:120
static Dune::Fem::Double denorm_min()
Definition: double.hh:1031
Double operator-(const Double &a, const Double &b)
Definition: double.hh:448
static Dune::Fem::Double round_error()
Definition: double.hh:1011
double real(const std::complex< Double > &x)
Definition: double.hh:890
Double operator/(const Double &a, const Double &b)
Definition: double.hh:542
OutStreamInterface< StreamTraits > & operator<<(OutStreamInterface< StreamTraits > &out, const DiscreteFunctionInterface< Impl > &df)
write a discrete function into an output stream
Definition: discretefunction_inline.hh:375
Double operator+(const Double &a, const Double &b)
Definition: double.hh:401
static double min(const Double &v, const double p)
Definition: double.hh:375
Double(const double value)
Definition: double.hh:310
abstract interface for an output stream
Definition: streams.hh:44