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.

33 lines
873 B

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