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.

64 lines
1.7 KiB

25 years ago
  1. #include <cln/number.h>
  2. #include <cln/io.h>
  3. #include <cln/float.h>
  4. #include <cln/real.h>
  5. #include <cln/random.h>
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <cln/timing.h>
  9. #include "float/lfloat/cl_LF.h"
  10. #include <iostream>
  11. using namespace cln;
  12. using namespace std;
  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. uintL len = atoi(argv[1]);
  23. extern cl_LF compute_catalanconst_ramanujan (uintC len);
  24. extern cl_LF compute_catalanconst_ramanujan_fast (uintC len);
  25. extern cl_LF compute_catalanconst_expintegral1 (uintC len);
  26. extern cl_LF compute_catalanconst_expintegral2 (uintC len);
  27. extern cl_LF compute_catalanconst_cvz1 (uintC len);
  28. extern cl_LF compute_catalanconst_cvz2 (uintC len);
  29. cl_LF p;
  30. ln(cl_I_to_LF(1000,len+10)); // fill cache
  31. { CL_TIMING;
  32. for (int rep = repetitions; rep > 0; rep--)
  33. { p = compute_catalanconst_ramanujan(len); }
  34. }
  35. cout << p << endl;
  36. { CL_TIMING;
  37. for (int rep = repetitions; rep > 0; rep--)
  38. { p = compute_catalanconst_ramanujan_fast(len); }
  39. }
  40. cout << p << endl;
  41. #if 0
  42. { CL_TIMING;
  43. for (int rep = repetitions; rep > 0; rep--)
  44. { p = compute_catalanconst_expintegral1(len); }
  45. }
  46. cout << p << endl;
  47. { CL_TIMING;
  48. for (int rep = repetitions; rep > 0; rep--)
  49. { p = compute_catalanconst_expintegral2(len); }
  50. }
  51. cout << p << endl;
  52. #endif
  53. { CL_TIMING;
  54. for (int rep = repetitions; rep > 0; rep--)
  55. { p = compute_catalanconst_cvz1(len); }
  56. }
  57. cout << p << endl;
  58. { CL_TIMING;
  59. for (int rep = repetitions; rep > 0; rep--)
  60. { p = compute_catalanconst_cvz2(len); }
  61. }
  62. cout << p << endl;
  63. }