Dune Core Modules (2.7.1)

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#include <type_traits>
13
14#if HAVE_GMP || DOXYGEN
15
16#include <gmpxx.h>
17
19
20namespace Dune
21{
22
27 template< unsigned int precision >
29 : public mpf_class
30 {
31 typedef mpf_class Base;
32
33 public:
36 : Base(0,precision)
37 {}
38
42 GMPField ( const char* str )
43 : Base(str,precision)
44 {}
45
49 GMPField ( const std::string& str )
50 : Base(str,precision)
51 {}
52
55 template< class T,
56 typename EnableIf = typename std::enable_if<
57 std::is_convertible<T, mpf_class>::value>::type
58 >
59 GMPField ( const T &v )
60 : Base( v,precision )
61 {}
62
63 // type conversion operators
64 operator double () const
65 {
66 return this->get_d();
67 }
68
69 };
70
71 template <unsigned int precision>
72 struct IsNumber<GMPField<precision>>
73 : public std::integral_constant<bool, true> {
74 };
75
76}
77
78#endif // HAVE_GMP
79
80#endif // #ifndef DUNE_GMPFIELD_HH
Number class for high precision floating point number using the GMP library mpf_class implementation.
Definition: gmpfield.hh:30
GMPField(const T &v)
initialize from a compatible scalar type
Definition: gmpfield.hh:59
GMPField()
Definition: gmpfield.hh:35
GMPField(const std::string &str)
initialize from a string
Definition: gmpfield.hh:49
GMPField(const char *str)
initialize from a string
Definition: gmpfield.hh:42
Dune namespace.
Definition: alignedallocator.hh:14
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)