]> www.ginac.de Git - cln.git/blob - tests/timeLFcos-compare.cc
* configure.ac: Disable shared lib on MinGW.
[cln.git] / tests / timeLFcos-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 < 2)
20                 exit(1);
21         extern int cl_cos_algo;
22         uintL len = atoi(argv[1]);
23 #if 0
24         cl_LF one = cl_I_to_LF(1,len);
25         cl_F x = scale_float(random_F(one),-1);
26         cout << x << endl;
27 #else
28         cl_F x = sqrt(cl_I_to_LF(2,len))-1;
29 #endif
30         cl_F y;
31         cl_cos_algo = 0;
32         { CL_TIMING;
33           for (int rep = repetitions; rep > 0; rep--)
34             { y = cos(x); }
35         }
36         cout << y << endl;
37         cl_cos_algo = 1;
38         { CL_TIMING;
39           for (int rep = repetitions; rep > 0; rep--)
40             { y = cos(x); }
41         }
42         cout << y << endl;
43 }