dd_real.h
Go to the documentation of this file.
1 /*
2  * include/double2.h
3  *
4  * This work was supported by the Director, Office of Science, Division
5  * of Mathematical, Information, and Computational Sciences of the
6  * U.S. Department of Energy under contract numbers DE-AC03-76SF00098 and
7  * DE-AC02-05CH11231.
8  *
9  * Copyright (c) 2003-2009, The Regents of the University of California,
10  * through Lawrence Berkeley National Laboratory (subject to receipt of
11  * any required approvals from U.S. Dept. of Energy) All rights reserved.
12  *
13  * By downloading or using this software you are agreeing to the modified
14  * BSD license "BSD-LBNL-License.doc" (see LICENSE.txt).
15  */
16 /*
17  * Double-double precision (>= 106-bit significand) floating point
18  * arithmetic package based on David Bailey's Fortran-90 double-double
19  * package, with some changes. See
20  *
21  * http://www.nersc.gov/~dhbailey/mpdist/mpdist.html
22  *
23  * for the original Fortran-90 version.
24  *
25  * Overall structure is similar to that of Keith Brigg's C++ double-double
26  * package. See
27  *
28  * http://www-epidem.plansci.cam.ac.uk/~kbriggs/doubledouble.html
29  *
30  * for more details. In particular, the fix for x86 computers is borrowed
31  * from his code.
32  *
33  * Yozo Hida
34  */
35 
36 #ifndef _DD_REAL_H
37 #define _DD_REAL_H
38 
39 #include <float.h>
40 #include <limits.h>
41 #include <math.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /* Some configuration defines */
48 
49 /* If fast fused multiply-add is available, define to the correct macro for
50  using it. It is invoked as DD_FMA(a, b, c) to compute fl(a * b + c).
51  If correctly rounded multiply-add is not available (or if unsure),
52  keep it undefined. */
53 #ifndef DD_FMA
54 #ifdef FP_FAST_FMA
55 #define DD_FMA(A, B, C) fma((A), (B), (C))
56 #endif
57 #endif
58 
59 /* Same with fused multiply-subtract */
60 #ifndef DD_FMS
61 #ifdef FP_FAST_FMA
62 #define DD_FMS(A, B, C) fma((A), (B), (-C))
63 #endif
64 #endif
65 
66 #ifdef __cplusplus
67 #define DD_STATIC_CAST(T, X) (static_cast<T>(X))
68 #else
69 #define DD_STATIC_CAST(T, X) ((T)(X))
70 #endif
71 
72 /* double2 struct definition, some external always-present double2 constants.
73 */
74 typedef struct double2
75 {
76  double x[2];
77 } double2;
78 
79 extern const double DD_C_EPS;
80 extern const double DD_C_MIN_NORMALIZED;
81 extern const double2 DD_C_MAX;
82 extern const double2 DD_C_SAFE_MAX;
83 extern const int DD_C_NDIGITS;
84 
85 extern const double2 DD_C_2PI;
86 extern const double2 DD_C_PI;
87 extern const double2 DD_C_3PI4;
88 extern const double2 DD_C_PI2;
89 extern const double2 DD_C_PI4;
90 extern const double2 DD_C_PI16;
91 extern const double2 DD_C_E;
92 extern const double2 DD_C_LOG2;
93 extern const double2 DD_C_LOG10;
94 extern const double2 DD_C_ZERO;
95 extern const double2 DD_C_ONE;
96 extern const double2 DD_C_NEGONE;
97 
98 /* NAN definition in AIX's math.h doesn't make it qualify as constant literal. */
99 #if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && defined(NAN) && !defined(_AIX)
100 #define DD_C_NAN_IS_CONST
101 extern const double2 DD_C_NAN;
102 extern const double2 DD_C_INF;
103 extern const double2 DD_C_NEGINF;
104 #else
105 #define DD_C_NAN (dd_create(NAN, NAN))
106 #define DD_C_INF (dd_create(INFINITY, INFINITY))
107 #define DD_C_NEGINF (dd_create(-INFINITY, -INFINITY))
108 #endif
109 
110 
111 /* Include the inline definitions of functions */
112 #include "dd_real_idefs.h"
113 
114 /* Non-inline functions */
115 
116 /********** Exponentiation **********/
117 double2 dd_npwr(const double2 a, int n);
118 
119 /*********** Transcendental Functions ************/
120 double2 dd_exp(const double2 a);
121 double2 dd_log(const double2 a);
122 double2 dd_expm1(const double2 a);
123 double2 dd_log1p(const double2 a);
124 double2 dd_log10(const double2 a);
125 double2 dd_log_d(double a);
126 
127 /* Returns the exponent of the double precision number.
128  Returns INT_MIN is x is zero, and INT_MAX if x is INF or NaN. */
129 int get_double_expn(double x);
130 
131 /*********** Polynomial Functions ************/
132 double2 dd_polyeval(const double2 *c, int n, const double2 x);
133 
134 /*********** Random number generator ************/
135 extern double2 dd_rand(void);
136 
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 
143 #endif /* _DD_REAL_H */
DD_C_NAN
#define DD_C_NAN
Definition: dd_real.h:105
DD_C_NEGONE
const double2 DD_C_NEGONE
Definition: dd_real.c:48
dd_polyeval
double2 dd_polyeval(const double2 *c, int n, const double2 x)
Definition: dd_real.c:524
DD_C_PI4
const double2 DD_C_PI4
Definition: dd_real.c:56
DD_C_MAX
const double2 DD_C_MAX
Definition: dd_real.c:40
dd_log
double2 dd_log(const double2 a)
Definition: dd_real.c:367
double2
Definition: dd_real.h:74
dd_log10
double2 dd_log10(const double2 a)
Definition: dd_real.c:422
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
dd_log_d
double2 dd_log_d(double a)
Definition: dd_real.c:428
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
DD_C_ONE
const double2 DD_C_ONE
Definition: dd_real.c:47
DD_C_MIN_NORMALIZED
const double DD_C_MIN_NORMALIZED
Definition: dd_real.c:36
DD_C_LOG10
const double2 DD_C_LOG10
Definition: dd_real.c:67
dd_exp
double2 dd_exp(const double2 a)
Definition: dd_real.c:294
DD_C_LOG2
const double2 DD_C_LOG2
Definition: dd_real.c:65
DD_C_2PI
const double2 DD_C_2PI
Definition: dd_real.c:50
n
int n
Definition: BiCGSTAB_simple.cpp:1
double2::x
double x[2]
Definition: dd_real.h:76
dd_real_idefs.h
dd_rand
double2 dd_rand(void)
Definition: dd_real.c:498
DD_C_3PI4
const double2 DD_C_3PI4
Definition: dd_real.c:60
DD_C_ZERO
const double2 DD_C_ZERO
Definition: dd_real.c:46
dd_npwr
double2 dd_npwr(const double2 a, int n)
Definition: dd_real.c:219
DD_C_PI16
const double2 DD_C_PI16
Definition: dd_real.c:58
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
DD_C_EPS
const double DD_C_EPS
Definition: dd_real.c:35
DD_C_NEGINF
#define DD_C_NEGINF
Definition: dd_real.h:107
DD_C_PI
const double2 DD_C_PI
Definition: dd_real.c:52
double2
struct double2 double2
DD_C_INF
#define DD_C_INF
Definition: dd_real.h:106
DD_C_SAFE_MAX
const double2 DD_C_SAFE_MAX
Definition: dd_real.c:42
DD_C_PI2
const double2 DD_C_PI2
Definition: dd_real.c:54
dd_log1p
double2 dd_log1p(const double2 a)
Definition: dd_real.c:404
DD_C_NDIGITS
const int DD_C_NDIGITS
DD_C_E
const double2 DD_C_E
Definition: dd_real.c:63
get_double_expn
int get_double_expn(double x)
Definition: dd_real.c:90
dd_expm1
double2 dd_expm1(const double2 a)
Definition: dd_real.c:481


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:26