dune-fem  2.8-git
double.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_DOUBLE_HH
2 #define DUNE_FEM_DOUBLE_HH
3 
4 //- system includes
5 #include <iostream>
6 #include <cmath>
7 #include <limits>
8 #include <string>
9 
10 //- Dune includes
11 #include <dune/common/version.hh>
12 #include <dune/common/typetraits.hh>
13 
18 
19 namespace Dune
20 {
21 
22  namespace Fem
23  {
24 
25 #ifdef COUNT_FLOPS
26 
27  template< class FloatImp >
28  class FlOpCounter;
29 
30 
31  template <class FloatImp>
32  class FlOpSummary
33  {
34  typedef FlOpSummary< FloatImp > ThisType;
35 
36  std::string name_;
37  ThreadSafeValue< unsigned long > count_;
38 
39  FlOpSummary(const std::string& name) : name_(name), count_( 0 ) {}
40  public:
41  ~FlOpSummary ()
42  {
43  unsigned long totalCount = 0;
44  for( size_t i=0; i<count_.size(); ++i )
45  {
46  std::cout << name_ << " thread[ " << i << " ]: " << count_[ i ] << std::endl;
47  totalCount += count_[ i ];
48  }
49 
50  std :: cout << "Total number of floating point operations (" << name_ << "): "
51  << totalCount << std :: endl;
52  }
53 
54  inline void add( const unsigned long count, const int thread )
55  {
56  count_[ thread ] += count ;
57  }
58 
59  friend class Dune::Fem::Singleton< ThisType >;
60 
61  static ThisType& instance( const std::string& name )
62  {
63  return Singleton< ThisType >::instance( name );
64  }
65  };
66 
67 
68  template< class FloatImp >
69  class FlOpCounter
70  {
71  public:
72  typedef FloatImp FloatType;
73 
74  private:
75  typedef FlOpCounter< FloatType > ThisType;
76 
77  protected:
78  unsigned long count_;
79  const int thread_;
80 
81  protected:
82  inline FlOpCounter ()
83  : count_( 0 ), thread_( ThreadManager::thread() )
84  {
85  FlOpSummary< FloatImp > :: instance( FloatImp::typeName() ) ;
86  }
87 
88  public:
89  inline ~FlOpCounter ()
90  {
91  FlOpSummary< FloatImp > :: instance( FloatImp::typeName() ).add( count_, thread_ );
92  }
93 
94  inline ThisType &operator++ ()
95  {
96  ++(count_);
97  return *this;
98  }
99 
100  inline ThisType &operator += ( const unsigned long i )
101  {
102  count_ += i;
103  return *this;
104  }
105 
106  friend class Dune::Fem::Singleton< ThisType >;
107  static ThisType &instance ()
108  {
109 #ifdef HAVE_PTHREAD
110  static thread_local ThisType instance;
111  return instance;
112 #else
114 #endif
115  }
116  };
117 
118 #else
119 
120  template< class FloatImp >
122  {
123  public:
124  typedef FloatImp FloatType;
125 
126  private:
128 
129  protected:
130  inline FlOpCounter ()
131  {
132  }
133 
134  public:
136  {
137  return *this;
138  }
139 
140  inline ThisType &operator += ( const unsigned long i )
141  {
142  return *this;
143  }
144 
145  DUNE_EXPORT static ThisType &instance ()
146  {
147 #ifdef HAVE_PTHREAD
148  static thread_local ThisType instance;
149 #else
150  static ThisType instance;
151 #endif
152  return instance;
153  }
154  };
155 
156 #endif
157 
158  //- forward declaration
159  class Double;
160  // wrap of std log
161  static double log (const Double& v);
162  // wrap of std sqrt
163  static double sqrt(const Double& v);
164  // wrap of std sin
165  static double cos (const Double& v);
166  // wrap of std cos
167  static double sin(const Double& v);
168 
169  // wrap of std min
170  static inline double min (const Double& v, const double p);
171  // wrap of std min
172  static inline double min (const double v, const Double& p);
173  // wrap of std max
174  static inline double max (const Double& v, const double p);
175  // wrap of std max
176  static inline double max (const double v, const Double& p);
177 
178 
179  // numeric limits
180  // --------------
181 
182  class Double
183  {
184  private:
185  typedef Double ThisType;
186 
187  friend Double operator+ ( const Double&, const Double& );
188  friend Double operator+ ( const Double&, const double );
189  friend Double operator+ ( const double, const Double& );
190  friend Double operator+ ( const Double&, const int );
191  friend Double operator+ ( const int, const Double& );
192  friend Double operator+ ( const Double&, const unsigned int );
193  friend Double operator+ ( const unsigned int, const Double& );
194 
195  friend Double operator- ( const Double&, const Double& );
196  friend Double operator- ( const Double&, const double );
197  friend Double operator- ( const double, const Double& );
198  friend Double operator- ( const Double&, const int );
199  friend Double operator- ( const int, const Double& );
200  friend Double operator- ( const Double&, const unsigned int );
201  friend Double operator- ( const unsigned int, const Double& );
202 
203  friend Double operator* ( const Double&, const Double& );
204  friend Double operator* ( const Double&, const double );
205  friend Double operator* ( const double, const Double& );
206  friend Double operator* ( const Double&, const int );
207  friend Double operator* ( const int, const Double& );
208  friend Double operator* ( const Double&, const unsigned int );
209  friend Double operator* ( const unsigned int, const Double& );
210 
211  friend Double operator/ ( const Double&, const Double& );
212  friend Double operator/ ( const double, const Double& );
213  friend Double operator/ ( const Double&, const double );
214  friend Double operator/ ( const int, const Double& );
215  friend Double operator/ ( const Double&, const int );
216  friend Double operator/ ( const unsigned int, const Double& );
217  friend Double operator/ ( const Double&, const unsigned int );
218 
219  friend bool operator== ( const Double&, const Double& );
220  friend bool operator== ( const double, const Double& );
221  friend bool operator== ( const Double&, const double );
222  friend bool operator== ( const int, const Double& );
223  friend bool operator== ( const Double&, const int );
224  friend bool operator== ( const unsigned int, const Double& );
225  friend bool operator== ( const Double&, const unsigned int );
226 
227  friend bool operator!= ( const Double&, const Double& );
228  friend bool operator!= ( const double, const Double& );
229  friend bool operator!= ( const Double&, const double );
230  friend bool operator!= ( const int, const Double& );
231  friend bool operator!= ( const Double&, const int );
232  friend bool operator!= ( const unsigned int, const Double& );
233  friend bool operator!= ( const Double&, const unsigned int );
234 
235  friend bool operator< ( const Double&, const Double& );
236  friend bool operator< ( const double, const Double& );
237  friend bool operator< ( const Double&, const double );
238  friend bool operator< ( const int, const Double& );
239  friend bool operator< ( const Double&, const int );
240  friend bool operator< ( const unsigned int, const Double& );
241  friend bool operator< ( const Double&, const unsigned int );
242 
243  friend bool operator<= ( const Double&, const Double& );
244  friend bool operator<= ( const double, const Double& );
245  friend bool operator<= ( const Double&, const double );
246  friend bool operator<= ( const int, const Double& );
247  friend bool operator<= ( const Double&, const int );
248  friend bool operator<= ( const unsigned int, const Double& );
249  friend bool operator<= ( const Double&, const unsigned int );
250 
251  friend bool operator> ( const Double&, const Double& );
252  friend bool operator> ( const double, const Double& );
253  friend bool operator> ( const Double&, const double );
254  friend bool operator> ( const int, const Double& );
255  friend bool operator> ( const Double&, const int );
256  friend bool operator> ( const unsigned int, const Double& );
257  friend bool operator> ( const Double&, const unsigned int );
258 
259  friend bool operator>= ( const Double&, const Double& );
260  friend bool operator>= ( const double, const Double& );
261  friend bool operator>= ( const Double&, const double );
262  friend bool operator>= ( const int, const Double& );
263  friend bool operator>= ( const Double&, const int );
264  friend bool operator>= ( const unsigned int, const Double& );
265  friend bool operator>= ( const Double&, const unsigned int );
266 
267  friend std :: ostream &operator<< ( std :: ostream&, const Double& );
268  friend std :: istream &operator>> ( std :: istream&, Double& );
269 
270  template< class Traits >
273  template< class Traits >
276 
277  friend double pow (const Double& v, const double p);
278  friend double pow (const Double& v, const Double& p);
279  friend double log (const Double& v);
280  friend double sqrt(const Double& v);
281  friend double sin(const Double& v);
282  friend double cos(const Double& v);
283 
284  friend Double abs ( const Double & );
285  friend double min(const Double&, const double);
286  friend double min(const double, const Double&);
287  friend double max(const Double&, const double);
288  friend double max(const double, const Double&);
289 
290  friend double real( const std::complex<Double>& );
291  friend double real( const Double& );
292  friend double imag( const std::complex<Double>& );
293  friend double imag( const Double& );
294 
295 #if DUNE_FEM_COMPATIBILITY
296  friend struct XdrIO< Double >;
297 #endif
298 
299  friend void field_cast ( const Double &, double & );
300 
301  protected:
303 
304  protected:
305  double value_;
306 
307  public:
308  operator double () const
309  {
310  return value_;
311  }
312 
313  inline Double ()
314  // : value_( 0 )
315 //#ifndef NDEBUG
316 // : value_( std::numeric_limits< double >::signaling_NaN() )
317 //#endif
318  {
319  }
320 
321  inline Double ( const double value )
322  : value_( value )
323  {}
324 
325  inline Double ( const ThisType &other )
326  : value_( other.value_ )
327  {}
328 
329  inline ThisType &operator= ( const ThisType other )
330  {
331  // flOp();
332  value_ = other.value_;
333  return *this;
334  }
335 
336  inline ThisType &operator+= ( const ThisType other )
337  {
338  flOp();
339  value_ += other.value_;
340  return *this;
341  }
342 
343  inline ThisType &operator-= ( const ThisType other )
344  {
345  flOp();
346  value_ -= other.value_;
347  return *this;
348  }
349 
350  inline ThisType &operator*= ( const ThisType other )
351  {
352  flOp();
353  value_ *= other.value_;
354  return *this;
355  }
356 
357  inline ThisType &operator/= ( const ThisType other )
358  {
359  flOp();
360  value_ /= other.value_;
361  return *this;
362  }
363 
365  {
366  flOp();
367  return Double( -value_ );
368  }
369 
370  static std :: string typeName ()
371  {
372  return "Double";
373  }
374 
375  protected:
376  static inline void flOp ()
377  {
379  }
380  };
381 
382  // min/max
383  // ---------
384 
385  // wrap of std min
386  static inline double min (const Double& v, const double p)
387  {
388  return (v.value_ > p) ? p : v.value_;
389  }
390 
391  // wrap of std min
392  static inline double min (const double v, const Double& p)
393  {
394  return (v > p.value_) ? p.value_ : v;
395  }
396 
397  // wrap of std max
398  static inline double max (const Double& v, const double p)
399  {
400  return (v.value_ < p) ? p : v.value_;
401  }
402 
403  // wrap of std max
404  static inline double max (const double v, const Double& p)
405  {
406  return (v < p.value_) ? p.value_ : v;
407  }
408 
409  // operator+
410  // ---------
411 
412  inline Double operator+ ( const Double &a, const Double &b )
413  {
414  Double :: flOp();
415  return Double( a.value_ + b.value_ );
416  }
417 
418  inline Double operator+ ( const double a, const Double &b )
419  {
420  Double :: flOp();
421  return Double( a + b.value_ );
422  }
423 
424  inline Double operator+ ( const Double &a, const double b )
425  {
426  Double :: flOp();
427  return Double( a.value_ + b );
428  }
429 
430  inline Double operator+ ( const int a, const Double &b )
431  {
432  Double :: flOp();
433  return Double( a + b.value_ );
434  }
435 
436  inline Double operator+ ( const Double &a, const int b )
437  {
438  Double :: flOp();
439  return Double( a.value_ + b );
440  }
441 
442  inline Double operator+ ( const unsigned int a, const Double &b )
443  {
444  Double :: flOp();
445  return Double( a + b.value_ );
446  }
447 
448  inline Double operator+ ( const Double &a, const unsigned int b )
449  {
450  Double :: flOp();
451  return Double( a.value_ + b );
452  }
453 
454 
455 
456  // operator-
457  // ---------
458 
459  inline Double operator- ( const Double &a, const Double &b )
460  {
461  Double :: flOp();
462  return Double( a.value_ - b.value_ );
463  }
464 
465  inline Double operator- ( const double a, const Double &b )
466  {
467  Double :: flOp();
468  return Double( a - b.value_ );
469  }
470 
471  inline Double operator- ( const Double &a, const double b )
472  {
473  Double :: flOp();
474  return Double( a.value_ - b );
475  }
476 
477  inline Double operator- ( const int a, const Double &b )
478  {
479  Double :: flOp();
480  return Double( a - b.value_ );
481  }
482 
483  inline Double operator- ( const Double &a, const int b )
484  {
485  Double :: flOp();
486  return Double( a.value_ - b );
487  }
488 
489  inline Double operator- ( const unsigned int a, const Double &b )
490  {
491  Double :: flOp();
492  return Double( a - b.value_ );
493  }
494 
495  inline Double operator- ( const Double &a, const unsigned int b )
496  {
497  Double :: flOp();
498  return Double( a.value_ - b );
499  }
500 
501 
502 
503  // operator*
504  // ---------
505 
506  inline Double operator* ( const Double &a, const Double &b )
507  {
508  Double :: flOp();
509  return Double( a.value_ * b.value_ );
510  }
511 
512  inline Double operator* ( const double a, const Double &b )
513  {
514  Double :: flOp();
515  return Double( a * b.value_ );
516  }
517 
518  inline Double operator* ( const Double &a, const double b )
519  {
520  Double :: flOp();
521  return Double( a.value_ * b );
522  }
523 
524  inline Double operator* ( const int a, const Double &b )
525  {
526  Double :: flOp();
527  return Double( a * b.value_ );
528  }
529 
530  inline Double operator* ( const Double &a, const int b )
531  {
532  Double :: flOp();
533  return Double( a.value_ * b );
534  }
535 
536  inline Double operator* ( const unsigned int a, const Double &b )
537  {
538  Double :: flOp();
539  return Double( a * b.value_ );
540  }
541 
542  inline Double operator* ( const Double &a, const unsigned int b )
543  {
544  Double :: flOp();
545  return Double( a.value_ * b );
546  }
547 
548 
549 
550  // operator/
551  // ---------
552 
553  inline Double operator/ ( const Double &a, const Double &b )
554  {
555  Double :: flOp();
556  return Double( a.value_ / b.value_ );
557  }
558 
559  inline Double operator/ ( const double a, const Double &b )
560  {
561  Double :: flOp();
562  return Double( a / b.value_ );
563  }
564 
565  inline Double operator/ ( const Double &a, const double b )
566  {
567  Double :: flOp();
568  return Double( a.value_ / b );
569  }
570 
571  inline Double operator/ ( const int a, const Double &b )
572  {
573  Double :: flOp();
574  return Double( a / b.value_ );
575  }
576 
577  inline Double operator/ ( const Double &a, const int b )
578  {
579  Double :: flOp();
580  return Double( a.value_ / b );
581  }
582 
583  inline Double operator/ ( const unsigned int a, const Double &b )
584  {
585  Double :: flOp();
586  return Double( a / b.value_ );
587  }
588 
589  inline Double operator/ ( const Double &a, const unsigned int b )
590  {
591  Double :: flOp();
592  return Double( a.value_ / b );
593  }
594 
595 
596 
597  // operator==
598  // ----------
599 
600  inline bool operator== ( const Double &a, const Double &b )
601  {
602  return (a.value_ == b.value_);
603  }
604 
605  inline bool operator== ( const double a, const Double &b )
606  {
607  return (a == b.value_);
608  }
609 
610  inline bool operator== ( const Double &a, const double b )
611  {
612  return (a.value_ == b);
613  }
614 
615  inline bool operator== ( const int a, const Double &b )
616  {
617  return (a == b.value_);
618  }
619 
620  inline bool operator== ( const Double &a, const int b )
621  {
622  return (a.value_ == b);
623  }
624 
625  inline bool operator== ( const unsigned int a, const Double &b )
626  {
627  return (a == b.value_);
628  }
629 
630  inline bool operator== ( const Double &a, const unsigned int b )
631  {
632  return (a.value_ == b);
633  }
634 
635 
636 
637  // operator!=
638  // ----------
639 
640  inline bool operator!= ( const Double &a, const Double &b )
641  {
642  return (a.value_ != b.value_);
643  }
644 
645  inline bool operator!= ( const double a, const Double &b )
646  {
647  return (a != b.value_);
648  }
649 
650  inline bool operator!= ( const Double &a, const double b )
651  {
652  return (a.value_ != b);
653  }
654 
655  inline bool operator!= ( const int a, const Double &b )
656  {
657  return (a != b.value_);
658  }
659 
660  inline bool operator!= ( const Double &a, const int b )
661  {
662  return (a.value_ != b);
663  }
664 
665  inline bool operator!= ( const unsigned int a, const Double &b )
666  {
667  return (a != b.value_);
668  }
669 
670  inline bool operator!= ( const Double &a, const unsigned int b )
671  {
672  return (a.value_ != b);
673  }
674 
675 
676 
677  // operator<
678  // ---------
679 
680  inline bool operator< ( const Double &a, const Double &b )
681  {
682  return (a.value_ < b.value_);
683  }
684 
685  inline bool operator< ( const double a, const Double &b )
686  {
687  return (a < b.value_);
688  }
689 
690  inline bool operator< ( const Double &a, const double b )
691  {
692  return (a.value_ < b);
693  }
694 
695  inline bool operator< ( const int a, const Double &b )
696  {
697  return (a < b.value_);
698  }
699 
700  inline bool operator< ( const Double &a, const int b )
701  {
702  return (a.value_ < b);
703  }
704 
705  inline bool operator< ( const unsigned int a, const Double &b )
706  {
707  return (a < b.value_);
708  }
709 
710  inline bool operator< ( const Double &a, const unsigned int b )
711  {
712  return (a.value_ < b);
713  }
714 
715 
716 
717  // operator<=
718  // ----------
719 
720  inline bool operator<= ( const Double &a, const Double &b )
721  {
722  return (a.value_ <= b.value_);
723  }
724 
725  inline bool operator<= ( const double a, const Double &b )
726  {
727  return (a <= b.value_);
728  }
729 
730  inline bool operator<= ( const Double &a, const double b )
731  {
732  return (a.value_ <= b);
733  }
734 
735  inline bool operator<= ( const int a, const Double &b )
736  {
737  return (a <= b.value_);
738  }
739 
740  inline bool operator<= ( const Double &a, const int b )
741  {
742  return (a.value_ <= b);
743  }
744 
745  inline bool operator<= ( const unsigned int a, const Double &b )
746  {
747  return (a <= b.value_);
748  }
749 
750  inline bool operator<= ( const Double &a, const unsigned int b )
751  {
752  return (a.value_ <= b);
753  }
754 
755 
756 
757  // operator>
758  // ---------
759 
760  inline bool operator> ( const Double &a, const Double &b )
761  {
762  return (a.value_ > b.value_);
763  }
764 
765  inline bool operator> ( const double a, const Double &b )
766  {
767  return (a > b.value_);
768  }
769 
770  inline bool operator> ( const Double &a, const double b )
771  {
772  return (a.value_ > b);
773  }
774 
775  inline bool operator> ( const int a, const Double &b )
776  {
777  return (a > b.value_);
778  }
779 
780  inline bool operator> ( const Double &a, const int b )
781  {
782  return (a.value_ > b);
783  }
784 
785  inline bool operator> ( const unsigned int a, const Double &b )
786  {
787  return (a > b.value_);
788  }
789 
790  inline bool operator> ( const Double &a, const unsigned int b )
791  {
792  return (a.value_ > b);
793  }
794 
795 
796 
797  // operator>=
798  // ----------
799 
800  inline bool operator>= ( const Double &a, const Double &b )
801  {
802  return (a.value_ >= b.value_);
803  }
804 
805  inline bool operator>= ( const double a, const Double &b )
806  {
807  return (a >= b.value_);
808  }
809 
810  inline bool operator>= ( const Double &a, const double b )
811  {
812  return (a.value_ >= b);
813  }
814 
815  inline bool operator>= ( const int a, const Double &b )
816  {
817  return (a >= b.value_);
818  }
819 
820  inline bool operator>= ( const Double &a, const int b )
821  {
822  return (a.value_ >= b);
823  }
824 
825  inline bool operator>= ( const unsigned int a, const Double &b )
826  {
827  return (a >= b.value_);
828  }
829 
830  inline bool operator>= ( const Double &a, const unsigned int b )
831  {
832  return (a.value_ >= b);
833  }
834 
835 
836 
837  // stream operators
838  // ----------------
839 
840  inline std :: ostream &operator<< ( std :: ostream &out, const Double &a )
841  {
842  return out << a.value_;
843  }
844 
845  inline std :: istream &operator>> ( std :: istream &in, Double &a )
846  {
847  return in >> a.value_;
848  }
849 
850  template< class Traits >
853  const Double a )
854  {
855  return out << a.value_;
856  }
857 
858  template< class Traits >
859  inline InStreamInterface< Traits > &
861  Double &a )
862  {
863  return in >> a.value_;
864  }
865 
866 
867 
868  // standard functions
869  // ------------------
870 
871  inline Double abs ( const Double &a )
872  {
873  return Double( std::abs( a.value_ ) );
874  }
875 
876  static inline double log (const Double& v)
877  {
878  return std::log(v.value_);
879  }
880 
881  inline double pow (const Double& a, const double b )
882  {
883  return std::pow(a.value_, b);
884  }
885 
886  static inline double sqrt(const Double& v)
887  {
888  return std::sqrt(v.value_);
889  }
890 
891  static inline double sin (const Double& v)
892  {
893  return std::sin(v.value_);
894  }
895 
896  static inline double cos(const Double& v)
897  {
898  return std::cos(v.value_);
899  }
900 
901  inline void field_cast ( const Double &f1, double &f2 )
902  {
903  f2 = f1.value_;
904  }
905 
906  inline double real (const std::complex<Double>& x)
907  {
908  return x.real().value_;
909  }
910 
911  inline double real (const Double& x)
912  {
913  return x.value_;
914  }
915 
916  inline double imag (const std::complex<Double>& x)
917  {
918  return x.imag().value_;
919  }
920 
921  inline double imag (const Double& x)
922  {
923  return x.value_;
924  }
925 
926  } // namespace Fem
927 
928  using Fem :: Double ;
929 
930  template <>
931  struct IsNumber< Double > : public IsNumber< double > {};
932 #if DUNE_VERSION_GT(DUNE_COMMON, 2, 6)
933  template <>
934  struct HasNaN < Double > : public HasNaN < double > {};
935 #endif
936 
937 } // namespace Dune
938 
939 
940 namespace std
941 {
942  inline Dune::Fem::Double abs ( const Dune::Fem::Double &a )
943  {
944  return Dune::Fem::abs( a );
945  }
946 
948  {
949  return Dune::Fem::pow( a, b );
950  }
951 
952  // wrap of std min
953  inline double min (const Dune::Fem::Double& v, const double p)
954  {
955  return Dune::Fem::min(v,p);
956  }
957 
958  // wrap of std min
959  inline double min (const double v, const Dune::Fem::Double& p)
960  {
961  return Dune::Fem::min(v,p);
962  }
963 
964  // wrap of std max
965  inline double max (const Dune::Fem::Double& v, const double p)
966  {
967  return Dune::Fem::max(v,p);
968  }
969 
970  // wrap of std max
971  inline double max (const double v, const Dune::Fem::Double& p)
972  {
973  return Dune::Fem::max(v,p);
974  }
975 
976  // wrap of std sqrt
977  inline double sqrt( const Dune::Fem::Double& v )
978  {
979  return Dune::Fem::sqrt( v );
980  }
981 
982  // wrap of std real
983  inline double real (const complex<Dune::Fem::Double>& x)
984  {
985  return Dune::Fem::real( x );
986  }
987 
988  // wrap of std real
989  inline double real (const Dune::Fem::Double& x)
990  {
991  return Dune::Fem::real( x );
992  }
993 
994  // wrap of std imag
995  inline double imag (const complex<Dune::Fem::Double>& x)
996  {
997  return Dune::Fem::imag( x );
998  }
999 
1000  // wrap of std imag
1001  inline double imag (const Dune::Fem::Double& x)
1002  {
1003  return Dune::Fem::imag( x );
1004  }
1005 
1006 
1007 
1008  // numeric limits
1009  // --------------
1010 
1011  template<>
1012  struct numeric_limits< Dune::Fem::Double >
1013  {
1014  static const bool is_specialized = true;
1015 
1016  static const int radix = numeric_limits< double > :: radix;
1017  static const int digits = numeric_limits< double > :: digits;
1018  static const int digits10 = numeric_limits< double > :: digits10;
1019 
1020  static const bool is_signed = numeric_limits< double > :: is_signed;
1021  static const bool is_integer = numeric_limits< double > :: is_integer;
1022  static const bool is_exact = numeric_limits< double > :: is_exact;
1023 
1024  inline static Dune::Fem::Double min () throw ()
1025  {
1026  return Dune::Fem::Double( numeric_limits< double > :: min() );
1027  }
1028 
1029  inline static Dune::Fem::Double max () throw ()
1030  {
1031  return Dune::Fem::Double( numeric_limits< double > :: max() );
1032  }
1033 
1034  inline static Dune::Fem::Double epsilon () throw ()
1035  {
1036  return Dune::Fem::Double( numeric_limits< double > :: epsilon() );
1037  }
1038 
1039  inline static Dune::Fem::Double round_error () throw ()
1040  {
1041  return Dune::Fem::Double( numeric_limits< double > :: round_error() );
1042  }
1043 
1044  inline static Dune::Fem::Double infinity () throw ()
1045  {
1046  return Dune::Fem::Double( numeric_limits< double > :: infinity() );
1047  }
1048 
1049  inline static Dune::Fem::Double quiet_NaN () throw ()
1050  {
1051  return Dune::Fem::Double( numeric_limits< double > :: quiet_NaN() );
1052  }
1053 
1054  inline static Dune::Fem::Double signaling_NaN () throw ()
1055  {
1056  return Dune::Fem::Double( numeric_limits< double > :: signaling_NaN() );
1057  }
1058 
1059  inline static Dune::Fem::Double denorm_min () throw ()
1060  {
1061  return Dune::Fem::Double( numeric_limits< double > :: denorm_min() );
1062  }
1063 
1064  static const int min_exponent = numeric_limits< double > :: min_exponent;
1065  static const int max_exponent = numeric_limits< double > :: max_exponent;
1066  static const int min_exponent10 = numeric_limits< double > :: min_exponent10;
1067  static const int max_exponent10 = numeric_limits< double > :: max_exponent10;
1068 
1069  static const bool has_infinity = numeric_limits< double > :: has_infinity;
1070  static const bool has_quiet_NaN = numeric_limits< double > :: has_quiet_NaN;
1071  static const bool has_signaling_NaN = numeric_limits< double > :: has_signaling_NaN;
1072  static const float_denorm_style has_denorm = numeric_limits< double > :: has_denorm;
1073  static const bool has_denorm_loss = numeric_limits< double > :: has_denorm_loss;
1074 
1075  static const bool is_iec559 = numeric_limits< double > :: is_iec559;
1076  static const bool is_bounded = numeric_limits< double > :: is_bounded;
1077  static const bool is_modulo = numeric_limits< double > :: is_modulo;
1078 
1079  static const bool traps = numeric_limits< double > :: traps;
1080  static const bool tinyness_before = numeric_limits< double > :: tinyness_before;
1081  static const float_round_style round_style
1082  = numeric_limits< double > :: round_style;
1083 
1084  };
1085 
1086  template <>
1087  struct is_floating_point< Dune::Fem::Double > : public is_floating_point< double > {};
1088 
1089 } // namespace std
1090 
1091 #endif // #ifndef DUNE_FEM_DOUBLE_HH
Definition: bindguard.hh:11
double imag(const std::complex< Double > &x)
Definition: double.hh:916
OutStreamInterface< StreamTraits > & operator<<(OutStreamInterface< StreamTraits > &out, const DiscreteFunctionInterface< Impl > &df)
write a discrete function into an output stream
Definition: discretefunction_inline.hh:397
Double operator/(const Double &a, const Double &b)
Definition: double.hh:553
bool operator<(const Double &a, const Double &b)
Definition: double.hh:680
double real(const std::complex< Double > &x)
Definition: double.hh:906
double pow(const Double &a, const double b)
Definition: double.hh:881
Double operator*(const Double &a, const Double &b)
Definition: double.hh:506
bool operator<=(const Double &a, const Double &b)
Definition: double.hh:720
static double cos(const Double &v)
Definition: double.hh:896
static double min(const Double &v, const double p)
Definition: double.hh:386
Double abs(const Double &a)
Definition: double.hh:871
static double sqrt(const Double &v)
Definition: double.hh:886
void field_cast(const Double &f1, double &f2)
Definition: double.hh:901
static double sin(const Double &v)
Definition: double.hh:891
bool operator==(const Double &a, const Double &b)
Definition: double.hh:600
bool operator>=(const Double &a, const Double &b)
Definition: double.hh:800
bool operator>(const Double &a, const Double &b)
Definition: double.hh:760
static double log(const Double &v)
Definition: double.hh:876
bool operator!=(const Double &a, const Double &b)
Definition: double.hh:640
Double operator+(const Double &a, const Double &b)
Definition: double.hh:412
Double operator-(const Double &a, const Double &b)
Definition: double.hh:459
static double max(const Double &v, const double p)
Definition: double.hh:398
InStreamInterface< StreamTraits > & operator>>(InStreamInterface< StreamTraits > &in, DiscreteFunctionInterface< Impl > &df)
read a discrete function from an input stream
Definition: discretefunction_inline.hh:417
abstract interface for an output stream
Definition: streams.hh:46
abstract interface for an input stream
Definition: streams.hh:179
Definition: double.hh:122
FlOpCounter()
Definition: double.hh:130
ThisType & operator++()
Definition: double.hh:135
ThisType & operator+=(const unsigned long i)
Definition: double.hh:140
static DUNE_EXPORT ThisType & instance()
Definition: double.hh:145
FloatImp FloatType
Definition: double.hh:124
Definition: double.hh:183
ThisType & operator+=(const ThisType other)
Definition: double.hh:336
ThisType & operator=(const ThisType other)
Definition: double.hh:329
Double operator-() const
Definition: double.hh:364
friend bool operator<=(const Double &, const Double &)
Definition: double.hh:720
friend void field_cast(const Double &, double &)
Definition: double.hh:901
friend bool operator>(const Double &, const Double &)
Definition: double.hh:760
friend double real(const std::complex< Double > &)
Definition: double.hh:906
static std ::string typeName()
Definition: double.hh:370
friend double sin(const Double &v)
Definition: double.hh:891
FlOpCounter< ThisType > FlOpCounterType
Definition: double.hh:302
ThisType & operator/=(const ThisType other)
Definition: double.hh:357
friend Double operator*(const Double &, const Double &)
Definition: double.hh:506
friend double pow(const Double &v, const double p)
Definition: double.hh:881
friend double sqrt(const Double &v)
Definition: double.hh:886
friend double log(const Double &v)
Definition: double.hh:876
ThisType & operator-=(const ThisType other)
Definition: double.hh:343
friend bool operator>=(const Double &, const Double &)
Definition: double.hh:800
friend double min(const Double &, const double)
Definition: double.hh:386
friend double max(const Double &, const double)
Definition: double.hh:398
friend bool operator!=(const Double &, const Double &)
Definition: double.hh:640
friend std ::istream & operator>>(std ::istream &, Double &)
Definition: double.hh:845
friend Double operator+(const Double &, const Double &)
Definition: double.hh:412
Double(const double value)
Definition: double.hh:321
friend std ::ostream & operator<<(std ::ostream &, const Double &)
Definition: double.hh:840
Double()
Definition: double.hh:313
double value_
Definition: double.hh:305
Double(const ThisType &other)
Definition: double.hh:325
friend bool operator==(const Double &, const Double &)
Definition: double.hh:600
ThisType & operator*=(const ThisType other)
Definition: double.hh:350
friend Double abs(const Double &)
Definition: double.hh:871
friend Double operator/(const Double &, const Double &)
Definition: double.hh:553
friend bool operator<(const Double &, const Double &)
Definition: double.hh:680
static void flOp()
Definition: double.hh:376
friend double cos(const Double &v)
Definition: double.hh:896
friend double imag(const std::complex< Double > &)
Definition: double.hh:916
static Dune::Fem::Double quiet_NaN()
Definition: double.hh:1049
static Dune::Fem::Double signaling_NaN()
Definition: double.hh:1054
static Dune::Fem::Double max()
Definition: double.hh:1029
static Dune::Fem::Double infinity()
Definition: double.hh:1044
static Dune::Fem::Double min()
Definition: double.hh:1024
static Dune::Fem::Double denorm_min()
Definition: double.hh:1059
static Dune::Fem::Double epsilon()
Definition: double.hh:1034
static Dune::Fem::Double round_error()
Definition: double.hh:1039
return singleton instance of given Object type.
Definition: singleton.hh:71
static Object & instance(Args &&... args)
return singleton instance of given Object type.
Definition: singleton.hh:101
The ThreadManager wrapps basic shared memory functionality provided by OpenMP or pthreads such as thr...