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.

54 lines
1.4 KiB

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 "cl_DS.h"
  5. #include "cl_2DS.h"
  6. #include <cln/random.h>
  7. #include "cl_random_impl.h"
  8. #include <cln/abort.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <cln/timing.h>
  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 < 3)
  20. exit(1);
  21. uintL len = atoi(argv[1]);
  22. int threshold = atoi(argv[2]);
  23. SAVE_NUM_STACK;
  24. uintD* a_MSDptr;
  25. uintD* a_LSDptr;
  26. uintD* b_MSDptr;
  27. uintD* b_LSDptr;
  28. uintD* bn_MSDptr;
  29. uintD* bn_LSDptr;
  30. num_stack_alloc(len,a_MSDptr=,a_LSDptr=);
  31. num_stack_alloc(len,b_MSDptr=,b_LSDptr=);
  32. num_stack_alloc(len,bn_MSDptr=,bn_LSDptr=);
  33. random_UDS(default_random_state,a_MSDptr,len);
  34. lspref(a_LSDptr,0) |= 1; // force a to be odd
  35. extern int recip2adic_threshold;
  36. // Check.
  37. recip2adic_threshold = 1000000;
  38. recip2adic(len,a_LSDptr,b_LSDptr);
  39. recip2adic_threshold = threshold;
  40. recip2adic(len,a_LSDptr,bn_LSDptr);
  41. if (compare_loop_msp(b_MSDptr,bn_MSDptr,len)) cl_abort();
  42. // Time.
  43. recip2adic_threshold = 1000000;
  44. { CL_TIMING;
  45. for (int rep = repetitions; rep > 0; rep--)
  46. { recip2adic(len,a_LSDptr,b_LSDptr); }
  47. }
  48. recip2adic_threshold = threshold;
  49. { CL_TIMING;
  50. for (int rep = repetitions; rep > 0; rep--)
  51. { recip2adic(len,a_LSDptr,b_LSDptr); }
  52. }
  53. }