DUNE-FEM (unstable)

double.hh
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
13
14#include <dune/fem/io/streams/streams.hh>
15#include <dune/fem/misc/mpimanager.hh>
16#include <dune/fem/misc/threads/threadsafevalue.hh>
17#include <dune/fem/storage/singleton.hh>
18
19namespace 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 {
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_( MPIManager::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 >
121 class FlOpCounter
122 {
123 public:
124 typedef FloatImp FloatType;
125
126 private:
127 typedef FlOpCounter< FloatType > ThisType;
128
129 protected:
130 inline FlOpCounter ()
131 {
132 }
133
134 public:
135 inline ThisType &operator++ ()
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 >
271 friend OutStreamInterface< Traits > &
272 operator<< ( OutStreamInterface< Traits > &, const Double );
273 template< class Traits >
274 friend InStreamInterface< Traits > &
275 operator>> ( InStreamInterface< Traits > &, Double & );
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:
302 typedef FlOpCounter< ThisType > FlOpCounterType;
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
364 Double operator- () const
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 {
378 ++(FlOpCounterType :: instance());
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 >
851 inline OutStreamInterface< Traits > &
852 operator<< ( OutStreamInterface< Traits > &out,
853 const Double a )
854 {
855 return out << a.value_;
856 }
857
858 template< class Traits >
859 inline InStreamInterface< Traits > &
860 operator>> ( InStreamInterface< Traits > &in,
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
940namespace std
941{
942 inline Dune::Fem::Double abs ( const Dune::Fem::Double &a )
943 {
944 return Dune::Fem::abs( a );
945 }
946
947 inline Dune::Fem::Double pow( const Dune::Fem::Double &a, const Dune::Fem::Double &b )
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
return singleton instance of given Object type.
Definition: singleton.hh:93
static DUNE_EXPORT Object & instance(Args &&... args)
return singleton instance of given Object type.
Definition: singleton.hh:123
Various macros to work with Dune module version numbers.
Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
Read a std::tuple.
Definition: streamoperators.hh:43
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
constexpr auto min
Function object that returns the smaller of the given values.
Definition: hybridutilities.hh:506
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:638
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:684
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:661
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:238
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:706
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:260
Dune namespace.
Definition: alignedallocator.hh:13
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:159
STL namespace.
Traits for type conversions and type information.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:20
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)