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.

52 lines
1.2 KiB

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