Project

General

Profile

Revision d948c0bd

View differences:

include/mpfr_lustre.c
94 94
{
95 95
  mpfr_clear(i);
96 96
}
97

  
98
// functions of lustrec_math
99
void MPFRacos_step (mpfr_t i, 
100
                             mpfr_t out
101
                             )
102
{
103
  mpfr_acos(out, i, MPFR_RNDN);
104
}
105

  
106
void MPFRacosh_step (mpfr_t i, 
107
                             mpfr_t out
108
                             )
109
{
110
  mpfr_acosh(out, i, MPFR_RNDN);
111
}
112
void MPFRasin_step (mpfr_t i, 
113
                             mpfr_t out
114
                             )
115
{
116
  mpfr_asin(out, i, MPFR_RNDN);
117
}
118
void MPFRasinh_step (mpfr_t i, 
119
                             mpfr_t out
120
                             )
121
{
122
  mpfr_asinh(out, i, MPFR_RNDN);
123
}
124
void MPFRatan_step (mpfr_t i, 
125
                             mpfr_t out
126
                             )
127
{
128
  mpfr_atan(out, i, MPFR_RNDN);
129
}
130

  
131
void MPFRatan2_step (mpfr_t y, mpfr_t x, 
132
                           mpfr_t out
133
                           )
134
{
135
  mpfr_atan2(out, y, x, MPFR_RNDN);
136
}
137

  
138
void MPFRatanh_step (mpfr_t i, 
139
                             mpfr_t out
140
                             )
141
{
142
  mpfr_atanh(out, i, MPFR_RNDN);
143
}
144
void MPFRcbrt_step (mpfr_t i, 
145
                             mpfr_t out
146
                             )
147
{
148
  mpfr_cbrt(out, i, MPFR_RNDN);
149
}
150

  
151
void MPFRcos_step (mpfr_t i, 
152
                             mpfr_t out
153
                             )
154
{
155
  mpfr_cos(out, i, MPFR_RNDN);
156
}
157

  
158
void MPFRcosh_step (mpfr_t i, 
159
                             mpfr_t out
160
                             )
161
{
162
  mpfr_cosh(out, i, MPFR_RNDN);
163
}
164

  
165
void MPFRceil_step (mpfr_t i, 
166
                             mpfr_t out
167
                             )
168
{
169
  mpfr_ceil(out, i);
170
}
171

  
172
void MPFRerf_step (mpfr_t i, 
173
                             mpfr_t out
174
                             )
175
{
176
  mpfr_erf(out, i, MPFR_RNDN);
177
}
178

  
179
void MPFRexp_step (mpfr_t i, 
180
                             mpfr_t out
181
                             )
182
{
183
  mpfr_exp(out, i, MPFR_RNDN);
184
}
185

  
186
void MPFRfabs_step (mpfr_t i, 
187
                             mpfr_t out
188
                             )
189
{
190
  mpfr_abs(out, i, MPFR_RNDN);
191
}
192

  
193
void MPFRfloor_step (mpfr_t i, 
194
                             mpfr_t out
195
                             )
196
{
197
  mpfr_floor(out, i);
198
}
199

  
200
void MPFRfmod_step (mpfr_t i1, mpfr_t i2, 
201
                           mpfr_t out
202
                           )
203
{
204
  mpfr_fmod(out, i1, i2, MPFR_RNDN);
205
}
206

  
207
void MPFRlog_step (mpfr_t i, 
208
                             mpfr_t out
209
                             )
210
{
211
  mpfr_log(out, i, MPFR_RNDN);
212
}
213

  
214
void MPFRlog10_step (mpfr_t i, 
215
                             mpfr_t out
216
                             )
217
{
218
  mpfr_log10(out, i, MPFR_RNDN);
219
}
220

  
221
void MPFRpow_step (mpfr_t i1, mpfr_t i2, 
222
                           mpfr_t out
223
                           )
224
{
225
  mpfr_pow(out, i1, i2, MPFR_RNDN);
226
}
227

  
228
void MPFRround_step (mpfr_t i, 
229
                             mpfr_t out
230
                             )
231
{
232
  mpfr_round(out, i);
233
}
234

  
235
void MPFRsin_step (mpfr_t i, 
236
                             mpfr_t out
237
                             )
238
{
239
  mpfr_sin(out, i, MPFR_RNDN);
240
}
241

  
242
void MPFRsinh_step (mpfr_t i, 
243
                             mpfr_t out
244
                             )
245
{
246
  mpfr_sinh(out, i, MPFR_RNDN);
247
}
248

  
249
void MPFRsqrt_step (mpfr_t i, 
250
                             mpfr_t out
251
                             )
252
{
253
  mpfr_sqrt(out, i, MPFR_RNDN);
254
}
255

  
256
void MPFRtrunc_step (mpfr_t i, 
257
                             mpfr_t out
258
                             )
259
{
260
  mpfr_trunc(out, i);
261
}
262

  
263
void MPFRtan_step (mpfr_t i, 
264
                             mpfr_t out
265
                             )
266
{
267
  mpfr_tan(out, i, MPFR_RNDN);
268
}
include/mpfr_lustre.lusi
1

  
2

  
3 1
function MPFRUminus(i: real) returns (out: real) lib gmp lib mpfr;
4 2

  
5 3
function MPFRPlus(i1, i2: real) returns (out: real);
......
21 19
function MPFREq(i1, i2: real) returns (out: bool);
22 20

  
23 21
function MPFRNeq(i1, i2: real) returns (out: bool);
22

  
23
-- Functions already available in lustrec_math
24

  
25
function MPFRacos (x: real) returns (y: real) ;
26
function MPFRacosh (x: real) returns (y: real) ;
27
function MPFRasin (x: real) returns (y: real) ;
28
function MPFRasinh (x: real) returns (y: real) ;
29
function MPFRatan (x: real) returns (y: real) ;
30
function MPFRatan2(x:real; n: real) returns (y: real) ;
31
function MPFRatanh (x: real) returns (y: real) ;
32
function MPFRcbrt (x: real) returns (y: real) ;
33
function MPFRcos (x: real) returns (y: real) ;
34
function MPFRcosh (x: real) returns (y: real) ;
35
function MPFRceil (x: real) returns (y: real) ;
36
function MPFRerf (x: real) returns (y: real) ;
37
function MPFRexp (x: real) returns (y: real) ;
38
function MPFRfabs (x: real) returns (y: real) ;
39
function MPFRfloor (x: real) returns (y: real) ;
40
function MPFRfmod (x,y: real) returns (z: real) ;
41
function MPFRlog (x: real) returns (y: real) ;
42
function MPFRlog10 (x: real) returns (y: real) ;
43
function MPFRpow (x:real; n: real) returns (y: real) ;
44
function MPFRround (x: real) returns (y: real) ;
45
function MPFRsin (x: real) returns (y: real) ;
46
function MPFRsinh (x: real) returns (y: real) ;
47
function MPFRsqrt (x: real) returns (y: real) ;
48
function MPFRtrunc (x: real) returns (y: real) ;
49
function MPFRtan (x: real) returns (y: real) ;
src/backends/C/c_backend_src.ml
347 347
  | MStep ([i0], i, vl) when Basic_library.is_value_internal_fun (mk_val (Fun (i, vl)) i0.var_type)  ->
348 348
    pp_machine_instr dependencies m self fmt 
349 349
      (update_instr_desc instr (MLocalAssign (i0, mk_val (Fun (i, vl)) i0.var_type)))
350
  | MStep (il, i, vl) when !Options.mpfr && Mpfr.is_homomorphic_fun i ->
351
     pp_instance_call m self fmt i vl il
350 352
  | MStep ([i0], i, vl) when has_c_prototype i dependencies -> 
351 353
    fprintf fmt "%a = %s(%a);" 
352 354
      (pp_c_val m self (pp_c_var_read m)) (mk_val (Var i0) i0.var_type)
353 355
      i
354 356
      (Utils.fprintf_list ~sep:", " (pp_c_val m self (pp_c_var_read m))) vl
355
  | MStep (il, i, vl) when Mpfr.is_homomorphic_fun i ->
356
    pp_instance_call m self fmt i vl il
357 357
  | MStep (il, i, vl) ->
358 358
    pp_basic_instance_call m self fmt i vl il
359 359
  | MBranch (_, []) -> (Format.eprintf "internal error: C_backend_src.pp_machine_instr %a@." (pp_instr m) instr; assert false)
src/plugins/mpfr/mpfr.ml
97 97
  | ">"      -> "MPFRGt"
98 98
  | "="      -> "MPFREq"
99 99
  | "!="     -> "MPFRNeq"
100
  (* Math library functions *)
101
  | "acos" -> "MPFRacos"
102
  | "acosh" -> "MPFRacosh"
103
  | "asin" -> "MPFRasin"
104
  | "asinh" -> "MPFRasinh"
105
  | "atan" -> "MPFRatan"
106
  | "atan2" -> "MPFRatan2"
107
  | "atanh" -> "MPFRatanh"
108
  | "cbrt" -> "MPFRcbrt"
109
  | "cos" -> "MPFRcos"
110
  | "cosh" -> "MPFRcosh"
111
  | "ceil" -> "MPFRceil"
112
  | "erf" -> "MPFRerf"
113
  | "exp" -> "MPFRexp"
114
  | "fabs" -> "MPFRfabs"
115
  | "floor" -> "MPFRfloor"
116
  | "fmod" -> "MPFRfmod"
117
  | "log" -> "MPFRlog"
118
  | "log10" -> "MPFRlog10"
119
  | "pow" -> "MPFRpow"
120
  | "round" -> "MPFRround"
121
  | "sin" -> "MPFRsin"
122
  | "sinh" -> "MPFRsinh"
123
  | "sqrt" -> "MPFRsqrt"
124
  | "trunc" -> "MPFRtrunc"
125
  | "tan" -> "MPFRtan"
126

  
127
           
128
  | "pow"    -> "MPFRpow"
100 129
  | _        -> raise Not_found
101 130

  
102 131
let inject_op id =
132
  Format.eprintf "trying to inject mpfr into function %s@." id;
103 133
  try
104 134
    base_inject_op id
105 135
  with Not_found -> id

Also available in: Unified diff