]> www.ginac.de Git - cln.git/blob - tests/test_MI_minus.cc
* src/base/digitseq/cl_DS.h: #undef DS, needed for i386-Solaris.
[cln.git] / tests / test_MI_minus.cc
1 #include "test_MI.h"
2
3 int test_MI_minus (int iterations)
4 {
5         int error = 0;
6         int i;
7         // Check anti-commutativity.
8         for (i = iterations; i > 0; i--) {
9                 cl_I m = testrandom_I();
10                 cl_modint_ring R = find_modint_ring(m);
11                 cl_MI a = R->canonhom(testrandom_I());
12                 cl_MI b = R->canonhom(testrandom_I());
13                 cl_MI z = R->zero();
14                 ASSERT3((a-b) + (b-a) == z, m,a,b);
15         }
16         // Check associativity.
17         for (i = iterations; i > 0; i--) {
18                 cl_I m = testrandom_I();
19                 cl_modint_ring R = find_modint_ring(m);
20                 cl_MI a = R->canonhom(testrandom_I());
21                 cl_MI b = R->canonhom(testrandom_I());
22                 cl_MI c = R->canonhom(testrandom_I());
23                 ASSERT4(a-(b-c) == c-(b-a), m,a,b,c);
24         }
25         // Check special case 0.
26         for (i = iterations; i > 0; i--) {
27                 cl_I m = testrandom_I();
28                 cl_modint_ring R = find_modint_ring(m);
29                 cl_MI a = R->canonhom(testrandom_I());
30                 cl_MI z = R->zero();
31                 ASSERT2(a-z == a, m,a);
32                 ASSERT2(z-(z-a) == a, m,a);
33         }
34         return error;
35 }