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.

43 lines
1019 B

25 years ago
25 years ago
25 years ago
  1. #include <cln/number.h>
  2. #include <cln/io.h>
  3. #include <cln/integer.h>
  4. #include <cln/lfloat.h>
  5. #include <cln/rational.h>
  6. #include <cln/float_io.h>
  7. #include <cln/random.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <cln/timing.h>
  11. int main (int argc, char * argv[])
  12. {
  13. int repetitions = 1;
  14. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  15. repetitions = atoi(argv[2]);
  16. argc -= 2; argv += 2;
  17. }
  18. if (argc < 4)
  19. exit(1);
  20. uintL m1 = atoi(argv[1]);
  21. cl_I m2 = cl_I(argv[2]);
  22. cl_I M2 = (cl_I)1 << (intDsize*m2);
  23. cl_I m3 = cl_I(argv[3]);
  24. cl_I M3 = (cl_I)1 << (intDsize*m3);
  25. float_format_t M1 = (float_format_t)(m1*intDsize);
  26. cl_I u;
  27. cl_I v;
  28. do { u = random_I(M2); } while (zerop(u));
  29. do { v = random_I(M3); } while (zerop(v) || gcd(u,v) > 1);
  30. cl_RA y = u / v;
  31. cl_F p;
  32. { CL_TIMING;
  33. for (int rep = repetitions; rep > 0; rep--)
  34. { p = cl_float(u,M1)/cl_float(v,M1); }
  35. }
  36. cout << p << endl;
  37. { CL_TIMING;
  38. for (int rep = repetitions; rep > 0; rep--)
  39. { p = cl_float(y,M1); }
  40. }
  41. cout << p << endl;
  42. }