]> www.ginac.de Git - cln.git/blob - tests/timeLFatanh.cc
Fix double_approx(const cl_RA& x) on 64-Bit platforms.
[cln.git] / tests / timeLFatanh.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/float.h>
4 #include <cln/lfloat.h>
5 #include "float/lfloat/cl_LF.h"
6 #include <cln/complex.h>
7 #include <cln/complex_io.h>
8 #include <cln/real.h>
9 #include <cln/random.h>
10 #include <cstdlib>
11 #include <cstring>
12 #include <cln/timing.h>
13 using namespace cln;
14 #include <iostream>
15 using namespace std;
16
17 int main (int argc, char * argv[])
18 {
19         int repetitions = 1;
20         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
21                 repetitions = atoi(argv[2]);
22                 argc -= 2; argv += 2;
23         }
24         if (argc < 2)
25                 exit(1);
26         uintL len = atoi(argv[1]);
27 #if 0
28         cl_LF one = cl_I_to_LF(1,len);
29         cl_F x = scale_float(random_F(one),-1);
30         cout << x << endl;
31 #else
32         cl_F x = sqrt(cl_I_to_LF(2,len))-1;
33 #endif
34         cl_N y;
35         ln(cl_I_to_LF(1000,len+10)); // fill cache
36         { CL_TIMING;
37           for (int rep = repetitions; rep > 0; rep--)
38             { y = atanh(x); }
39         }
40         cout << y << endl;
41         { CL_TIMING;
42           for (int rep = repetitions; rep > 0; rep--)
43             { y = ln((1+x)/(1-x))/2; }
44         }
45         cout << y << endl;
46 }