1 #include <LiDIA/bigint.h>
2 #include <LiDIA/bigfloat.h>
3 #include <LiDIA/timer.h>
7 int main (int argc, char * argv[])
12 if (!strcmp(argv[1],"-r")) {
13 repetitions = atoi(argv[2]);
17 if (!strcmp(argv[1],"-n")) {
18 digits = atoi(argv[2]);
27 cerr << "Number of digits: " << digits << "\n";
28 cerr << "Number of repetitions (except for pi,euler,e): " << repetitions << "\n";
30 bigfloat::precision(digits);
31 bigfloat x1 = sqrt((bigfloat)2);
32 bigfloat x2 = sqrt((bigfloat)3);
33 bigfloat x3 = log((bigfloat)2);
35 cerr << "multiplication\n";
37 { timer t; t.set_print_mode(0); t.start_timer();
38 for (int rep = repetitions; rep > 0; rep--)
40 t.stop_timer(); cerr << t << endl;
42 cout << r << endl << endl;
46 { bigfloat r = sqrt(x3);
47 { timer t; t.set_print_mode(0); t.start_timer();
48 for (int rep = repetitions; rep > 0; rep--)
50 t.stop_timer(); cerr << t << endl;
52 cout << r << endl << endl;
57 { timer t; t.set_print_mode(0); t.start_timer();
59 t.stop_timer(); cerr << t << endl;
61 cout << r << endl << endl;
64 cerr << "eulerconst\n";
66 { timer t; t.set_print_mode(0); t.start_timer();
68 t.stop_timer(); cerr << t << endl;
70 cout << r << endl << endl;
75 { timer t; t.set_print_mode(0); t.start_timer();
77 t.stop_timer(); cerr << t << endl;
79 cout << r << endl << endl;
83 { bigfloat r = exp(-x1);
84 { timer t; t.set_print_mode(0); t.start_timer();
85 for (int rep = repetitions; rep > 0; rep--)
87 t.stop_timer(); cerr << t << endl;
89 cout << r << endl << endl;
93 { bigfloat r = log(x2);
94 { timer t; t.set_print_mode(0); t.start_timer();
95 for (int rep = repetitions; rep > 0; rep--)
97 t.stop_timer(); cerr << t << endl;
99 cout << r << endl << endl;
103 { bigfloat r = sin(5*x1);
104 { timer t; t.set_print_mode(0); t.start_timer();
105 for (int rep = repetitions; rep > 0; rep--)
107 t.stop_timer(); cerr << t << endl;
109 cout << r << endl << endl;
113 { bigfloat r = cos(5*x1);
114 { timer t; t.set_print_mode(0); t.start_timer();
115 for (int rep = repetitions; rep > 0; rep--)
117 t.stop_timer(); cerr << t << endl;
119 cout << r << endl << endl;
123 { bigfloat r = asin(x3);
124 { timer t; t.set_print_mode(0); t.start_timer();
125 for (int rep = repetitions; rep > 0; rep--)
127 t.stop_timer(); cerr << t << endl;
129 cout << r << endl << endl;
133 { bigfloat r = acos(x3);
134 { timer t; t.set_print_mode(0); t.start_timer();
135 for (int rep = repetitions; rep > 0; rep--)
137 t.stop_timer(); cerr << t << endl;
139 cout << r << endl << endl;
143 { bigfloat r = atan(x3);
144 { timer t; t.set_print_mode(0); t.start_timer();
145 for (int rep = repetitions; rep > 0; rep--)
147 t.stop_timer(); cerr << t << endl;
149 cout << r << endl << endl;
153 { bigfloat r = sinh(x2);
154 { timer t; t.set_print_mode(0); t.start_timer();
155 for (int rep = repetitions; rep > 0; rep--)
157 t.stop_timer(); cerr << t << endl;
159 cout << r << endl << endl;
163 { bigfloat r = cosh(x2);
164 { timer t; t.set_print_mode(0); t.start_timer();
165 for (int rep = repetitions; rep > 0; rep--)
167 t.stop_timer(); cerr << t << endl;
169 cout << r << endl << endl;
173 { bigfloat r = asinh(x3);
174 { timer t; t.set_print_mode(0); t.start_timer();
175 for (int rep = repetitions; rep > 0; rep--)
177 t.stop_timer(); cerr << t << endl;
179 cout << r << endl << endl;
183 { bigfloat r = acosh(1+x3);
184 { timer t; t.set_print_mode(0); t.start_timer();
185 for (int rep = repetitions; rep > 0; rep--)
187 t.stop_timer(); cerr << t << endl;
189 cout << r << endl << endl;
193 { bigfloat r = atanh(x3);
194 { timer t; t.set_print_mode(0); t.start_timer();
195 for (int rep = repetitions; rep > 0; rep--)
197 t.stop_timer(); cerr << t << endl;
199 cout << r << endl << endl;