Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
Float.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_FLOAT_H
2#define _RHEOLEF_FLOAT_H
3//
4// This file is part of Rheolef.
5//
6// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7//
8// Rheolef is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rheolef is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rheolef; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// =========================================================================
23// compiler-dependent part for rheolef implementation: the floating point
24// author: Pierre.Saramito@imag.fr
25// date: 27 january 2000
26
27namespace rheolef {
57} // namespace rheolef
58
59#include "rheolef/config.h" /* as generated by configure */
60
61#include <cmath>
62
63namespace rheolef {
64using std::cos;
65using std::sin;
66using std::tan;
67using std::acos;
68using std::asin;
69using std::atan;
70using std::cosh;
71using std::sinh;
72using std::tanh;
73using std::exp;
74using std::log;
75using std::log10;
76using std::sqrt;
77using std::abs;
78using std::fabs;
79using std::floor;
80using std::ceil;
81using std::atan2;
82using std::pow;
83using std::fmod;
84} // namespace rheolef
85
86
87#include <complex>
88
89namespace rheolef {
90
92template<class T>
94 typedef T type;
95};
96template<class T>
97struct float_traits<std::complex<T> >
98{
99 typedef typename float_traits<T>::type type;
100};
101} // namespace rheolef
102
103// ==================================================================================================
104
105#include <limits>
106
107#include "rheolef/numeric_flags.h"
108
109// -------------------------------------------------
110// Float
111// -------------------------------------------------
112#if defined(_RHEOLEF_HAVE_FLOAT128)
113#include <boost/multiprecision/float128.hpp>
114namespace rheolef {
115using boost::multiprecision::float128;
116using namespace boost::multiprecision;
117static inline float128 sqr (const float128& x) { return (x*x); }
118static inline float128 norm (const float128& x) { return fabs(x); } // for completeness with field_expr
120using Float = float128;
121//using boost::math::isnan;
122//using boost::math::isinf;
123//using boost::math::isfinite;
124//using boost::math::isnormal;
125} // namespace rheolef
126
127#elif defined(_RHEOLEF_HAVE_CLN)
128# include "rheolef/bigfloat.h"
129namespace rheolef {
131typedef bigfloat<_RHEOLEF_DIGITS10> Float;
132} // namespace rheolef
133
134#elif defined(_RHEOLEF_HAVE_LONG_DOUBLE)
135namespace rheolef {
137typedef long double Float;
138} // namespace rheolef
139
140#else
141namespace rheolef {
143typedef double Float;
144} // namespace rheolef
145#endif // Float
146
147// is any integer or float type (included extended precision, if used)
148namespace rheolef { namespace details {
149template <class T, class Sfinae = void>
150struct is_rheolef_arithmetic: std::false_type {};
151
152template <class T>
154typename std::enable_if<
155 std::is_arithmetic<T>::value
156 || std::is_same<typename std::decay<T>::type,double>::value
157>::type>
158: std::true_type {};
159
160#ifdef _RHEOLEF_HAVE_FLOAT128
161template <class T>
163typename std::enable_if<
164 std::is_same<typename std::decay<T>::type,float128>::value
165>::type>
166: std::true_type {};
167#endif // _RHEOLEF_HAVE_FLOAT128
168
169}} // namespace rheolef::details
170
171// -------------------------------------------------
172
173namespace rheolef { namespace details {
174template<class T, class Check = T>
176 typedef T type;
177};
178template<class Int>
179struct upgrade_integral_to_float<Int, typename std::enable_if<std::is_integral<Int>::value,Int>::type>
180{
181 // integers upgrated to default Float
182 typedef Float type;
183};
184
185}} // namespace rheolef::details
186
187#if !defined(_RHEOLEF_HAVE_SQR_DOUBLE)
188namespace rheolef {
189static inline double sqr (const double& x) { return (x*x); }
190} // namespace rheolef
191#endif
192
193#include <functional> // greater/less, ect...
194#include <numeric> // inner_product, ect...
195#include <algorithm>
196
197namespace rheolef {
198using std::min;
199using std::max;
200#ifdef TO_CLEAN
201// TODO: promote<T1,T2>::type max(T1,T2) {...}
202// conflict with max(field_nonlinear_expr<E>,int)
203template <class T> T max (T x, int y) { return x > y ? x : T(y); }
204template <class T> T max (int x, T y) { return x > y ? T(x) : y; }
205template <class T> T min (T x, int y) { return x < y ? x : T(y); }
206template <class T> T min (int x, T y) { return x < y ? T(x) : y; }
207// conflict with ginac::abs
208template <class T> T abs (T x) { return (x > T(0) ? x : -x); }
209#endif // TO_CLEAN
210} // namespace rheolef
211
212#include <climits>
213
214#endif // _RHEOLEF_FLOAT_H
see the Float page for the full documentation
double Float
see the Float page for the full documentation
Definition Float.h:143
Expr1::float_type T
Definition field_expr.h:230
This file is part of Rheolef.
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition vec.h:387
STL namespace.
float_traits< T >::type type
Definition Float.h:99
helper for std::complex<T>: get basic T type
Definition Float.h:93