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: " << repetitions << "\n";
30 bigint pow; power(pow, (bigint)10,digits);
31 bigfloat::precision(digits*2);
32 bigint x1; truncate(x1, ((sqrt((bigfloat)5)+1)/2) * (pow*pow));
33 bigfloat::precision(digits);
34 bigint x2; truncate(x2, sqrt((bigfloat)3) * pow);
37 cerr << "multiplication\n";
39 { timer t; t.set_print_mode(0); t.start_timer();
40 for (int rep = repetitions; rep > 0; rep--)
42 t.stop_timer(); cerr << t << endl;
44 cout << r << endl << endl;
48 { bigint q; bigint r; div_rem(q,r, x1,x2);
49 { timer t; t.set_print_mode(0); t.start_timer();
50 for (int rep = repetitions; rep > 0; rep--)
51 { bigint q; bigint r; div_rem(q,r, x1,x2); }
52 t.stop_timer(); cerr << t << endl;
54 cout << q << endl << r << endl << endl;
58 { bigint r; sqrt(r, x3);
59 { timer t; t.set_print_mode(0); t.start_timer();
60 for (int rep = repetitions; rep > 0; rep--)
61 { bigint r; sqrt(r, x3); }
62 t.stop_timer(); cerr << t << endl;
64 cout << r << endl << endl;
68 { bigint r = gcd(x1,x2);
69 { timer t; t.set_print_mode(0); t.start_timer();
70 for (int rep = repetitions; rep > 0; rep--)
71 { bigint r = gcd(x1,x2); }
72 t.stop_timer(); cerr << t << endl;
74 cout << r << endl << endl;