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