You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
940 B

25 years ago
  1. #include "test_MI.h"
  2. int test_MI_minus (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check anti-commutativity.
  7. for (i = iterations; i > 0; i--) {
  8. cl_I m = testrandom_I();
  9. cl_modint_ring R = cl_find_modint_ring(m);
  10. cl_MI a = R->canonhom(testrandom_I());
  11. cl_MI b = R->canonhom(testrandom_I());
  12. cl_MI z = R->zero();
  13. ASSERT3((a-b) + (b-a) == z, m,a,b);
  14. }
  15. // Check associativity.
  16. for (i = iterations; i > 0; i--) {
  17. cl_I m = testrandom_I();
  18. cl_modint_ring R = cl_find_modint_ring(m);
  19. cl_MI a = R->canonhom(testrandom_I());
  20. cl_MI b = R->canonhom(testrandom_I());
  21. cl_MI c = R->canonhom(testrandom_I());
  22. ASSERT4(a-(b-c) == c-(b-a), m,a,b,c);
  23. }
  24. // Check special case 0.
  25. for (i = iterations; i > 0; i--) {
  26. cl_I m = testrandom_I();
  27. cl_modint_ring R = cl_find_modint_ring(m);
  28. cl_MI a = R->canonhom(testrandom_I());
  29. cl_MI z = R->zero();
  30. ASSERT2(a-z == a, m,a);
  31. ASSERT2(z-(z-a) == a, m,a);
  32. }
  33. return error;
  34. }