X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=src%2Fbase%2Fdigitseq%2Fcl_2DS_div.cc;h=30eed3840c55b6fafeecd01ee05390f8f350228c;hb=22549ef70fee95faab1e9f2adaf710ba9e0bdabf;hp=5d0738ee3ad32c9e5fd0ced6036065a0cb9c0a2c;hpb=c84c6db5d56829d69083c819688a973867694a2a;p=cln.git diff --git a/src/base/digitseq/cl_2DS_div.cc b/src/base/digitseq/cl_2DS_div.cc index 5d0738e..30eed38 100644 --- a/src/base/digitseq/cl_2DS_div.cc +++ b/src/base/digitseq/cl_2DS_div.cc @@ -11,7 +11,7 @@ #include "cl_2D.h" #include "cl_DS.h" -#include "cln/abort.h" +#include "cln/exception.h" namespace cln { @@ -55,15 +55,15 @@ namespace cln { // // Break-even-point. When in doubt, prefer to choose the standard algorithm. #if CL_USE_GMP - static inline cl_boolean cl_recip_suitable (uintC m, uintC n) // n <= m + static inline bool cl_recip_suitable (uintC m, uintC n) // n <= m { if (n < 2000) - return cl_false; + return false; else // when n >= 4400/(m/n)^2, i.e. (m/66)^2 > n { var uintC mq = floor(m,66); if ((mq >= bit(intCsize/2)) || (mq*mq > n)) - return cl_true; + return true; else - return cl_false; + return false; } } #else @@ -93,15 +93,15 @@ namespace cln { // 1.8*N / N : Newton for N >= 500 // 1.9*N / N : Newton for N >= 500 // 2.0*N / N : Newton for N >= 500 - static inline cl_boolean cl_recip_suitable (uintC m, uintC n) // n <= m + static inline bool cl_recip_suitable (uintC m, uintC n) // n <= m { if (n < 500) - return cl_false; + return false; else // when n >= 2100/(m/n)^2, i.e. (m/46)^2 > n { var uintC mq = floor(m,46); if ((mq >= bit(intCsize/2)) || (mq*mq > n)) - return cl_true; + return true; else - return cl_false; + return false; } } #endif @@ -124,9 +124,9 @@ void div2adic (uintC a_len, const uintD* a_LSDptr, uintC b_len, const uintD* b_L var uintD* p_LSDptr; num_stack_alloc(2*b_len,,p_LSDptr=); cl_UDS_mul(q_LSDptr,b_len,b_LSDptr,b_len,p_LSDptr); - // Überprüfen, daß p == a mod 2^(intDsize*b_len): + // Überprüfen, daß p == a mod 2^(intDsize*b_len): if (compare_loop_msp(a_LSDptr lspop b_len,p_LSDptr lspop b_len,b_len)) - cl_abort(); + throw runtime_exception(); // Quotient q und "Rest" (a-b*q)/2^(intDsize*b_len) ablegen: copy_loop_lsp(q_LSDptr,dest_LSDptr,b_len); if (lendiff <= b_len) @@ -141,9 +141,9 @@ void div2adic (uintC a_len, const uintD* a_LSDptr, uintC b_len, const uintD* b_L { // Standard division. var uintD b0inv = div2adic(1,lspref(b_LSDptr,0)); // b' copy_loop_lsp(a_LSDptr,dest_LSDptr,a_len); // d := a - do { var uintD digit = lspref(dest_LSDptr,0); // nächstes d[j] + do { var uintD digit = lspref(dest_LSDptr,0); // nächstes d[j] digit = mul2adic(b0inv,digit); - // digit = nächstes c[j] + // digit = nächstes c[j] if (a_len <= b_len) { mulusub_loop_lsp(digit,b_LSDptr,dest_LSDptr,a_len); } // d := d - b * c[j] * beta^j else @@ -157,7 +157,7 @@ void div2adic (uintC a_len, const uintD* a_LSDptr, uintC b_len, const uintD* b_L } } // Nun ist lspref(dest_LSDptr,0) = 0. lspref(dest_LSDptr,0) = digit; // c[j] ablegen - lsshrink(dest_LSDptr); a_len--; // nächstes j + lsshrink(dest_LSDptr); a_len--; // nächstes j } until (a_len==lendiff); }