1 #include <LiDIA/bigfloat.h>
2 #include <LiDIA/timer.h>
4 int main (int argc, char * argv[])
7 if ((argc >= 3) && !strcmp(argv[1],"-r")) {
8 repetitions = atoi(argv[2]);
14 bigfloat::precision(1000);
18 { timer t; t.set_print_mode(0); t.start_timer();
20 t.stop_timer(); cerr << t << endl;
22 { timer t; t.set_print_mode(0); t.start_timer();
23 for (int rep = repetitions; rep > 0; rep--)
24 { bigfloat p = Pi(); }
25 t.stop_timer(); cerr << t << endl;
27 cout << p << endl << endl;
32 { timer t; t.set_print_mode(0); t.start_timer();
34 t.stop_timer(); cerr << t << endl;
36 { timer t; t.set_print_mode(0); t.start_timer();
37 for (int rep = repetitions; rep > 0; rep--)
38 { bigfloat p = Euler(); }
39 t.stop_timer(); cerr << t << endl;
41 cout << p << endl << endl;
46 { timer t; t.set_print_mode(0); t.start_timer();
47 for (int rep = repetitions; rep > 0; rep--)
49 t.stop_timer(); cerr << t << endl;
51 cout << p << endl << endl;
55 { bigfloat p = sqrt((bigfloat)3);
56 { timer t; t.set_print_mode(0); t.start_timer();
57 for (int rep = repetitions; rep > 0; rep--)
58 { bigfloat p = sqrt((bigfloat)3); }
59 t.stop_timer(); cerr << t << endl;
61 cout << p << endl << endl;
64 cerr << "exp(log(2))\n";
65 { bigfloat p = exp(log((bigfloat)2));
66 { timer t; t.set_print_mode(0); t.start_timer();
67 for (int rep = repetitions; rep > 0; rep--)
68 { bigfloat p = exp(log((bigfloat)2)); }
69 t.stop_timer(); cerr << t << endl;
71 cout << p << endl << endl;
74 cerr << "log(exp(2))\n";
75 { bigfloat p = log(exp((bigfloat)2));
76 { timer t; t.set_print_mode(0); t.start_timer();
77 for (int rep = repetitions; rep > 0; rep--)
78 { bigfloat p = log(exp((bigfloat)2)); }
79 t.stop_timer(); cerr << t << endl;
81 cout << p << endl << endl;
84 cerr << "sin(pi/3)\n";
85 { bigfloat p = sin(Pi()/3);
86 { timer t; t.set_print_mode(0); t.start_timer();
87 for (int rep = repetitions; rep > 0; rep--)
88 { bigfloat p = sin(Pi()/3); }
89 t.stop_timer(); cerr << t << endl;
91 cout << p << endl << endl;
94 cerr << "cos(pi/3)\n";
95 { bigfloat p = cos(Pi()/3);
96 { timer t; t.set_print_mode(0); t.start_timer();
97 for (int rep = repetitions; rep > 0; rep--)
98 { bigfloat p = cos(Pi()/3); }
99 t.stop_timer(); cerr << t << endl;
101 cout << p << endl << endl;
104 cerr << "arcsin(sqrt(3)/2)\n";
105 { bigfloat p = asin(sqrt((bigfloat)3)/2);
106 { timer t; t.set_print_mode(0); t.start_timer();
107 for (int rep = repetitions; rep > 0; rep--)
108 { bigfloat p = asin(sqrt((bigfloat)3)/2); }
109 t.stop_timer(); cerr << t << endl;
111 cout << p << endl << endl;
114 cerr << "arccos(sqrt(3)/2)\n";
115 { bigfloat p = acos(sqrt((bigfloat)3)/2);
116 { timer t; t.set_print_mode(0); t.start_timer();
117 for (int rep = repetitions; rep > 0; rep--)
118 { bigfloat p = acos(sqrt((bigfloat)3)/2); }
119 t.stop_timer(); cerr << t << endl;
121 cout << p << endl << endl;
124 cerr << "sinh(log(2))\n";
125 { bigfloat p = sinh(log((bigfloat)2));
126 { timer t; t.set_print_mode(0); t.start_timer();
127 for (int rep = repetitions; rep > 0; rep--)
128 { bigfloat p = sinh(log((bigfloat)2)); }
129 t.stop_timer(); cerr << t << endl;
131 cout << p << endl << endl;
134 cerr << "cosh(log(2))\n";
135 { bigfloat p = cosh(log((bigfloat)2));
136 { timer t; t.set_print_mode(0); t.start_timer();
137 for (int rep = repetitions; rep > 0; rep--)
138 { bigfloat p = cosh(log((bigfloat)2)); }
139 t.stop_timer(); cerr << t << endl;
141 cout << p << endl << endl;
144 cerr << "arsinh(pi)\n";
145 { bigfloat p = asinh(Pi());
146 { timer t; t.set_print_mode(0); t.start_timer();
147 for (int rep = repetitions; rep > 0; rep--)
148 { bigfloat p = asinh(Pi()); }
149 t.stop_timer(); cerr << t << endl;
151 cout << p << endl << endl;
154 cerr << "arcosh(pi)\n";
155 { bigfloat p = acosh(Pi());
156 { timer t; t.set_print_mode(0); t.start_timer();
157 for (int rep = repetitions; rep > 0; rep--)
158 { bigfloat p = acosh(Pi()); }
159 t.stop_timer(); cerr << t << endl;
161 cout << p << endl << endl;