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.

61 lines
1.6 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
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/modinteger.h>
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <cln/timing.h>
  8. using namespace cln;
  9. #include <iostream>
  10. using namespace std;
  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 < 1)
  19. exit(1);
  20. cl_I p = "1269281897404513557783934075031171555202695168107";
  21. cl_modint_ring R = find_modint_ring(p);
  22. {
  23. cl_MI a = R->canonhom("1111111111111111111111111111111111111111111111111");
  24. cl_MI b = R->canonhom("777777777777777777777777777777777777777777777777");
  25. cout << "product modulo p" << endl;
  26. { CL_TIMING;
  27. for (int rep = repetitions; rep > 0; rep--)
  28. { cl_MI c = R->mul(a,b); }
  29. }
  30. cout << "square modulo p" << endl;
  31. { CL_TIMING;
  32. for (int rep = repetitions; rep > 0; rep--)
  33. { cl_MI c = R->square(a); }
  34. }
  35. cout << "quotient modulo p" << endl;
  36. { CL_TIMING;
  37. for (int rep = repetitions; rep > 0; rep--)
  38. { cl_MI c = R->div(a,b); }
  39. }
  40. }
  41. {
  42. cl_MI a = R->canonhom("1234567890123456789012345678901234567890123456789");
  43. cl_MI b = R->canonhom("909090909090909090909090909090909090909090909090");
  44. cout << "product modulo p" << endl;
  45. { CL_TIMING;
  46. for (int rep = repetitions; rep > 0; rep--)
  47. { cl_MI c = R->mul(a,b); }
  48. }
  49. cout << "square modulo p" << endl;
  50. { CL_TIMING;
  51. for (int rep = repetitions; rep > 0; rep--)
  52. { cl_MI c = R->square(a); }
  53. }
  54. cout << "quotient modulo p" << endl;
  55. { CL_TIMING;
  56. for (int rep = repetitions; rep > 0; rep--)
  57. { cl_MI c = R->div(a,b); }
  58. }
  59. }
  60. }