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.

53 lines
1.2 KiB

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 <cln/univpoly.h>
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <cln/timing.h>
  9. using namespace cln;
  10. int main (int argc, char * argv[])
  11. {
  12. int repetitions = 1;
  13. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  14. repetitions = atoi(argv[2]);
  15. argc -= 2; argv += 2;
  16. }
  17. if (argc < 2)
  18. exit(1);
  19. int n = atoi(argv[1]);
  20. cl_I m = 100001;
  21. int i;
  22. cl_modint_ring R1 = find_modint_ring(m);
  23. cl_univpoly_ring PR1 = find_univpoly_ring(R1);
  24. cl_UP p1 = PR1->create(n-1);
  25. for (i = 0; i < n; i++)
  26. p1.set_coeff(i, R1->canonhom((int)(1.618033989*i*i)));
  27. p1.finalize();
  28. cout << p1 << endl;
  29. cl_UP sp1 = PR1->zero();
  30. { CL_TIMING;
  31. for (int rep = repetitions; rep > 0; rep--)
  32. { sp1 = square(p1); }
  33. }
  34. cout << sp1 << endl;
  35. }
  36. // Time:
  37. // n modint modint2 neu
  38. // 2 0.000123 0.000082 0.000086
  39. // 5 0.00051 0.00031 0.00032
  40. // 10 0.00169 0.00095 0.00100
  41. // 25 0.0089 0.0049 0.0053
  42. // 50 0.031 0.018 0.020
  43. // 100 0.118 0.070 0.079
  44. // 250 0.72 0.43 0.48
  45. // 500 2.87 1.76 1.91
  46. // 1000 11.4 7.0 8.0