]> www.ginac.de Git - cln.git/blobdiff - src/float/transcendental/cl_F_expx.cc
Fix linking problems on some platforms caused by inline/non-inline versions
[cln.git] / src / float / transcendental / cl_F_expx.cc
index 16957230cbcd598a21d2766120b78fc1743b2ce3..19517cdc545721328680d096407bdc30c37aae2a 100644 (file)
@@ -16,8 +16,7 @@
 #include "cl_LF.h"
 #include "cln/integer.h"
 
-#undef MAYBE_INLINE
-#define MAYBE_INLINE inline
+#include "cl_inline.h"
 #include "cl_LF_zerop.cc"
 #include "cl_LF_exponent.cc"
 
@@ -43,24 +42,24 @@ namespace cln {
 const cl_LF expx_naive (const cl_LF& x)
 {
 // Methode:
-// wie oben, mit adaptiver Genauigkeit während der Potenzreihen-Summation.
-       if (zerop(x))
+// wie oben, mit adaptiver Genauigkeit während der Potenzreihen-Summation.
+       if (zerop_inline(x))
                return cl_float(1,x);
-       var uintL actuallen = TheLfloat(x)->len;
+       var uintC actuallen = TheLfloat(x)->len;
        var uintC d = float_digits(x);
-       var sintL e = float_exponent(x);
+       var sintE e = float_exponent_inline(x);
        if (e < -(sintC)d) // e < -d ?
                return cl_float(1,x); // ja -> 1.0 als Ergebnis
  {     Mutable(cl_LF,x);
-       var uintL k = 0; // Rekursionszähler k:=0
+       var uintE k = 0; // Rekursionszähler k:=0
        // Bei e <= -1-limit_slope*floor(sqrt(d)) kann die Potenzreihe
        // angewandt werden. limit_slope = 1.0 ist nicht schlecht,
        // auch im Bereich d = ca. 800.
-       var sintL e_limit = -1-isqrt(d); // -1-floor(sqrt(d))
+       var sintL e_limit = -1-isqrtC(d); // -1-floor(sqrt(d))
        if (e > e_limit) {
-               // e > -1-floor(sqrt(d)) -> muß |x| verkleinern.
+               // e > -1-floor(sqrt(d)) -> muß |x| verkleinern.
                k = e - e_limit;
-               x = scale_float(x,-(sintL)k); // x := x/2^k
+               x = scale_float(x,-(sintE)k); // x := x/2^k
                // Neuer Exponent = e-k = e_limit.
        }
        // Potenzreihe anwenden:
@@ -94,22 +93,22 @@ const cl_F expx_naive (const cl_F& x)
        if (zerop(x))
                return cl_float(1,x);
        var uintC d = float_digits(x);
-       var sintL e = float_exponent(x);
+       var sintE e = float_exponent(x);
        if (e < -(sintC)d) // e < -d ?
                return cl_float(1,x); // ja -> 1.0 als Ergebnis
  {     Mutable(cl_F,x);
-       var uintL k = 0; // Rekursionszähler k:=0
+       var uintE k = 0; // Rekursionszähler k:=0
        // Bei e <= -1-limit_slope*floor(sqrt(d)) kann die Potenzreihe
-       // angewandt werden. limit_slope = 1.0 ist nicht schlecht. Für
+       // angewandt werden. limit_slope = 1.0 ist nicht schlecht. Für
        // d > 1600 scheint der Bereich 2.0 <= limit_slope <= 2.6 am besten
-       // zu sein (mit bis zu 15% Beschleunigung gegenüber limit_slope = 1.0),
+       // zu sein (mit bis zu 15% Beschleunigung gegenüber limit_slope = 1.0),
        // aber in diesem Bereich rechnen wir gar nicht.
-       // Wir wählen limit_slope = 1.5.
-       var sintL e_limit = -1-floor(isqrt(d)*3,2); // -1-floor(sqrt(d))
+       // Wir wählen limit_slope = 1.5.
+       var sintL e_limit = -1-floor(isqrtC(d)*3,2); // -1-floor(sqrt(d))
        if (e > e_limit) {
-               // e > -1-floor(sqrt(d)) -> muß |x| verkleinern.
+               // e > -1-floor(sqrt(d)) -> muß |x| verkleinern.
                k = e - e_limit;
-               x = scale_float(x,-(sintL)k); // x := x/2^k
+               x = scale_float(x,-(sintE)k); // x := x/2^k
                // Neuer Exponent = e-k = e_limit.
        }
        // Potenzreihe anwenden:
@@ -139,7 +138,7 @@ const cl_LF expx_ratseries (const cl_LF& x)
        var uintC len = TheLfloat(x)->len;
        var cl_idecoded_float x_ = integer_decode_float(x);
        // x = (-1)^sign * 2^exponent * mantissa
-       var uintL lq = cl_I_to_UL(- x_.exponent);
+       var uintE lq = cl_I_to_UE(- x_.exponent);
        var const cl_I& p = x_.mantissa;
        // Compute exp(p/2^lq) by splitting into pieces.
        // Each piece gives rise to a factor exp(pk/2^lqk).
@@ -151,14 +150,14 @@ const cl_LF expx_ratseries (const cl_LF& x)
        //  (b) 311 317 305 312 295 291 286 293 291 284 295 284 293 287 288 305
        // (a): N=300, time in 0.01 sec. (b): N=1000, time in 0.1 sec.
        // Values 2.5 <= c <= 3.2 seem best. Let's choose c = 2.875.
-       var cl_boolean first_factor = cl_true;
+       var bool first_factor = true;
        var cl_LF product;
-       var uintL b1;
-       var uintL b2;
+       var uintE b1;
+       var uintE b2;
        for (b1 = 0, b2 = 1; b1 < lq; b1 = b2, b2 = ceiling(b2*23,8)) {
                // Piece containing bits b1+1..b2 after "decimal point"
                // in the binary representation of (p/2^lq).
-               var uintL lqk = (lq >= b2 ? b2 : lq);
+               var uintE lqk = (lq >= b2 ? b2 : lq);
                var cl_I pk = ldb(p,cl_byte(lqk-b1,lq-lqk));
                // Compute exp(pk/2^lqk).
                if (!zerop(pk)) {
@@ -166,7 +165,7 @@ const cl_LF expx_ratseries (const cl_LF& x)
                        var cl_LF factor = cl_exp_aux(pk,lqk,len);
                        if (first_factor) {
                                product = factor;
-                               first_factor = cl_false;
+                               first_factor = false;
                        } else
                                product = product * factor;
                }