Dune Core Modules (2.6.0)

gmpfield.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GMPFIELD_HH
4#define DUNE_GMPFIELD_HH
5
10#include <iostream>
11#include <string>
12
13#if HAVE_GMP || DOXYGEN
14
15#include <gmpxx.h>
16
18
19namespace Dune
20{
21
26 template< unsigned int precision >
28 : public mpf_class
29 {
30 typedef mpf_class Base;
31
32 public:
35 : Base(0,precision)
36 {}
37
41 GMPField ( const char* str )
42 : Base(str,precision)
43 {}
44
48 GMPField ( const std::string& str )
49 : Base(str,precision)
50 {}
51
54 template< class T,
55 typename EnableIf = typename std::enable_if<
56 std::is_convertible<T, mpf_class>::value>::type
57 >
58 GMPField ( const T &v )
59 : Base( v,precision )
60 {}
61
62 // type conversion operators
63 operator double () const
64 {
65 return this->get_d();
66 }
67
68 };
69
70 template <unsigned int precision>
71 struct IsNumber<GMPField<precision>>
72 : public std::integral_constant<bool, true> {
73 };
74}
75
76#endif // HAVE_GMP
77
78#endif // #ifndef DUNE_GMPFIELD_HH
Number class for high precision floating point number using the GMP library mpf_class implementation.
Definition: gmpfield.hh:29
GMPField(const T &v)
initialize from a compatible scalar type
Definition: gmpfield.hh:58
GMPField()
Definition: gmpfield.hh:34
GMPField(const std::string &str)
initialize from a string
Definition: gmpfield.hh:48
GMPField(const char *str)
initialize from a string
Definition: gmpfield.hh:41
Dune namespace.
Definition: alignedallocator.hh:10
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)