]> www.ginac.de Git - cln.git/blob - tests/timecatalan.cc
4ddb6beccd26a056b03229a30145ba28c5252d6d
[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 using namespace cln;
12 using namespace std;
13
14 int main (int argc, char * argv[])
15 {
16         int repetitions = 1;
17         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
18                 repetitions = atoi(argv[2]);
19                 argc -= 2; argv += 2;
20         }
21         if (argc < 2)
22                 exit(1);
23         uintL len = atoi(argv[1]);
24         extern cl_LF compute_catalanconst_ramanujan (uintC len);
25         extern cl_LF compute_catalanconst_ramanujan_fast (uintC len);
26         extern cl_LF compute_catalanconst_expintegral1 (uintC len);
27         extern cl_LF compute_catalanconst_expintegral2 (uintC len);
28         extern cl_LF compute_catalanconst_cvz1 (uintC len);
29         extern cl_LF compute_catalanconst_cvz2 (uintC len);
30         cl_LF p;
31         ln(cl_I_to_LF(1000,len+10)); // fill cache
32         { CL_TIMING;
33           for (int rep = repetitions; rep > 0; rep--)
34             { p = compute_catalanconst_ramanujan(len); }
35         }
36         cout << p << endl;
37         { CL_TIMING;
38           for (int rep = repetitions; rep > 0; rep--)
39             { p = compute_catalanconst_ramanujan_fast(len); }
40         }
41         cout << p << endl;
42 #if 0
43         { CL_TIMING;
44           for (int rep = repetitions; rep > 0; rep--)
45             { p = compute_catalanconst_expintegral1(len); }
46         }
47         cout << p << endl;
48         { CL_TIMING;
49           for (int rep = repetitions; rep > 0; rep--)
50             { p = compute_catalanconst_expintegral2(len); }
51         }
52         cout << p << endl;
53 #endif
54         { CL_TIMING;
55           for (int rep = repetitions; rep > 0; rep--)
56             { p = compute_catalanconst_cvz1(len); }
57         }
58         cout << p << endl;
59         { CL_TIMING;
60           for (int rep = repetitions; rep > 0; rep--)
61             { p = compute_catalanconst_cvz2(len); }
62         }
63         cout << p << endl;
64 }