lustrec / include / mpfr_lustre.c @ 8d164031
History  View  Annotate  Download (6.23 KB)
1 
#include <mpfr.h> 

2 
#include "mpfr_lustre.h" 
3  
4 
void MPFR_LUSTRE_INIT () {

5 
return;

6 
} 
7  
8 
void MPFR_LUSTRE_CLEAR () {

9 
return;

10 
} 
11  
12 
void MPFRNeq_step (mpfr_t i1, mpfr_t i2,

13 
_Bool (*out) 
14 
) 
15 
{ 
16 
*out = mpfr_lessgreater_p(i1, i2); 
17 
} 
18  
19 
void MPFREq_step (mpfr_t i1, mpfr_t i2,

20 
_Bool (*out) 
21 
) 
22 
{ 
23 
*out = mpfr_equal_p(i1, i2); 
24 
} 
25  
26 
void MPFRGt_step (mpfr_t i1, mpfr_t i2,

27 
_Bool (*out) 
28 
) 
29 
{ 
30 
*out = mpfr_greater_p(i1, i2); 
31 
} 
32  
33 
void MPFRGe_step (mpfr_t i1, mpfr_t i2,

34 
_Bool (*out) 
35 
) 
36 
{ 
37 
*out = mpfr_greaterequal_p(i1, i2); 
38 
} 
39  
40 
extern void MPFRLt_step (mpfr_t i1, mpfr_t i2, 
41 
_Bool (*out) 
42 
) 
43 
{ 
44 
*out = mpfr_less_p(i1, i2); 
45 
} 
46 
void MPFRLe_step (mpfr_t i1, mpfr_t i2,

47 
_Bool (*out) 
48 
) 
49 
{ 
50 
*out = mpfr_lessequal_p(i1, i2); 
51 
} 
52  
53 
void MPFRDiv_step (mpfr_t i1, mpfr_t i2,

54 
mpfr_t out 
55 
) 
56 
{ 
57 
mpfr_div(out, i1, i2, MPFR_RNDN); 
58 
} 
59  
60 
void MPFRTimes_step (mpfr_t i1, mpfr_t i2,

61 
mpfr_t out 
62 
) 
63 
{ 
64 
mpfr_mul(out, i1, i2, MPFR_RNDN); 
65 
} 
66  
67 
void MPFRMinus_step (mpfr_t i1, mpfr_t i2,

68 
mpfr_t out 
69 
) 
70 
{ 
71 
mpfr_sub(out, i1, i2, MPFR_RNDN); 
72 
} 
73  
74 
void MPFRPlus_step (mpfr_t i1, mpfr_t i2,

75 
mpfr_t out 
76 
) 
77 
{ 
78 
mpfr_add(out, i1, i2, MPFR_RNDN); 
79 
} 
80  
81 
void MPFRUminus_step (mpfr_t i,

82 
mpfr_t out 
83 
) 
84 
{ 
85 
mpfr_neg(out, i, MPFR_RNDN); 
86 
} 
87  
88 
void MPFRInit(mpfr_t i, mpfr_prec_t prec)

89 
{ 
90 
mpfr_init2(i, prec); 
91 
} 
92  
93 
void MPFRClear(mpfr_t i)

94 
{ 
95 
mpfr_clear(i); 
96 
} 
97  
98 
// functions of conv

99  
100 
void MPFRint_to_real_step (int i, mpfr_t out) 
101 
{ 
102 
mpfr_set_si(out, i, MPFR_RNDN); 
103 
} 
104  
105 
void MPFRreal_to_int_step (mpfr_t in1, int *out) 
106 
{ 
107 
*out = mpfr_get_sj (in1, MPFR_RNDN); 
108 
} 
109  
110 
void MPFRFloor (mpfr_t in1, int *out) 
111 
{ 
112 
mpfr_t tmp; 
113 
int prec;

114 
mpfr_init (tmp); // would be better to avoid local init

115 
prec = mpfr_get_prec (in1); 
116 
mpfr_set_prec(tmp, prec); 
117  
118 
mpfr_floor(tmp, in1); 
119 
*out = mpfr_get_sj (tmp, MPFR_RNDN); 
120  
121 
mpfr_clear(tmp); 
122 
} 
123  
124 
void MPFRCeiling (mpfr_t in1, int *out) 
125 
{ 
126 
mpfr_t tmp; 
127 
int prec;

128 
mpfr_init (tmp); // would be better to avoid local init

129 
prec = mpfr_get_prec (in1); 
130 
mpfr_set_prec(tmp, prec); 
131 

132 
mpfr_ceil(tmp, in1); 
133 
*out = mpfr_get_sj (tmp, MPFR_RNDN); 
134  
135 
mpfr_clear(tmp); 
136 
} 
137  
138 
void MPFRRound (mpfr_t in1, int *out) 
139 
{ 
140 
mpfr_t tmp; 
141 
int prec;

142 
mpfr_init (tmp); // would be better to avoid local init

143 
prec = mpfr_get_prec (in1); 
144 
mpfr_set_prec(tmp, prec); 
145 

146 
mpfr_round(tmp, in1); 
147 
*out = mpfr_get_sj (tmp, MPFR_RNDN); 
148  
149 
mpfr_clear(tmp); 
150 
} 
151  
152 
// functions of lustrec_math

153 
void MPFRacos_step (mpfr_t i,

154 
mpfr_t out 
155 
) 
156 
{ 
157 
mpfr_acos(out, i, MPFR_RNDN); 
158 
} 
159  
160 
void MPFRacosh_step (mpfr_t i,

161 
mpfr_t out 
162 
) 
163 
{ 
164 
mpfr_acosh(out, i, MPFR_RNDN); 
165 
} 
166 
void MPFRasin_step (mpfr_t i,

167 
mpfr_t out 
168 
) 
169 
{ 
170 
mpfr_asin(out, i, MPFR_RNDN); 
171 
} 
172 
void MPFRasinh_step (mpfr_t i,

173 
mpfr_t out 
174 
) 
175 
{ 
176 
mpfr_asinh(out, i, MPFR_RNDN); 
177 
} 
178 
void MPFRatan_step (mpfr_t i,

179 
mpfr_t out 
180 
) 
181 
{ 
182 
mpfr_atan(out, i, MPFR_RNDN); 
183 
} 
184  
185 
void MPFRatan2_step (mpfr_t y, mpfr_t x,

186 
mpfr_t out 
187 
) 
188 
{ 
189 
mpfr_atan2(out, y, x, MPFR_RNDN); 
190 
} 
191  
192 
void MPFRatanh_step (mpfr_t i,

193 
mpfr_t out 
194 
) 
195 
{ 
196 
mpfr_atanh(out, i, MPFR_RNDN); 
197 
} 
198 
void MPFRcbrt_step (mpfr_t i,

199 
mpfr_t out 
200 
) 
201 
{ 
202 
mpfr_cbrt(out, i, MPFR_RNDN); 
203 
} 
204  
205 
void MPFRcos_step (mpfr_t i,

206 
mpfr_t out 
207 
) 
208 
{ 
209 
mpfr_cos(out, i, MPFR_RNDN); 
210 
} 
211  
212 
void MPFRcosh_step (mpfr_t i,

213 
mpfr_t out 
214 
) 
215 
{ 
216 
mpfr_cosh(out, i, MPFR_RNDN); 
217 
} 
218  
219 
void MPFRceil_step (mpfr_t i,

220 
mpfr_t out 
221 
) 
222 
{ 
223 
mpfr_ceil(out, i); 
224 
} 
225  
226 
void MPFRerf_step (mpfr_t i,

227 
mpfr_t out 
228 
) 
229 
{ 
230 
mpfr_erf(out, i, MPFR_RNDN); 
231 
} 
232  
233 
void MPFRexp_step (mpfr_t i,

234 
mpfr_t out 
235 
) 
236 
{ 
237 
mpfr_exp(out, i, MPFR_RNDN); 
238 
} 
239  
240 
void MPFRfabs_step (mpfr_t i,

241 
mpfr_t out 
242 
) 
243 
{ 
244 
mpfr_abs(out, i, MPFR_RNDN); 
245 
} 
246  
247 
void MPFRfloor_step (mpfr_t i,

248 
mpfr_t out 
249 
) 
250 
{ 
251 
mpfr_floor(out, i); 
252 
} 
253  
254 
void MPFRfmod_step (mpfr_t i1, mpfr_t i2,

255 
mpfr_t out 
256 
) 
257 
{ 
258 
mpfr_fmod(out, i1, i2, MPFR_RNDN); 
259 
} 
260  
261 
void MPFRlog_step (mpfr_t i,

262 
mpfr_t out 
263 
) 
264 
{ 
265 
mpfr_log(out, i, MPFR_RNDN); 
266 
} 
267  
268 
void MPFRlog10_step (mpfr_t i,

269 
mpfr_t out 
270 
) 
271 
{ 
272 
mpfr_log10(out, i, MPFR_RNDN); 
273 
} 
274  
275 
void MPFRpow_step (mpfr_t i1, mpfr_t i2,

276 
mpfr_t out 
277 
) 
278 
{ 
279 
mpfr_pow(out, i1, i2, MPFR_RNDN); 
280 
} 
281  
282 
void MPFRround_step (mpfr_t i,

283 
mpfr_t out 
284 
) 
285 
{ 
286 
mpfr_round(out, i); 
287 
} 
288  
289 
void MPFRsin_step (mpfr_t i,

290 
mpfr_t out 
291 
) 
292 
{ 
293 
mpfr_sin(out, i, MPFR_RNDN); 
294 
} 
295  
296 
void MPFRsinh_step (mpfr_t i,

297 
mpfr_t out 
298 
) 
299 
{ 
300 
mpfr_sinh(out, i, MPFR_RNDN); 
301 
} 
302  
303 
void MPFRsqrt_step (mpfr_t i,

304 
mpfr_t out 
305 
) 
306 
{ 
307 
mpfr_sqrt(out, i, MPFR_RNDN); 
308 
} 
309  
310 
void MPFRtrunc_step (mpfr_t i,

311 
mpfr_t out 
312 
) 
313 
{ 
314 
mpfr_trunc(out, i); 
315 
} 
316  
317 
void MPFRtan_step (mpfr_t i,

318 
mpfr_t out 
319 
) 
320 
{ 
321 
mpfr_tan(out, i, MPFR_RNDN); 
322 
} 