]> www.ginac.de Git - cln.git/commitdiff
* include/cln/integer.h (cl_I_to_E, cl_I_to_UE): New functions.
authorRichard Kreckel <kreckel@ginac.de>
Thu, 31 May 2007 20:22:13 +0000 (20:22 +0000)
committerRichard Kreckel <kreckel@ginac.de>
Thu, 31 May 2007 20:22:13 +0000 (20:22 +0000)
        * src/float/transcendental/cl_LF_exp_aux.cc: Make lq argument an uintE.
        * src/float/transcendental/cl_LF_cossin_aux.cc: Likewise.
        * src/float/transcendental/cl_LF_coshsinh_aux.cc: Likewise.
        * src/float/transcendental/cl_F_tran.h: Change declaration of lq.
        * src/float/transcendental/cl_F_lnx.cc: Fix some exponent types.
        * src/float/transcendental/cl_F_expx.cc: Likewise.
        * src/float/transcendental/cl_F_sinh.cc: Likewise.
        * src/float/transcendental/cl_F_atanx.cc: Likewise.
        * src/float/transcendental/cl_F_coshsinh.cc: Likewise.
        * src/float/transcendental/cl_LF_cossin.cc: Likewise.
        * src/float/transcendental/cl_LF_coshsinh.cc: Likewise.

13 files changed:
ChangeLog
include/cln/integer.h
src/float/transcendental/cl_F_atanx.cc
src/float/transcendental/cl_F_coshsinh.cc
src/float/transcendental/cl_F_expx.cc
src/float/transcendental/cl_F_lnx.cc
src/float/transcendental/cl_F_sinh.cc
src/float/transcendental/cl_F_tran.h
src/float/transcendental/cl_LF_coshsinh.cc
src/float/transcendental/cl_LF_coshsinh_aux.cc
src/float/transcendental/cl_LF_cossin.cc
src/float/transcendental/cl_LF_cossin_aux.cc
src/float/transcendental/cl_LF_exp_aux.cc

index f00389ecbd458290aa01c6b9ef604769a7153127..e1c81e84b064517e3115c8d7a8975abc93058c7f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-05-31  Richard B. Kreckel  <kreckel@ginac.de>
+
+       * include/cln/integer.h (cl_I_to_E, cl_I_to_UE): New functions.
+       * src/float/transcendental/cl_LF_exp_aux.cc: Make lq argument an uintE.
+       * src/float/transcendental/cl_LF_cossin_aux.cc: Likewise.
+       * src/float/transcendental/cl_LF_coshsinh_aux.cc: Likewise.
+       * src/float/transcendental/cl_F_tran.h: Change declaration of lq.
+       * src/float/transcendental/cl_F_lnx.cc: Fix some exponent types.
+       * src/float/transcendental/cl_F_expx.cc: Likewise.
+       * src/float/transcendental/cl_F_sinh.cc: Likewise.
+       * src/float/transcendental/cl_F_atanx.cc: Likewise.
+       * src/float/transcendental/cl_F_coshsinh.cc: Likewise.
+       * src/float/transcendental/cl_LF_cossin.cc: Likewise.
+       * src/float/transcendental/cl_LF_coshsinh.cc: Likewise.
+
 2007-04-09  Richard B. Kreckel  <kreckel@ginac.de>
 
        More memory efficient constants:
index 14012c55846b9f6a2f0d1406c99bd1512729beba..28d51648802c5d25d0374632b5ecb231b613a510 100644 (file)
@@ -32,17 +32,22 @@ CL_DEFINE_AS_CONVERSION(cl_I)
   inline unsigned int cl_I_to_uint (const cl_I& x) { return cl_I_to_UL(x); }
 #endif
 
+// Convert an integer to a 64-bit 'quad' type.
+#ifdef intQsize
+ extern uint64 cl_I_to_UQ (const cl_I& obj);
+ extern sint64 cl_I_to_Q (const cl_I& obj);
+#endif
+
 // Convert an integer to a C `long' or `unsigned long'.
 #if (long_bitsize==32)
   inline long          cl_I_to_long  (const cl_I& x) { return cl_I_to_L(x);  }
   inline unsigned long cl_I_to_ulong (const cl_I& x) { return cl_I_to_UL(x); }
 #elif (long_bitsize==64)
-  extern uint64 cl_I_to_UQ (const cl_I& obj);
-  extern sint64 cl_I_to_Q (const cl_I& obj);
   inline long          cl_I_to_long  (const cl_I& x) { return cl_I_to_Q(x);  }
   inline unsigned long cl_I_to_ulong (const cl_I& x) { return cl_I_to_UQ(x); }
 #endif
 
+// Convert an integer to a counter type.
 #if (intCsize==long_bitsize)
   inline uintC cl_I_to_UC (const cl_I& x) { return cl_I_to_ulong(x); }
   inline sintC cl_I_to_C  (const cl_I& x) { return cl_I_to_long(x);  }
@@ -51,6 +56,15 @@ CL_DEFINE_AS_CONVERSION(cl_I)
   inline sintC cl_I_to_C  (const cl_I& x) { return cl_I_to_int(x);  }
 #endif
 
+// Convert an integer to an exponent type.
+#if (intEsize==intLsize)
+  inline uintE cl_I_to_UE (const cl_I& x) { return cl_I_to_UL(x); }
+  inline sintE cl_I_to_E  (const cl_I& x) { return cl_I_to_L(x);  }
+#elif (intEsize==intQsize)
+  inline uintE cl_I_to_UE (const cl_I& x) { return cl_I_to_UQ(x); }
+  inline sintE cl_I_to_E  (const cl_I& x) { return cl_I_to_Q(x);  }
+#endif
+
 
 // Logische Operationen auf Integers:
 
index b6708539dff638002c733a549301707f96ec567d..38fd1098cdbb3a692166f4b238bf4d0bd09f06dc 100644 (file)
@@ -195,15 +195,15 @@ static const cl_LF atanx_ratseries (const cl_LF& t)
                var cl_idecoded_float y_ = integer_decode_float(y);
                // y = (-1)^sign * 2^exponent * mantissa
                var uintC lm = integer_length(y_.mantissa);
-               var uintL me = cl_I_to_UL(- y_.exponent);
+               var uintE me = cl_I_to_UE(- y_.exponent);
                var cl_I p;
-               var uintC lq;
+               var uintE lq;
                var cl_boolean last_step = cl_false;
                if (lm >= me) { // |y| >= 1/2 ?
                        p = y_.sign; // 1 or -1
                        lq = 1;
                } else {
-                       var uintL n = me - lm; // |y| < 2^-n with n maximal
+                       var uintE n = me - lm; // |y| < 2^-n with n maximal
                        // Set p to the first n bits of |y|:
                        if (lm > n) {
                                p = y_.mantissa >> (lm - n);
@@ -221,7 +221,7 @@ static const cl_LF atanx_ratseries (const cl_LF& t)
                        if (2*n >= lm)
                                last_step = cl_true;
                }
-               z = z + scale_float(cl_I_to_LF(p,len),-(sintC)lq);
+               z = z + scale_float(cl_I_to_LF(p,len),-(sintE)lq);
                if (last_step)
                        break;
                var cl_LF_cos_sin_t cis_z = cl_cossin_aux(-p,lq,len);
index 78882853ad5a86abd2e1733c942e1094df895648..55b90871a9792f63bc4b3dbcfd58b7f41ad1c52a 100644 (file)
@@ -33,7 +33,7 @@ const cosh_sinh_t cosh_sinh (const cl_F& x)
 //   (scale-float (+ y (/ y)) -1) und (scale-float (- y (/ y)) -1) bilden.
 // Genauigkeit wieder verringern.
 
-       var sintL e = float_exponent(x);
+       var sintE e = float_exponent(x);
        if (e < 0) { // Exponent e abtesten
                // e<0
                if (zerop(x) || (e <= (1-(sintC)float_digits(x))>>1))
@@ -54,7 +54,7 @@ const cosh_sinh_t cosh_sinh (const cl_F& x)
                        #endif
                        if (TheLfloat(x)->len >= 585) {
                                // verwende exp(x), schneller als cl_coshsinh_ratseries
-                               var cl_LF xx = extend(x,TheLfloat(x)->len+ceiling((uintL)(-e),intDsize));
+                               var cl_LF xx = extend(x,TheLfloat(x)->len+ceiling((uintE)(-e),intDsize));
                                var cl_F y = exp(xx);
                                var cl_F y_inv = recip(y);
                                return cosh_sinh_t(
index c7956a3de631af527514a64a5d8dba77d37215fe..3f3dfec786edf3a63305cd5159653fa50ce2f697 100644 (file)
@@ -139,7 +139,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).
@@ -153,12 +153,12 @@ const cl_LF expx_ratseries (const cl_LF& x)
        // Values 2.5 <= c <= 3.2 seem best. Let's choose c = 2.875.
        var cl_boolean first_factor = cl_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)) {
index e6b2ea720b4ed61a3c36ea6058abaed3bff01a1f..b00a5d1965010d664da56f5a18e91dec0a86d2f0 100644 (file)
@@ -201,15 +201,15 @@ const cl_LF lnx_ratseries (const cl_LF& x)
                if (zerop(x1_.mantissa))
                        break;
                var uintC lm = integer_length(x1_.mantissa);
-               var uintL me = cl_I_to_UL(- x1_.exponent);
+               var uintE me = cl_I_to_UE(- x1_.exponent);
                var cl_I p;
-               var uintC lq;
+               var uintE lq;
                var cl_boolean last_step = cl_false;
                if (lm >= me) { // |x'| >= 1/2 ?
                        p = x1_.sign; // 1 or -1
                        lq = 1;
                } else {
-                       var uintL n = me - lm; // |x'| < 2^-n with n maximal
+                       var uintE n = me - lm; // |x'| < 2^-n with n maximal
                        // Set p to the first n bits of |x'|:
                        if (lm > n) {
                                p = x1_.mantissa >> (lm - n);
@@ -227,7 +227,7 @@ const cl_LF lnx_ratseries (const cl_LF& x)
                        if (2*n >= lm)
                                last_step = cl_true;
                }
-               y = y + scale_float(cl_I_to_LF(p,len),-(sintC)lq);
+               y = y + scale_float(cl_I_to_LF(p,len),-(sintE)lq);
                if (last_step)
                        break;
                x = x * cl_exp_aux(-p,lq,len);
index b1f0bfcece3aeec95d0c658f0eff8e3273263b13..21d37db255c35fa7f3dc9b77620ef46cb1f76580 100644 (file)
@@ -41,7 +41,7 @@ const cl_F sinh (const cl_F& x)
                                // verwende exp(x), schneller als cl_coshsinh_ratseries
                                // (aber nur bei 0 > e > -d/2, denn wir müssen, um
                                // Auslöschung zu verhindern, |e| Bits dazunehmen)
-                               var cl_LF xx = extend(x,TheLfloat(x)->len+ceiling((uintL)(-float_exponent(x)),intDsize));
+                               var cl_LF xx = extend(x,TheLfloat(x)->len+ceiling((uintE)(-float_exponent(x)),intDsize));
                                var cl_F y = exp(xx);
                                var cl_F z = scale_float(y - recip(y), -1); // (/ (- y (/ y)) 2)
                                return cl_float(z,x);
index 739226b47a5a2a898b31b6823c9e9bb7660df12d..29a7a87c14343ec5c5a264b92358e1381cb74156 100644 (file)
@@ -19,7 +19,7 @@ extern const cl_LF pi (uintC len); // computes it even further
 // cl_exp_aux(p,lq,len) liefert die Zahl exp(p/2^lq) mit len Digits.
 // 0 < |p| < 2^lq.
 // Es sollte |p|^2 < 2^lq sein, sonst ist das nicht effizient.
-extern const cl_LF cl_exp_aux (const cl_I& p, uintC lq, uintC len);
+extern const cl_LF cl_exp_aux (const cl_I& p, uintE lq, uintC len);
 
 // cl_cossin_aux(p,lq,len) liefert cos(p/2^lq) und sin(p/2^lq) mit len Digits.
 // 0 < |p| < 2^lq.
@@ -31,7 +31,7 @@ struct cl_LF_cos_sin_t {
        cl_LF_cos_sin_t (const cl_LF& u, const cl_LF& v) : cos (u), sin (v) {}
        cl_LF_cos_sin_t () {}
 };
-extern const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintC lq, uintC len);
+extern const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintE lq, uintC len);
 
 // cl_coshsinh_aux(p,lq,len) liefert cosh(p/2^lq) und sinh(p/2^lq) mit len Digits.
 // 0 < |p| < 2^lq.
@@ -43,7 +43,7 @@ struct cl_LF_cosh_sinh_t {
        cl_LF_cosh_sinh_t (const cl_LF& u, const cl_LF& v) : cosh (u), sinh (v) {}
        cl_LF_cosh_sinh_t () {}
 };
-extern const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintC lq, uintC len);
+extern const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintE lq, uintC len);
 
 // atanhx(x) liefert zu einem Float x (betragsmäßig <1/2) atanh(x) als Float.
 extern const cl_F atanhx (const cl_F& x);
index da15148c2b3678e4a271867904f687ac31b0deba..7a926b7a40ebead9896c24d539b648dd969a0c40 100644 (file)
@@ -26,17 +26,17 @@ const cl_LF_cosh_sinh_t cl_coshsinh_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 sinh(p/2^lq) and cosh(p/2^lq) by splitting into pieces.
        var cl_boolean first_factor = cl_true;
        var cl_LF_cosh_sinh_t product;
-       var uintL b1;
-       var uintL b2;
+       var uintE b1;
+       var uintE b2;
        for (b1 = 0, b2 = 1; b1 < lq; b1 = b2, b2 = 2*b2) {
                // 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 sinh(pk/2^lqk) and cosh(pk/2^lqk).
                if (!zerop(pk)) {
index ee68f827c23396f0a9cc8d4a5238a6f8dbdb8715..5aebbf1743d627dffb764ecbcde92ca0c3b9b4f4 100644 (file)
@@ -26,10 +26,10 @@ namespace cln {
 // by a power series evaluation brings 20% speedup, even more for small lengths.
 #define TRIVIAL_SPEEDUP
 
-const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintC lq, uintC len)
+const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintE lq, uintC len)
 {
  {     Mutable(cl_I,p);
-       var uintC lp = integer_length(p); // now |p| < 2^lp.
+       var uintE lp = integer_length(p); // now |p| < 2^lp.
        if (!(lp <= lq)) cl_abort();
        lp = lq - lp; // now |p/2^lq| < 2^-lp.
        // Minimize lq (saves computation time).
index 624e3c66f951d01dcd06dd255bcb5d4f80cc448b..15d5a817691d376d5e2e2d666f6de8301f1c7cff 100644 (file)
@@ -26,17 +26,17 @@ const cl_LF_cos_sin_t cl_cossin_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 sin(p/2^lq) and cos(p/2^lq) by splitting into pieces.
        var cl_boolean first_factor = cl_true;
        var cl_LF_cos_sin_t product;
-       var uintL b1;
-       var uintL b2;
+       var uintE b1;
+       var uintE b2;
        for (b1 = 0, b2 = 1; b1 < lq; b1 = b2, b2 = 2*b2) {
                // 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 sin(pk/2^lqk) and cos(pk/2^lqk).
                if (!zerop(pk)) {
index 32d0b77e85aff2573ef8be642e1c6694ba822567..943158be56257ef4e86c750fb3cd0cfbbc46537a 100644 (file)
@@ -26,10 +26,10 @@ namespace cln {
 // by a power series evaluation brings 20% speedup, even more for small lengths.
 #define TRIVIAL_SPEEDUP
 
-const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintC lq, uintC len)
+const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintE lq, uintC len)
 {
  {     Mutable(cl_I,p);
-       var uintC lp = integer_length(p); // now |p| < 2^lp.
+       var uintE lp = integer_length(p); // now |p| < 2^lp.
        if (!(lp <= lq)) cl_abort();
        lp = lq - lp; // now |p/2^lq| < 2^-lp.
        // Minimize lq (saves computation time).
index 1dda6d28d49019d3a22fe1a2ad8a6a1f4eb48801..3401768a7ac20aaf3ae925e73f4da81c841fea0f 100644 (file)
 
 namespace cln {
 
-const cl_LF cl_exp_aux (const cl_I& p, uintC lq, uintC len)
+const cl_LF cl_exp_aux (const cl_I& p, uintE lq, uintC len)
 {
  {     Mutable(cl_I,p);
-       var uintC lp = integer_length(p); // now |p| < 2^lp.
+       var uintE lp = integer_length(p); // now |p| < 2^lp.
        if (!(lp <= lq)) cl_abort();
        lp = lq - lp; // now |p/2^lq| < 2^-lp.
        // Minimize lq (saves computation time).