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.

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