1 #include <cln/number.h>
4 #include <cln/float_io.h>
6 #include <cln/random.h>
9 #include <cln/timing.h>
14 int main (int argc, char * argv[])
17 if ((argc >= 3) && !strcmp(argv[1],"-r")) {
18 repetitions = atoi(argv[2]);
24 uintL len = atoi(argv[1]);
25 extern cl_LF compute_pi_brent_salamin (uintC len);
26 extern cl_LF compute_pi_brent_salamin_quartic (uintC len);
27 extern cl_LF compute_pi_ramanujan_163 (uintC len);
28 extern cl_LF compute_pi_ramanujan_163_fast (uintC len);
31 for (int rep = repetitions; rep > 0; rep--)
32 { p = compute_pi_brent_salamin(len); }
36 for (int rep = repetitions; rep > 0; rep--)
37 { p = compute_pi_brent_salamin_quartic(len); }
41 for (int rep = repetitions; rep > 0; rep--)
42 { p = compute_pi_ramanujan_163(len); }
46 for (int rep = repetitions; rep > 0; rep--)
47 { p = compute_pi_ramanujan_163_fast(len); }
51 // Here the argument is N *decimal* digits, not N*32 bits!
52 int n = atoi(argv[1]);
53 float_format_t prec = float_format(n);
55 cerr << "Computing pi" << endl;
56 { CL_TIMING; p = pi(prec); }
57 cerr << "Converting pi to decimal" << endl;
58 { CL_TIMING; cout << p << endl << endl; }