]> www.ginac.de Git - cln.git/blob - tests/timecatalan.cc
Enable modifying operators by default.
[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 "cl_LF.h"
10 using namespace cln;
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         extern cl_LF compute_catalanconst_ramanujan (uintC len);
23         extern cl_LF compute_catalanconst_ramanujan_fast (uintC len);
24         extern cl_LF compute_catalanconst_expintegral1 (uintC len);
25         extern cl_LF compute_catalanconst_expintegral2 (uintC len);
26         extern cl_LF compute_catalanconst_cvz1 (uintC len);
27         extern cl_LF compute_catalanconst_cvz2 (uintC len);
28         cl_LF p;
29         ln(cl_I_to_LF(1000,len+10)); // fill cache
30         { CL_TIMING;
31           for (int rep = repetitions; rep > 0; rep--)
32             { p = compute_catalanconst_ramanujan(len); }
33         }
34         cout << p << endl;
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { p = compute_catalanconst_ramanujan_fast(len); }
38         }
39         cout << p << endl;
40 #if 0
41         { CL_TIMING;
42           for (int rep = repetitions; rep > 0; rep--)
43             { p = compute_catalanconst_expintegral1(len); }
44         }
45         cout << p << endl;
46         { CL_TIMING;
47           for (int rep = repetitions; rep > 0; rep--)
48             { p = compute_catalanconst_expintegral2(len); }
49         }
50         cout << p << endl;
51 #endif
52         { CL_TIMING;
53           for (int rep = repetitions; rep > 0; rep--)
54             { p = compute_catalanconst_cvz1(len); }
55         }
56         cout << p << endl;
57         { CL_TIMING;
58           for (int rep = repetitions; rep > 0; rep--)
59             { p = compute_catalanconst_cvz2(len); }
60         }
61         cout << p << endl;
62 }