]> www.ginac.de Git - cln.git/blob - tests/timeLFexp.cc
* src/base/digitseq/cl_DS.h: #undef DS, needed for i386-Solaris.
[cln.git] / tests / timeLFexp.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/float.h>
4 #include <cln/float_io.h>
5 #include <cln/lfloat.h>
6 #include "cl_LF.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 < 2)
21                 exit(1);
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         extern int cl_exp_algo;
32         y = exp(x); // fill cache
33 #if 0
34         cl_exp_algo = 0;
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { y = exp(x); }
38         }
39         cout << y << endl;
40         cl_exp_algo = 1;
41 #endif
42         { CL_TIMING;
43           for (int rep = repetitions; rep > 0; rep--)
44             { y = exp(x); }
45         }
46         cout << y << endl;
47 }