/usr/include/fplll/nr/nr_FP_dd.inl is in libfplll-dev 5.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | #ifndef FPLLL_NR_FP_DD_H
#define FPLLL_NR_FP_DD_H
/**********************************
* F=dd_real specialization
*********************************/
#include "../defs.h"
#include "nr_FP.inl"
#include <qd/dd_real.h>
FPLLL_BEGIN_NAMESPACE
/* DD specialization if defined QD */
/* constructor */
template<>
inline FP_NR<dd_real>::FP_NR() {}
template<>
inline FP_NR<dd_real>::FP_NR(const FP_NR<dd_real>& f) {data = f.data;}
template<>
inline FP_NR<dd_real>::~FP_NR() {}
template<>
inline unsigned int FP_NR<dd_real>::get_prec() {return PREC_DD;}
template<>
inline unsigned int FP_NR<dd_real>::set_prec(unsigned int) {
return get_prec(); // ignored
}
/* return data */
template<>
inline double FP_NR<dd_real>::get_d(mp_rnd_t) const {
return ::to_double(data);
}
template<>
inline void FP_NR<dd_real>::get_mpfr(mpfr_t r, mp_rnd_t rnd) const {
mpfr_set_prec (r, get_prec());
mpfr_set_d (r, data._lo(), rnd);
mpfr_add_d (r, r, data._hi(), rnd);
}
template<>
inline void FP_NR<dd_real>::set_mpfr(mpfr_t r, mp_rnd_t rnd) {
data = mpfr_get_ld (r, rnd);
}
template<>
inline long FP_NR<dd_real>::get_si() const {
return to_int(data);
}
template<>
inline long FP_NR<dd_real>::exponent() const {
return ilogb(::to_double(data)) + 1;
}
template<>
inline long FP_NR<dd_real>::get_si_exp_we(long& expo, long expo_add) const {
if (data == 0)
expo = 0;
else
expo = max(exponent() + expo_add - numeric_limits<long>::digits, 0L);
return static_cast<long>((::ldexp(data, expo_add - expo)).x[0]);
}
template<>
inline long FP_NR<dd_real>::get_si_exp(long& expo) const {
return get_si_exp_we(expo, 0);
}
/* comparison */
template<>
inline int FP_NR<dd_real>::cmp(const FP_NR<dd_real>& b) const {
if (data > b.data) return 1;
if (data < b.data) return -1;
return 0;
}
template<>
inline int FP_NR<dd_real>::cmp(double b) const {
if (data > b) return 1;
if (data < b) return -1;
return 0;
}
template<>
inline int FP_NR<dd_real>::sgn() const {
if (data > 0) return 1;
if (data < 0) return -1;
return 0;
}
/* operators */
template<>
inline void FP_NR<dd_real>::operator=(const FP_NR<dd_real>& a) {
data = a.data;
}
template<>
inline void FP_NR<dd_real>::operator=(double a) {
data = a;
}
template<>
inline void FP_NR<dd_real>::operator=(const char* s) {
data.read(s, data);
}
template<>
inline bool FP_NR<dd_real>::operator<=(const FP_NR<dd_real>& a) const {
return data <= a.data;
}
template<>
inline bool FP_NR<dd_real>::operator<=(double a) const {
return data <= a;
}
template<>
inline bool FP_NR<dd_real>::operator>=(const FP_NR<dd_real>& a) const {
return data >= a.data;
}
template<>
inline bool FP_NR<dd_real>::operator>=(double a) const {
return data >= a;
}
template<>
inline bool FP_NR<dd_real>::operator<(const FP_NR<dd_real>& a) const {
return data < a.data;
}
template<>
inline bool FP_NR<dd_real>::operator<(double a) const {
return data < a;
}
template<>
inline bool FP_NR<dd_real>::operator>(const FP_NR<dd_real>& a) const {
return data > a.data;
}
template<>
inline bool FP_NR<dd_real>::operator>(double a) const {
return data > a;
}
template<>
inline bool FP_NR<dd_real>::is_zero() const {
return data == 0;
}
template<>
inline int FP_NR<dd_real>::is_nan() const {
return data.isnan();
}
template<>
inline int FP_NR<dd_real>::is_finite() const {
return data.isfinite();
}
/* arithmetic */
template<>
inline void FP_NR<dd_real>::add(const FP_NR<dd_real>& b, const FP_NR<dd_real>& c, mp_rnd_t /*rnd*/) {
data = b.data + c.data;
}
template<>
inline void FP_NR<dd_real>::sub(const FP_NR<dd_real>& b, const FP_NR<dd_real>& c, mp_rnd_t /*rnd*/) {
data = b.data - c.data;
}
template<>
inline void FP_NR<dd_real>::mul(const FP_NR<dd_real>& b, const FP_NR<dd_real>& c, mp_rnd_t /*rnd*/) {
data = b.data * c.data;
}
template<>
inline void FP_NR<dd_real>::mul_d(const FP_NR<dd_real>& b, const double c, mp_rnd_t /*rnd*/) {
data = b.data * c;
}
template<>
inline void FP_NR<dd_real>::mul_2si(const FP_NR<dd_real>& b, long c) {
data = ::ldexp(b.data, static_cast<int>(c));
}
template<>
inline void FP_NR<dd_real>::div(const FP_NR<dd_real>& a, const FP_NR<dd_real>& b, mp_rnd_t rnd) {
data = a.data / b.data;
}
template<>
inline void FP_NR<dd_real>::addmul(const FP_NR<dd_real>& b, const FP_NR<dd_real>& c, mp_rnd_t /*rnd*/) {
data = data + b.data * c.data;
}
template<>
inline void FP_NR<dd_real>::submul(const FP_NR<dd_real>& b, const FP_NR<dd_real>& c, mp_rnd_t /*rnd*/) {
data = data - b.data * c.data;
}
template<>
inline void FP_NR<dd_real>::pow_si(const FP_NR<dd_real>& a, long b, mp_rnd_t /*rnd*/) {
data = ::pow(a.data, static_cast<int>(b));
}
template<>
inline void FP_NR<dd_real>::exponential(const FP_NR<dd_real>& a, mp_rnd_t /*rnd*/) {
data = ::exp(a.data);
}
template<>
inline void FP_NR<dd_real>::log(const FP_NR<dd_real>& a, mp_rnd_t /*rnd*/) {
data = ::log(a.data);
}
template<>
inline void FP_NR<dd_real>::sqrt(const FP_NR<dd_real>& a, mp_rnd_t /*rnd*/) {
data = ::sqrt(a.data);
}
template<>
inline void FP_NR<dd_real>::root(const FP_NR<dd_real>& a, unsigned int k, mp_rnd_t /*rnd*/) {
data = ::nroot(a.data, k);
}
template<>
inline void FP_NR<dd_real>::neg(const FP_NR<dd_real>& b) {
data = -b.data;
}
template<>
inline void FP_NR<dd_real>::abs(const FP_NR<dd_real>& b) {
data = ::abs(b.data);
}
template<>
inline void FP_NR<dd_real>::rnd(const FP_NR<dd_real>& b) {
data = ::nint(b.data);
}
template<>
inline void FP_NR<dd_real>::rnd_we(const FP_NR<dd_real>& b, long expo_add) {
/* double-double has same expo limit as double format*/
if (b.exponent() + expo_add >= numeric_limits<double>::digits)
data = b.data;
else
data = ::ldexp(::nint(::ldexp(b.data, expo_add)), -expo_add);
}
template<>
inline void FP_NR<dd_real>::floor(const FP_NR<dd_real>& b) {
data = ::floor(b.data);
}
template<>
inline void FP_NR<dd_real>::set_nan() {
data = NAN;
}
template<>
inline void FP_NR<dd_real>::swap(FP_NR<dd_real>& a) {
dd_real t = a.data;
a.data = data;
data = t;
}
FPLLL_END_NAMESPACE
#endif
|