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.1 KiB

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 "float/lfloat/cl_LF.h"
  6. #include <cln/real.h>
  7. #include <cln/random.h>
  8. #include <cstdlib>
  9. #include <cstring>
  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 < 3)
  19. exit(1);
  20. extern double cl_sin_factor;
  21. extern int cl_sin_algo;
  22. extern int cl_aux_algo;
  23. uintL len = atoi(argv[1]);
  24. cl_sin_factor = atof(argv[2]);
  25. #if 0
  26. cl_LF one = cl_I_to_LF(1,len);
  27. cl_F x = scale_float(random_F(one),-1);
  28. cout << x << endl;
  29. #else
  30. cl_F x = sqrt(cl_I_to_LF(2,len))-1;
  31. #endif
  32. cl_F y;
  33. cl_sin_algo = 0;
  34. { CL_TIMING;
  35. for (int rep = repetitions; rep > 0; rep--)
  36. { y = sin(x); }
  37. }
  38. cout << y << endl;
  39. cl_sin_algo = 1; cl_aux_algo = 0;
  40. { CL_TIMING;
  41. for (int rep = repetitions; rep > 0; rep--)
  42. { y = sin(x); }
  43. }
  44. cout << y << endl;
  45. cl_sin_algo = 1; cl_aux_algo = 1;
  46. { CL_TIMING;
  47. for (int rep = repetitions; rep > 0; rep--)
  48. { y = sin(x); }
  49. }
  50. cout << y << endl;
  51. }