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.

58 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
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 <stdlib.h>
  6. #include <string.h>
  7. #include <cln/timing.h>
  8. int main (int argc, char * argv[])
  9. {
  10. int repetitions = 1;
  11. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  12. repetitions = atoi(argv[2]);
  13. argc -= 2; argv += 2;
  14. }
  15. if (argc < 1)
  16. exit(1);
  17. cl_I p = "1269281897404513557783934075031171555202695168107";
  18. cl_modint_ring R = find_modint_ring(p);
  19. {
  20. cl_MI a = R->canonhom("1111111111111111111111111111111111111111111111111");
  21. cl_MI b = R->canonhom("777777777777777777777777777777777777777777777777");
  22. cout << "product modulo p" << endl;
  23. { CL_TIMING;
  24. for (int rep = repetitions; rep > 0; rep--)
  25. { cl_MI c = R->mul(a,b); }
  26. }
  27. cout << "square modulo p" << endl;
  28. { CL_TIMING;
  29. for (int rep = repetitions; rep > 0; rep--)
  30. { cl_MI c = R->square(a); }
  31. }
  32. cout << "quotient modulo p" << endl;
  33. { CL_TIMING;
  34. for (int rep = repetitions; rep > 0; rep--)
  35. { cl_MI c = R->div(a,b); }
  36. }
  37. }
  38. {
  39. cl_MI a = R->canonhom("1234567890123456789012345678901234567890123456789");
  40. cl_MI b = R->canonhom("909090909090909090909090909090909090909090909090");
  41. cout << "product modulo p" << endl;
  42. { CL_TIMING;
  43. for (int rep = repetitions; rep > 0; rep--)
  44. { cl_MI c = R->mul(a,b); }
  45. }
  46. cout << "square modulo p" << endl;
  47. { CL_TIMING;
  48. for (int rep = repetitions; rep > 0; rep--)
  49. { cl_MI c = R->square(a); }
  50. }
  51. cout << "quotient modulo p" << endl;
  52. { CL_TIMING;
  53. for (int rep = repetitions; rep > 0; rep--)
  54. { cl_MI c = R->div(a,b); }
  55. }
  56. }
  57. }