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.

27 lines
586 B

25 years ago
  1. #include "test_I.h"
  2. int test_I_gcd (int iterations)
  3. {
  4. int error = 0;
  5. int i;
  6. // Check commutativity.
  7. for (i = iterations; i > 0; i--) {
  8. cl_I a = testrandom_I();
  9. cl_I b = testrandom_I();
  10. ASSERT2(gcd(a,b) == gcd(b,a), a,b);
  11. }
  12. // Check some axioms.
  13. for (i = iterations; i > 0; i--) {
  14. cl_I a = testrandom_I();
  15. cl_I b = testrandom_I();
  16. cl_I g = gcd(a,b);
  17. if (g > 1) {
  18. ASSERT2(mod(a,g) == 0, a,b);
  19. ASSERT2(mod(b,g) == 0, a,b);
  20. ASSERT2(gcd(exquo(a,g),exquo(b,g)) == 1, a,b);
  21. }
  22. cl_I c = testrandom_I();
  23. ASSERT3(gcd(a+b*c,b) == g, a,b,c);
  24. }
  25. return error;
  26. }