1 #include <cln/number.h>
3 #include <cln/integer.h>
5 #include <cln/float_io.h>
7 #include <cln/real_io.h>
8 #include <cln/complex.h>
9 #include <cln/complex_io.h>
12 #include <cln/timing.h>
17 int main (int argc, char * argv[])
22 if (!strcmp(argv[1],"-r")) {
23 repetitions = atoi(argv[2]);
27 if (!strcmp(argv[1],"-n")) {
28 digits = atoi(argv[2]);
37 cerr << "Number of digits: " << digits << endl;
38 cerr << "Number of repetitions (except for pi,euler,e): " << repetitions << endl;
40 float_format_t prec = float_format(digits);
41 cl_F x1 = sqrt(cl_float(2,prec));
42 cl_F x2 = sqrt(cl_float(3,prec));
43 cl_F x3 = The(cl_F)(log(cl_float(2,prec)));
45 cerr << "multiplication" << endl;
48 for (int rep = repetitions; rep > 0; rep--)
51 cout << r << endl << endl;
54 cerr << "sqrt" << endl;
57 for (int rep = repetitions; rep > 0; rep--)
60 cout << r << endl << endl;
65 { CL_TIMING; r = pi(prec); }
66 cout << r << endl << endl;
69 cerr << "eulerconst" << endl;
71 { CL_TIMING; r = eulerconst(prec); }
72 cout << r << endl << endl;
77 { CL_TIMING; r = exp1(prec); }
78 cout << r << endl << endl;
81 cerr << "exp" << endl;
84 for (int rep = repetitions; rep > 0; rep--)
87 cout << r << endl << endl;
90 cerr << "log" << endl;
93 for (int rep = repetitions; rep > 0; rep--)
96 cout << r << endl << endl;
99 cerr << "sin" << endl;
100 { cl_R r = sin(5*x1);
102 for (int rep = repetitions; rep > 0; rep--)
105 cout << r << endl << endl;
108 cerr << "cos" << endl;
109 { cl_R r = cos(5*x1);
111 for (int rep = repetitions; rep > 0; rep--)
114 cout << r << endl << endl;
117 cerr << "asin" << endl;
120 for (int rep = repetitions; rep > 0; rep--)
123 cout << r << endl << endl;
126 cerr << "acos" << endl;
129 for (int rep = repetitions; rep > 0; rep--)
132 cout << r << endl << endl;
135 cerr << "atan" << endl;
138 for (int rep = repetitions; rep > 0; rep--)
141 cout << r << endl << endl;
144 cerr << "sinh" << endl;
147 for (int rep = repetitions; rep > 0; rep--)
150 cout << r << endl << endl;
153 cerr << "cosh" << endl;
156 for (int rep = repetitions; rep > 0; rep--)
159 cout << r << endl << endl;
162 cerr << "asinh" << endl;
163 { cl_N r = asinh(x3);
165 for (int rep = repetitions; rep > 0; rep--)
168 cout << r << endl << endl;
171 cerr << "acosh" << endl;
172 { cl_N r = acosh(1+x3);
174 for (int rep = repetitions; rep > 0; rep--)
177 cout << r << endl << endl;
180 cerr << "atanh" << endl;
181 { cl_N r = atanh(x3);
183 for (int rep = repetitions; rep > 0; rep--)
186 cout << r << endl << endl;