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

25 years ago
  1. //#define WANT_OBFUSCATING_OPERATORS
  2. #include <cl_number.h>
  3. #include <cl_io.h>
  4. //#include <cl_complex.h>
  5. //#include <cl_real.h>
  6. //#include <cl_real_io.h>
  7. //#include <cl_output.h>
  8. //#include <cl_ffloat.h>
  9. #include <cl_integer.h>
  10. #include <cl_integer_io.h>
  11. //#include <cl_modinteger.h>
  12. //#include <cl_numtheory.h>
  13. #include <cl_timing.h>
  14. #define DUMP(expr) \
  15. fprint(cl_stdout, #expr" = "); fprint(cl_stdout, expr); fprint(cl_stdout, "\n");
  16. int main (int argc, char* argv[])
  17. {
  18. (void)argc; (void)argv;
  19. #if 0
  20. cl_F pi = cl_pi((cl_float_format_t)10000);
  21. fprint(cl_stdout, pi);
  22. fprint(cl_stdout, "\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(cl_stdout, "x1 = "); print_float_binary(cl_stdout,x1); fprint(cl_stdout, " = "); fprint(cl_stdout,x1); fprint(cl_stdout, "\n");
  30. fprint(cl_stdout, "x2 = "); print_float_binary(cl_stdout,x2); fprint(cl_stdout, " = "); fprint(cl_stdout,x2); fprint(cl_stdout, "\n");
  31. fprint(cl_stdout, "y = "); print_float_binary(cl_stdout,y); fprint(cl_stdout, " = "); fprint(cl_stdout,y); fprint(cl_stdout, "\n");
  32. cl_FF x = x1*x2;
  33. fprint(cl_stdout, "x1*x2 = "); print_float_binary(cl_stdout,x); fprint(cl_stdout, " = "); fprint(cl_stdout,x); fprint(cl_stdout, "\n");
  34. #endif
  35. #if 0
  36. cl_I x = 10;
  37. cl_I y = ++x;
  38. x *= 2;
  39. x++;
  40. fprint(cl_stdout, "x = "); fprint(cl_stdout, x); fprint(cl_stdout, "\n");
  41. fprint(cl_stdout, "y = "); fprint(cl_stdout, y); fprint(cl_stdout, "\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 = cl_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. cl_float_format_t f = cl_float_format(atoi(argv[1]));
  74. extern cl_LF cl_zeta3 (uintC len);
  75. uintC len = (uintL)f/intDsize+1;
  76. { CL_TIMING; cout << cl_zeta(2,f) << endl; }
  77. { CL_TIMING; cout << expt(cl_pi(f),2)/6 << endl; }
  78. { CL_TIMING; cout << cl_zeta(3,f) << endl; }
  79. { CL_TIMING; cout << cl_zeta3(len) << endl; }
  80. { CL_TIMING; cout << cl_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. }