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.

43 lines
868 B

25 years ago
25 years ago
25 years ago
  1. #include <cln/number.h>
  2. #include <cln/io.h>
  3. #include <cln/float.h>
  4. #include <cln/lfloat.h>
  5. #include "cl_LF.h"
  6. #include <cln/real.h>
  7. #include <cln/random.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <cln/timing.h>
  11. int main (int argc, char * argv[])
  12. {
  13. int repetitions = 1;
  14. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  15. repetitions = atoi(argv[2]);
  16. argc -= 2; argv += 2;
  17. }
  18. if (argc < 2)
  19. exit(1);
  20. extern int cl_cos_algo;
  21. uintL len = atoi(argv[1]);
  22. #if 0
  23. cl_LF one = cl_I_to_LF(1,len);
  24. cl_F x = scale_float(random_F(one),-1);
  25. cout << x << endl;
  26. #else
  27. cl_F x = sqrt(cl_I_to_LF(2,len))-1;
  28. #endif
  29. cl_F y;
  30. cl_cos_algo = 0;
  31. { CL_TIMING;
  32. for (int rep = repetitions; rep > 0; rep--)
  33. { y = cos(x); }
  34. }
  35. cout << y << endl;
  36. cl_cos_algo = 1;
  37. { CL_TIMING;
  38. for (int rep = repetitions; rep > 0; rep--)
  39. { y = cos(x); }
  40. }
  41. cout << y << endl;
  42. }