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.

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