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

25 years ago
  1. #include <cl_number.h>
  2. #include <cl_io.h>
  3. #include <cl_float.h>
  4. #include <cl_float_io.h>
  5. #include <cl_lfloat.h>
  6. #include "cl_LF.h"
  7. #include <cl_real.h>
  8. #include <cl_random.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <cl_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 < 2)
  20. exit(1);
  21. extern int cl_sinh_algo;
  22. uintL len = atoi(argv[1]);
  23. #if 0
  24. cl_LF one = cl_I_to_LF(1,len);
  25. cl_F x = scale_float(random_F(one),-1);
  26. cout << x << endl;
  27. #else
  28. cl_F x = sqrt(cl_I_to_LF(2,len))-1;
  29. #endif
  30. cl_F y;
  31. y = exp(x); // fill cache
  32. #if 0
  33. cl_sinh_algo = 0;
  34. { CL_TIMING;
  35. for (int rep = repetitions; rep > 0; rep--)
  36. { y = sinh(x); }
  37. }
  38. cout << y << endl;
  39. cl_sinh_algo = 1;
  40. #endif
  41. { CL_TIMING;
  42. for (int rep = repetitions; rep > 0; rep--)
  43. { y = sinh(x); }
  44. }
  45. cout << y << endl;
  46. { CL_TIMING;
  47. for (int rep = repetitions; rep > 0; rep--)
  48. { y = exp(x); y = (y-recip(y))/2; }
  49. }
  50. cout << y << endl;
  51. }