12 #include "cln/lfloat.h"
17 const cl_R cl_RA_LF_div (const cl_RA& x, const cl_LF& y)
20 // Write x = u/v. Return u/(v*y).
23 return cl_I_LF_div(x,y);
26 var const cl_I& u = TheRatio(x)->numerator;
27 var const cl_I& v = TheRatio(x)->denominator; // v /= 0
28 return cl_I_LF_div(u,The(cl_LF)(cl_LF_I_mul(y,v)));
32 // Timings on an i486 33 MHz, running Linux.
33 // First timing: u/(v*y), using cl_LF_I_mul and cl_LF_I_div
34 // Second timing: (u/v)/y, using cl_RA_to_LF and operator/
35 // With x_length = 100, in 0.01 sec.
36 // num_length 50 70 100 200 500
39 // 50 0.82 0.98 1.38 1.61 2.48 2.80 8.37 9.05 46.92 48.59
41 // 70 0.81 1.16 1.43 1.85 2.65 3.18 8.64 9.76 47.53 50.34
43 // 100 0.82 1.43 1.44 2.24 2.79 3.69 8.98 10.77 48.42 52.81
45 // 200 0.80 2.31 1.43 3.44 2.78 5.43 9.93 14.31 51.08 61.57
47 // 500 0.82 4.62 1.44 6.21 2.76 9.40 9.97 22.66 55.52 87.71
49 // With x_length = 1000, in sec.
50 // num_length 500 700 1000 2000 5000
53 // 500 0.55 0.88 0.96 1.39 1.60 2.24 4.35 5.60 10.83 14.18
55 // 700 0.55 0.95 0.98 1.57 1.65 2.58 4.47 6.34 10.61 15.88
57 // 1000 0.56 1.00 0.98 1.67 1.69 2.70 4.61 7.13 10.65 16.29
59 // 2000 0.56 1.25 0.98 1.97 1.69 3.05 4.88 7.74 10.75 17.03
61 // 5000 0.55 1.94 0.98 2.30 1.70 3.33 4.90 7.74 11.94 19.29
63 // We see that the first approach is always better than the second.