12 #include "cln/integer.h"
13 #include "cln/lfloat.h"
15 #include "cl_LF_tran.h"
16 #include "cl_alloca.h"
20 #define floor cln_floor
25 // See examples/atanh_recip.cc for a comparison of the algorithms.
26 // Here we take algorithm 1d. It's the fastest throughout the range.
28 const cl_LF cl_atanh_recip (cl_I m, uintC len)
30 var uintC actuallen = len + 1;
32 var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/::log(double_approx(m))) + 1;
34 var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I));
35 var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I));
37 for (n = 0; n < N; n++) {
38 new (&bv[n]) cl_I ((cl_I)(2*n+1));
39 new (&qv[n]) cl_I (n==0 ? m : m2);
41 var cl_qb_series series;
43 series.qv = qv; series.qsv = NULL;
44 var cl_LF result = eval_rational_series(N,series,actuallen);
45 for (n = 0; n < N; n++) {
49 return shorten(result,len);
51 // Bit complexity (N = len): O(log(N)^2*M(N)).