]> www.ginac.de Git - cln.git/blob - tests/timeLFatan-compare.cc
Make GCC compiler flags default to -O
[cln.git] / tests / timeLFatan-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/real.h>
7 #include <cln/random.h>
8 #include <cstdlib>
9 #include <cstring>
10 #include <cln/timing.h>
11 using namespace cln;
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_atanx_factor;
23         extern int cl_atan_algo;
24         uintL len = atoi(argv[1]);
25         cl_atanx_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_F y;
34         cl_atan_algo = 0;
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { y = atan(x); }
38         }
39         cout << y << endl;
40         cl_atan_algo = 1;
41         { CL_TIMING;
42           for (int rep = repetitions; rep > 0; rep--)
43             { y = atan(x); }
44         }
45         cout << y << endl;
46 }