]> www.ginac.de Git - cln.git/blob - tests/timeLFsin-compare.cc
* Fix typo.
[cln.git] / tests / timeLFsin-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
12 int main (int argc, char * argv[])
13 {
14         int repetitions = 1;
15         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
16                 repetitions = atoi(argv[2]);
17                 argc -= 2; argv += 2;
18         }
19         if (argc < 3)
20                 exit(1);
21         extern double cl_sin_factor;
22         extern int cl_sin_algo;
23         extern int cl_aux_algo;
24         uintL len = atoi(argv[1]);
25         cl_sin_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_sin_algo = 0;
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { y = sin(x); }
38         }
39         cout << y << endl;
40         cl_sin_algo = 1; cl_aux_algo = 0;
41         { CL_TIMING;
42           for (int rep = repetitions; rep > 0; rep--)
43             { y = sin(x); }
44         }
45         cout << y << endl;
46         cl_sin_algo = 1; cl_aux_algo = 1;
47         { CL_TIMING;
48           for (int rep = repetitions; rep > 0; rep--)
49             { y = sin(x); }
50         }
51         cout << y << endl;
52 }