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.

53 lines
1.1 KiB

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/float_io.h>
  5. #include <cln/lfloat.h>
  6. #include "cl_LF.h"
  7. #include <cln/real.h>
  8. #include <cln/random.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <cln/timing.h>
  12. using namespace cln;
  13. int main (int argc, char * argv[])
  14. {
  15. int repetitions = 1;
  16. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  17. repetitions = atoi(argv[2]);
  18. argc -= 2; argv += 2;
  19. }
  20. if (argc < 2)
  21. exit(1);
  22. extern int cl_sinh_algo;
  23. uintL len = atoi(argv[1]);
  24. #if 0
  25. cl_LF one = cl_I_to_LF(1,len);
  26. cl_F x = scale_float(random_F(one),-1);
  27. cout << x << endl;
  28. #else
  29. cl_F x = sqrt(cl_I_to_LF(2,len))-1;
  30. #endif
  31. cl_F y;
  32. y = exp(x); // fill cache
  33. #if 0
  34. cl_sinh_algo = 0;
  35. { CL_TIMING;
  36. for (int rep = repetitions; rep > 0; rep--)
  37. { y = sinh(x); }
  38. }
  39. cout << y << endl;
  40. cl_sinh_algo = 1;
  41. #endif
  42. { CL_TIMING;
  43. for (int rep = repetitions; rep > 0; rep--)
  44. { y = sinh(x); }
  45. }
  46. cout << y << endl;
  47. { CL_TIMING;
  48. for (int rep = repetitions; rep > 0; rep--)
  49. { y = exp(x); y = (y-recip(y))/2; }
  50. }
  51. cout << y << endl;
  52. }