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.

110 lines
2.6 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. //#define WANT_OBFUSCATING_OPERATORS
  2. #include <cln/number.h>
  3. #include <cln/io.h>
  4. //#include <cln/complex.h>
  5. //#include <cln/real.h>
  6. //#include <cln/real_io.h>
  7. //#include <cln/output.h>
  8. //#include <cln/ffloat.h>
  9. #include <cln/integer.h>
  10. #include <cln/integer_io.h>
  11. //#include <cln/modinteger.h>
  12. //#include <cln/numtheory.h>
  13. #include <cln/timing.h>
  14. #define DUMP(expr) \
  15. fprint(cout, #expr" = "); fprint(cout, expr); fprint(cout, "\n");
  16. int main (int argc, char* argv[])
  17. {
  18. (void)argc; (void)argv;
  19. #if 0
  20. cl_F archimedes = pi((float_format_t)10000);
  21. fprint(cout, archimedes);
  22. fprint(cout, "\n");
  23. #endif
  24. #if 0
  25. cl_FF a;
  26. cl_FF x1 = "-0.2173f0";
  27. cl_FF x2 = "5.5084f9";
  28. cl_FF y = "-1.19698f9";
  29. fprint(cout, "x1 = "); print_float_binary(cout,x1); fprint(cout, " = "); fprint(cout,x1); fprint(cout, "\n");
  30. fprint(cout, "x2 = "); print_float_binary(cout,x2); fprint(cout, " = "); fprint(cout,x2); fprint(cout, "\n");
  31. fprint(cout, "y = "); print_float_binary(cout,y); fprint(cout, " = "); fprint(cout,y); fprint(cout, "\n");
  32. cl_FF x = x1*x2;
  33. fprint(cout, "x1*x2 = "); print_float_binary(cout,x); fprint(cout, " = "); fprint(cout,x); fprint(cout, "\n");
  34. #endif
  35. #if 0
  36. cl_I x = 10;
  37. cl_I y = ++x;
  38. x *= 2;
  39. x++;
  40. fprint(cout, "x = "); fprint(cout, x); fprint(cout, "\n");
  41. fprint(cout, "y = "); fprint(cout, y); fprint(cout, "\n");
  42. #endif
  43. #if 0
  44. cl_I a = "77371252437321868671713407";
  45. cl_I w;
  46. cl_boolean squarep = isqrt(a,&w);
  47. DUMP(squarep);
  48. DUMP(w);
  49. DUMP(expt_pos(w,2) <= a);
  50. DUMP(a < expt_pos(w+1,2));
  51. #endif
  52. #if 0
  53. cl_I m = "79228162513111556826425457664";
  54. cl_I a = "19787815858762768436681494528";
  55. cl_modint_ring R = find_modint_ring(m);
  56. cl_I b = R->retract(R->canonhom(a));
  57. cl_I c = mod(a,abs(m));
  58. DUMP(b);
  59. DUMP(c);
  60. DUMP(b==c);
  61. #endif
  62. #if 0
  63. cl_N x = argv[1];
  64. cl_N y = sinh(x);
  65. { CL_TIMING; y = sinh(x); }
  66. cout << y << endl;
  67. #endif
  68. #if 0
  69. cl_I x = argv[1];
  70. cout << x << " is " << (isprobprime(x) ? "" : "not ") << "prime" << endl;
  71. #endif
  72. #if 0
  73. float_format_t f = float_format(atoi(argv[1]));
  74. extern cl_LF zeta3 (uintC len);
  75. uintC len = (uintL)f/intDsize+1;
  76. { CL_TIMING; cout << zeta(2,f) << endl; }
  77. { CL_TIMING; cout << expt(pi(f),2)/6 << endl; }
  78. { CL_TIMING; cout << zeta(3,f) << endl; }
  79. { CL_TIMING; cout << zeta3(len) << endl; }
  80. { CL_TIMING; cout << zeta(4,f) << endl; }
  81. #endif
  82. cl_I a = cl_I(argv[1]);
  83. cl_I b = cl_I(argv[2]);
  84. cl_I u;
  85. cl_I v;
  86. cl_I g = xgcd(a,b,&u,&v);
  87. cout << "a = " << a << endl;
  88. cout << "b = " << b << endl;
  89. cout << "gcd = " << gcd(a,b) << endl;
  90. cout << "g = " << g << endl;
  91. cout << "u = " << u << endl;
  92. cout << "v = " << v << endl;
  93. #if 0
  94. cl_F x = argv[1];
  95. cout << x << endl;
  96. #endif
  97. }