]> www.ginac.de Git - cln.git/blob - src/float/transcendental/cl_LF_atanh_recip.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / float / transcendental / cl_LF_atanh_recip.cc
1 // cl_atanh_recip().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_F_tran.h"
8
9
10 // Implementation.
11
12 #include "cln/integer.h"
13 #include "cln/lfloat.h"
14 #include "cl_LF.h"
15 #include "cl_LF_tran.h"
16 #include "cl_alloca.h"
17
18 #undef floor
19 #include <cmath>
20 #define floor cln_floor
21
22 namespace cln {
23
24 // Method:
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.
27
28 const cl_LF cl_atanh_recip (cl_I m, uintC len)
29 {
30         var uintC actuallen = len + 1;
31         var cl_I m2 = m*m;
32         var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/::log(double_approx(m))) + 1;
33         CL_ALLOCA_STACK;
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));
36         var uintL n;
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);
40         }
41         var cl_qb_series series;
42         series.bv = bv;
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++) {
46                 bv[n].~cl_I();
47                 qv[n].~cl_I();
48         }
49         return shorten(result,len);
50 }
51 // Bit complexity (N = len): O(log(N)^2*M(N)).
52
53 }  // namespace cln