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.

72 lines
1.8 KiB

25 years ago
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. namespace cln
  12. {
  13. // FIXME: using internal functions is a bad idea (even if it works
  14. // on some ELF systems)
  15. extern cl_LF compute_catalanconst_ramanujan (uintC len);
  16. extern cl_LF compute_catalanconst_ramanujan_fast (uintC len);
  17. extern cl_LF compute_catalanconst_expintegral1 (uintC len);
  18. extern cl_LF compute_catalanconst_expintegral2 (uintC len);
  19. extern cl_LF compute_catalanconst_cvz1 (uintC len);
  20. extern cl_LF compute_catalanconst_cvz2 (uintC len);
  21. }
  22. using namespace cln;
  23. using namespace std;
  24. int main (int argc, char * argv[])
  25. {
  26. int repetitions = 1;
  27. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  28. repetitions = atoi(argv[2]);
  29. argc -= 2; argv += 2;
  30. }
  31. if (argc < 2)
  32. exit(1);
  33. uintL len = atoi(argv[1]);
  34. cl_LF p;
  35. ln(cl_I_to_LF(1000,len+10)); // fill cache
  36. { CL_TIMING;
  37. for (int rep = repetitions; rep > 0; rep--)
  38. { p = compute_catalanconst_ramanujan(len); }
  39. }
  40. cout << p << endl;
  41. { CL_TIMING;
  42. for (int rep = repetitions; rep > 0; rep--)
  43. { p = compute_catalanconst_ramanujan_fast(len); }
  44. }
  45. cout << p << endl;
  46. #if 0
  47. { CL_TIMING;
  48. for (int rep = repetitions; rep > 0; rep--)
  49. { p = compute_catalanconst_expintegral1(len); }
  50. }
  51. cout << p << endl;
  52. { CL_TIMING;
  53. for (int rep = repetitions; rep > 0; rep--)
  54. { p = compute_catalanconst_expintegral2(len); }
  55. }
  56. cout << p << endl;
  57. #endif
  58. { CL_TIMING;
  59. for (int rep = repetitions; rep > 0; rep--)
  60. { p = compute_catalanconst_cvz1(len); }
  61. }
  62. cout << p << endl;
  63. { CL_TIMING;
  64. for (int rep = repetitions; rep > 0; rep--)
  65. { p = compute_catalanconst_cvz2(len); }
  66. }
  67. cout << p << endl;
  68. }