npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
std_quadmath.hh
1 #ifndef NPSTAT_STD_QUADMATH_HH_
2 #define NPSTAT_STD_QUADMATH_HH_
3 
4 #include <complex>
5 
6 #define npstat_convert_to_complex128(from, to) /**/ \
7  __complex128 to; \
8  __real__ to = (from).real(); \
9  __imag__ to = (from).imag();
10 
11 #define npstat_adapt_float128_1arg_fcn(quadname, stdname) /**/ \
12  inline lapack_double stdname (const lapack_double c) \
13  { \
14  return quadname (c); \
15  }
16 
17 #define npstat_adapt_float128_2arg_fcn(quadname, stdname) /**/ \
18  inline lapack_double stdname (const lapack_double c1, \
19  const lapack_double c2) \
20  { \
21  return quadname (c1, c2); \
22  }
23 
24 #define npstat_adapt_complex128_1arg_fcn(quadname, stdname) /**/ \
25  inline std::complex<lapack_double> stdname ( \
26  const std::complex<lapack_double> c) \
27  { \
28  npstat_convert_to_complex128(c, y); \
29  const __complex128 r = quadname (y); \
30  return std::complex<lapack_double>(__real__ r, __imag__ r);\
31  }
32 
33 namespace std {
34  inline lapack_double abs(const lapack_double c)
35  {
36  return c >= 0.0 ? c : -c;
37  }
38 
39  npstat_adapt_float128_1arg_fcn(acosq, acos)
40  npstat_adapt_float128_1arg_fcn(acoshq, acosh)
41  npstat_adapt_float128_1arg_fcn(asinq, asin)
42  npstat_adapt_float128_1arg_fcn(asinhq, asinh)
43  npstat_adapt_float128_1arg_fcn(atanq, atan)
44  npstat_adapt_float128_1arg_fcn(atanhq, atanh)
45  npstat_adapt_float128_2arg_fcn(atan2q, atan2)
46  npstat_adapt_float128_1arg_fcn(cbrtq, cbrt)
47  npstat_adapt_float128_1arg_fcn(ceilq, ceil)
48  npstat_adapt_float128_2arg_fcn(copysignq, copysign)
49  npstat_adapt_float128_1arg_fcn(coshq, cosh)
50  npstat_adapt_float128_1arg_fcn(cosq, cos)
51  npstat_adapt_float128_1arg_fcn(erfq, erf)
52  npstat_adapt_float128_1arg_fcn(erfcq, erfc)
53  npstat_adapt_float128_1arg_fcn(expq, exp)
54  npstat_adapt_float128_1arg_fcn(expm1q, expm1)
55  npstat_adapt_float128_2arg_fcn(fmaxq, max)
56  npstat_adapt_float128_2arg_fcn(fminq, min)
57  npstat_adapt_float128_2arg_fcn(fmodq, mod)
58  npstat_adapt_float128_2arg_fcn(hypotq, hypot)
59  npstat_adapt_float128_1arg_fcn(j0q, j0)
60  npstat_adapt_float128_1arg_fcn(j1q, j1)
61  npstat_adapt_float128_1arg_fcn(lgammaq, lgamma)
62  npstat_adapt_float128_1arg_fcn(logq, log)
63  npstat_adapt_float128_1arg_fcn(log10q, log10)
64  npstat_adapt_float128_1arg_fcn(log2q, log2)
65  npstat_adapt_float128_1arg_fcn(log1pq, log1p)
66  npstat_adapt_float128_1arg_fcn(nearbyintq, nearbyint)
67  npstat_adapt_float128_2arg_fcn(nextafterq, nextafter)
68  npstat_adapt_float128_2arg_fcn(powq, pow)
69  npstat_adapt_float128_2arg_fcn(remainderq, remainder)
70  npstat_adapt_float128_1arg_fcn(rintq, rint)
71  npstat_adapt_float128_1arg_fcn(roundq, round)
72  npstat_adapt_float128_1arg_fcn(sinhq, sinh)
73  npstat_adapt_float128_1arg_fcn(sinq, sin)
74  npstat_adapt_float128_1arg_fcn(sqrtq, sqrt)
75  npstat_adapt_float128_1arg_fcn(tanq, tan)
76  npstat_adapt_float128_1arg_fcn(tanhq, tanh)
77  npstat_adapt_float128_1arg_fcn(tgammaq, tgamma)
78  npstat_adapt_float128_1arg_fcn(truncq, trunc)
79  npstat_adapt_float128_1arg_fcn(y0q, y0)
80  npstat_adapt_float128_1arg_fcn(y1q, y1)
81 
82  inline int finite(const lapack_double c)
83  {
84  return finiteq(c);
85  }
86 
87  inline int isinf(const lapack_double c)
88  {
89  return isinfq(c);
90  }
91 
92  inline int isnan(const lapack_double c)
93  {
94  return isnanq(c);
95  }
96 
97  inline int signbit(const lapack_double c)
98  {
99  return signbitq(c);
100  }
101 
102  inline long long int llrint(const lapack_double c)
103  {
104  return llrintq(c);
105  }
106 
107  inline long long int llround(const lapack_double c)
108  {
109  return llroundq(c);
110  }
111 
112  inline long int lrint(const lapack_double c)
113  {
114  return lrintq(c);
115  }
116 
117  inline long int lround(const lapack_double c)
118  {
119  return lroundq(c);
120  }
121 
122  inline lapack_double abs(const std::complex<lapack_double> c)
123  {
124  return hypotq(c.real(), c.imag());
125  }
126 
127  inline lapack_double arg(const std::complex<lapack_double> c)
128  {
129  npstat_convert_to_complex128(c, y);
130  return cargq(y);
131  }
132 
133  inline std::complex<lapack_double> expi(const lapack_double c)
134  {
135  const __complex128 r = cexpiq(c);
136  return std::complex<lapack_double>(__real__ r, __imag__ r);
137  }
138 
139  npstat_adapt_complex128_1arg_fcn(cacosq, acos)
140  npstat_adapt_complex128_1arg_fcn(cacoshq, acosh)
141  npstat_adapt_complex128_1arg_fcn(casinq, asin)
142  npstat_adapt_complex128_1arg_fcn(casinhq, asinh)
143  npstat_adapt_complex128_1arg_fcn(catanq, atan)
144  npstat_adapt_complex128_1arg_fcn(catanhq, atanh)
145  npstat_adapt_complex128_1arg_fcn(ccosq, cos)
146  npstat_adapt_complex128_1arg_fcn(ccoshq, cosh)
147  npstat_adapt_complex128_1arg_fcn(cexpq, exp)
148  npstat_adapt_complex128_1arg_fcn(clogq, log)
149  npstat_adapt_complex128_1arg_fcn(clog10q, log10)
150  npstat_adapt_complex128_1arg_fcn(cprojq, proj)
151  npstat_adapt_complex128_1arg_fcn(csinq, sin)
152  npstat_adapt_complex128_1arg_fcn(csinhq, sinh)
153  npstat_adapt_complex128_1arg_fcn(csqrtq, sqrt)
154  npstat_adapt_complex128_1arg_fcn(ctanq, tan)
155  npstat_adapt_complex128_1arg_fcn(ctanhq, tanh)
156 
157  inline std::complex<lapack_double> pow(const std::complex<lapack_double> c1,
158  const std::complex<lapack_double> c2)
159  {
160  npstat_convert_to_complex128(c1, y1);
161  npstat_convert_to_complex128(c2, y2);
162  const __complex128 r = cpowq(y1, y2);
163  return std::complex<lapack_double>(__real__ r, __imag__ r);
164  }
165 }
166 
167 #endif // NPSTAT_STD_QUADMATH_HH_