]> www.ginac.de Git - cln.git/blob - tests/timecatalan.cc
Fix double_approx(const cl_RA& x) on 64-Bit platforms.
[cln.git] / tests / timecatalan.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/float.h>
4 #include <cln/real.h>
5 #include <cln/random.h>
6 #include <cstdlib>
7 #include <cstring>
8 #include <cln/timing.h>
9 #include "float/lfloat/cl_LF.h"
10 #include <iostream>
11 namespace cln
12 {
13 // FIXME: using internal functions is a bad idea (even if it works
14 // on some ELF systems)
15 extern cl_LF compute_catalanconst_ramanujan (uintC len);
16 extern cl_LF compute_catalanconst_ramanujan_fast (uintC len);
17 extern cl_LF compute_catalanconst_expintegral1 (uintC len);
18 extern cl_LF compute_catalanconst_expintegral2 (uintC len);
19 extern cl_LF compute_catalanconst_cvz1 (uintC len);
20 extern cl_LF compute_catalanconst_cvz2 (uintC len);
21 }
22
23 using namespace cln;
24 using namespace std;
25
26 int main (int argc, char * argv[])
27 {
28         int repetitions = 1;
29         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
30                 repetitions = atoi(argv[2]);
31                 argc -= 2; argv += 2;
32         }
33         if (argc < 2)
34                 exit(1);
35         uintL len = atoi(argv[1]);
36
37
38         cl_LF p;
39         ln(cl_I_to_LF(1000,len+10)); // fill cache
40         { CL_TIMING;
41           for (int rep = repetitions; rep > 0; rep--)
42             { p = compute_catalanconst_ramanujan(len); }
43         }
44         cout << p << endl;
45         { CL_TIMING;
46           for (int rep = repetitions; rep > 0; rep--)
47             { p = compute_catalanconst_ramanujan_fast(len); }
48         }
49         cout << p << endl;
50 #if 0
51         { CL_TIMING;
52           for (int rep = repetitions; rep > 0; rep--)
53             { p = compute_catalanconst_expintegral1(len); }
54         }
55         cout << p << endl;
56         { CL_TIMING;
57           for (int rep = repetitions; rep > 0; rep--)
58             { p = compute_catalanconst_expintegral2(len); }
59         }
60         cout << p << endl;
61 #endif
62         { CL_TIMING;
63           for (int rep = repetitions; rep > 0; rep--)
64             { p = compute_catalanconst_cvz1(len); }
65         }
66         cout << p << endl;
67         { CL_TIMING;
68           for (int rep = repetitions; rep > 0; rep--)
69             { p = compute_catalanconst_cvz2(len); }
70         }
71         cout << p << endl;
72 }