1 //#define WANT_OBFUSCATING_OPERATORS
2 #include <cln/number.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>
19 fprint(cout, #expr" = "); fprint(cout, expr); fprint(cout, "\n");
21 int main (int argc, char* argv[])
23 (void)argc; (void)argv;
26 cl_F archimedes = pi((float_format_t)10000);
27 fprint(cout, archimedes);
33 cl_FF x1 = "-0.2173f0";
34 cl_FF x2 = "5.5084f9";
35 cl_FF y = "-1.19698f9";
36 fprint(cout, "x1 = "); print_float_binary(cout,x1); fprint(cout, " = "); fprint(cout,x1); fprint(cout, "\n");
37 fprint(cout, "x2 = "); print_float_binary(cout,x2); fprint(cout, " = "); fprint(cout,x2); fprint(cout, "\n");
38 fprint(cout, "y = "); print_float_binary(cout,y); fprint(cout, " = "); fprint(cout,y); fprint(cout, "\n");
40 fprint(cout, "x1*x2 = "); print_float_binary(cout,x); fprint(cout, " = "); fprint(cout,x); fprint(cout, "\n");
48 fprint(cout, "x = "); fprint(cout, x); fprint(cout, "\n");
49 fprint(cout, "y = "); fprint(cout, y); fprint(cout, "\n");
53 cl_I a = "77371252437321868671713407";
55 bool squarep = isqrt(a,&w);
58 DUMP(expt_pos(w,2) <= a);
59 DUMP(a < expt_pos(w+1,2));
63 cl_I m = "79228162513111556826425457664";
64 cl_I a = "19787815858762768436681494528";
65 cl_modint_ring R = find_modint_ring(m);
66 cl_I b = R->retract(R->canonhom(a));
67 cl_I c = mod(a,abs(m));
76 { CL_TIMING; y = sinh(x); }
82 cout << x << " is " << (isprobprime(x) ? "" : "not ") << "prime" << endl;
86 float_format_t f = float_format(atoi(argv[1]));
87 extern cl_LF zeta3 (uintC len);
88 uintC len = (uintC)f/intDsize+1;
89 { CL_TIMING; cout << zeta(2,f) << endl; }
90 { CL_TIMING; cout << expt(pi(f),2)/6 << endl; }
91 { CL_TIMING; cout << zeta(3,f) << endl; }
92 { CL_TIMING; cout << zeta3(len) << endl; }
93 { CL_TIMING; cout << zeta(4,f) << endl; }
96 cl_I a = cl_I(argv[1]);
97 cl_I b = cl_I(argv[2]);
100 cl_I g = xgcd(a,b,&u,&v);
101 cout << "a = " << a << endl;
102 cout << "b = " << b << endl;
103 cout << "gcd = " << gcd(a,b) << endl;
104 cout << "g = " << g << endl;
105 cout << "u = " << u << endl;
106 cout << "v = " << v << endl;