]> www.ginac.de Git - cln.git/blob - tests/test_I_mul.cc
* src/polynomial/elem/cl_UP_GF2.h (gf2_mul_table): define for sparc64.
[cln.git] / tests / test_I_mul.cc
1 #include "test_I.h"
2
3 int test_I_mul (int iterations)
4 {
5         int error = 0;
6         int i;
7         // Check commutativity.
8         for (i = iterations; i > 0; i--) {
9                 cl_I a = testrandom_I();
10                 cl_I b = testrandom_I();
11                 ASSERT2(a*b == b*a, a,b);
12         }
13         // Check associativity.
14         for (i = iterations; i > 0; i--) {
15                 cl_I a = testrandom_I();
16                 cl_I b = testrandom_I();
17                 cl_I c = testrandom_I();
18                 ASSERT3((a*b)*c == a*(b*c), a,b,c);
19         }
20         // Check second binomial formula.
21         for (i = iterations; i > 0; i--) {
22                 cl_I a = testrandom_I();
23                 cl_I b = testrandom_I();
24                 ASSERT2((a+b)*(a-b) == a*a-b*b, a,b);
25         }
26         // Check distributive formula.
27         for (i = iterations; i > 0; i--) {
28                 cl_I a = testrandom_I();
29                 cl_I b = testrandom_I();
30                 cl_I c = testrandom_I();
31                 ASSERT3((a+c)*(b+c) == a*b+(a+b)*c+c*c, a,b,c);
32         }
33         // Check special cases 0, 1, -1.
34         for (i = iterations; i > 0; i--) {
35                 cl_I a = testrandom_I();
36                 ASSERT1(a*0 == 0, a);
37                 ASSERT1(a*1 == a, a);
38                 ASSERT1(a*-1 == -a, a);
39         }
40         return error;
41 }