]> www.ginac.de Git - cln.git/blob - tests/timeLFln-compare.cc
51df5c940663a1af09da4387b7b619af0158ffd5
[cln.git] / tests / timeLFln-compare.cc
1 #include <cl_number.h>
2 #include <cl_io.h>
3 #include <cl_float.h>
4 #include <cl_lfloat.h>
5 #include "cl_LF.h"
6 #include <cl_real.h>
7 #include <cl_random.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <cl_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         uintL len = atoi(argv[1]);
22 #if 0
23         cl_LF one = cl_I_to_LF(1,len);
24         cl_F x = one + random_F(one)/3;
25         cout << x << endl;
26 #else
27         cl_F x = sqrt(sqrt(cl_I_to_LF(2,len)));
28 #endif
29         cl_F y;
30         extern int cl_lnx_algo;
31         cl_lnx_algo = 0;
32         y = ln(x); // fill cache
33         { CL_TIMING;
34           for (int rep = repetitions; rep > 0; rep--)
35             { y = ln(x); }
36         }
37         cout << y << endl;
38         cl_lnx_algo = 1;
39         { CL_TIMING;
40           for (int rep = repetitions; rep > 0; rep--)
41             { y = ln(x); }
42         }
43         cout << y << endl;
44 }