X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=src%2Ffloat%2Ftranscendental%2Fcl_LF_cossin_aux.cc;h=86e630d300d75161ef7e75664adb7363bbec8d2a;hb=8b3d91dec77438c0fe679b10869ab29e6cdeba58;hp=5e3e0b3a64b39e4c75483dd867c0efaab795635c;hpb=850abfde7f0d985ba01526c346bcd0d733562943;p=cln.git diff --git a/src/float/transcendental/cl_LF_cossin_aux.cc b/src/float/transcendental/cl_LF_cossin_aux.cc index 5e3e0b3..86e630d 100644 --- a/src/float/transcendental/cl_LF_cossin_aux.cc +++ b/src/float/transcendental/cl_LF_cossin_aux.cc @@ -14,7 +14,7 @@ #include "cl_LF.h" #include "cln/integer.h" #include "cl_alloca.h" -#include "cln/abort.h" +#include "cln/exception.h" #undef floor #include @@ -26,15 +26,15 @@ 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, uintL 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 uintL lp = integer_length(p); // now |p| < 2^lp. - if (!(lp <= lq)) cl_abort(); + var uintE lp = integer_length(p); // now |p| < 2^lp. + if (!(lp <= lq)) throw runtime_exception(); lp = lq - lp; // now |p/2^lq| < 2^-lp. // Minimize lq (saves computation time). { - var uintL lp2 = ord2(p); + var uintC lp2 = ord2(p); if (lp2 > 0) { p = p >> lp2; lq = lq - lp2; @@ -65,16 +65,16 @@ const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintL lq, uintC len) // Third approximation: // N2 = ceiling(M*log(2)/(log(N1)-1+lp*log(2))), slightly too large. // N = N2+2, two more terms for safety. - var uintL N0 = intDsize*actuallen; - var uintL N1 = (uintL)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); - var uintL N2 = (uintL)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; - var uintL N = N2+2; + var uintC N0 = intDsize*actuallen; + var uintC N1 = (uintC)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); + var uintC N2 = (uintC)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; + var uintC N = N2+2; N = ceiling(N,2); CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL* qsv = (uintL*) cl_alloca(N*sizeof(uintL)); - var uintL n; + var uintC* qsv = (uintC*) cl_alloca(N*sizeof(uintC)); + var uintC n; var cl_I p2 = -square(p); var cl_LF sinsum; { @@ -112,7 +112,7 @@ const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintL lq, uintC len) #else // TRIVIAL_SPEEDUP var cl_LF cossum = sqrt(cl_I_to_LF(1,actuallen) - square(sinsum)); #endif - return cl_LF_cos_sin_t(shorten(cossum,len),shorten(sinsum,len)); // verkürzen und fertig + return cl_LF_cos_sin_t(shorten(cossum,len),shorten(sinsum,len)); // verkürzen und fertig }} // Bit complexity (N = len, and if p has length O(log N) and ql = O(log N)): // O(log(N)*M(N)).