4 #include "base/cl_sysdep.h"
7 #include "float/lfloat/cl_LF.h"
12 #include "cln/lfloat.h"
13 #include "rational/cl_RA.h"
17 const cl_R cl_LF_RA_mul (const cl_LF& x, const cl_RA& y)
20 // Write y = u/v. Return (x*u)/v.
23 return cl_LF_I_mul(x,y);
26 var const cl_I& u = TheRatio(y)->numerator; // u /= 0
27 var const cl_I& v = TheRatio(y)->denominator; // v /= 0
28 return cl_LF_I_div(The(cl_LF)(cl_LF_I_mul(x,u)),v);
32 // Timings on an i486 33 MHz, running Linux, in 0.01 sec.
33 // First timing: (x*u)/v, using cl_LF_I_mul and cl_LF_I_div
34 // Second timing: x*(u/v), using cl_RA_to_LF and operator*
35 // with x_length = 100.
36 // num_length 50 70 100 200 500
39 // 50 1.59 1.92 1.76 1.92 1.89 1.92 1.90 2.78 1.93 8.07
41 // 70 1.93 2.26 2.14 2.25 2.25 2.25 2.27 2.78 2.25 8.07
43 // 100 2.44 2.77 2.65 2.77 2.79 2.80 2.80 2.81 2.80 8.05
45 // 200 2.46 4.53 2.65 4.54 2.78 4.55 2.79 4.55 2.77 8.05
47 // 500 2.45 8.38 2.65 8.50 2.76 8.49 2.79 8.52 2.81 8.55
49 // We see that the first approach is always better than the second, except if
50 // den_length = x_length && x_length <= num_length <= 2*x_length
51 // when both are equally fast.