more typename fixes
[prop.git] / tests / qa7.cc
blobe75f34d01644664af93f7967bc8893816677a5ee
1 // Test some numeric stuff
3 #include <stdio.h>
4 #include <iostream.h>
5 #include <assert.h>
6 #include <AD/numeric/bigint.h>
7 #include <AD/numeric/complex.h>
8 #include <AD/numeric/matrix.h>
9 #include <AD/numeric/ratio.h>
10 #include <AD/numeric/z.h>
12 int main(int argc, char * argv[])
13 { Z<9> a = 0, b = 1, c = 0;
15 assert(sizeof(a) == 4);
16 assert(a != b && a == c);
18 Complex i(0,1);
20 assert (i * i == -1);
22 BigInt x = 123456, y = 8765;
23 cout << x << " % " << y << " = " << (x%y) << '\n';
24 cout << x << " / " << y << " = " << (x/y) << '\n';
25 cout << x << " * " << y << " = " << (x*y) << '\n';
26 cout << x << " + " << y << " = " << (x+y) << '\n';
27 cout << x << " - " << y << " = " << (x-y) << '\n';
29 cout << x << " % " << y << " = " << (123456%8765) << '\n';
30 cout << x << " / " << y << " = " << (123456/8765) << '\n';
31 cout << x << " * " << y << " = " << (123456*8765) << '\n';
32 cout << x << " + " << y << " = " << (123456+8765) << '\n';
33 cout << x << " - " << y << " = " << (123456-8765) << '\n';
35 assert (x % y == 123456%8765);
36 assert (x / y == 123456/8765);
37 assert (x * y == 123456*8765);
38 assert (x + y == 123456+8765);
39 assert (x - y == 123456-8765);
41 BigInt fact = 1;
42 int limit = 100;
43 if (argc == 2) sscanf(argv[1],"%d",&limit);
44 for (int n = 1; n <= limit; n++) {
45 fact *= n;
47 cout << "Done\n"; cout.flush();
48 cout << " my fact(" << limit << ") = " << fact << '\n';
50 BigInt fact2 =
51 "93326215443944152681699238856266700490715968264381621468592963895217"
52 "59999322991560894146397615651828625369792082722375825118521091686400"
53 "0000000000000000000000";
55 cout << "real fact(" << limit << ") = " << fact2 << '\n';
56 assert(fact == fact2);
58 //for (n = 1; n <= 10000; n++) fact /= n;
59 //cout << "one = " << fact << '\n';
61 printf("OK\n");
62 return 0;