X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=src%2Fnumtheory%2Fcl_nt_cornacchia1.cc;h=e43405acc5a29db027cada283529c9f91d2f3246;hb=8b3d91dec77438c0fe679b10869ab29e6cdeba58;hp=36b8e2d28b7b132e2f7b1662c24619e213051207;hpb=dd9e0f894eec7e2a8cf85078330ddc0a6639090b;p=cln.git diff --git a/src/numtheory/cl_nt_cornacchia1.cc b/src/numtheory/cl_nt_cornacchia1.cc index 36b8e2d..e43405a 100644 --- a/src/numtheory/cl_nt_cornacchia1.cc +++ b/src/numtheory/cl_nt_cornacchia1.cc @@ -4,13 +4,15 @@ #include "cl_sysdep.h" // Specification. -#include "cl_numtheory.h" +#include "cln/numtheory.h" // Implementation. #include "cl_xmacros.h" +namespace cln { + // [Cohen], section 1.5.2, algorithm 1.5.2. // For proofs refer to [F. Morain, J.-L. Nicolas: On Cornacchia's algorithm // for solving the diophantine equation u^2+v*d^2=m]. @@ -73,12 +75,12 @@ const cornacchia_t cornacchia1 (const cl_I& d, const cl_I& p) break; } // Compute x with x^2+d == 0 mod p. - var cl_modint_ring R = cl_find_modint_ring(p); + var cl_modint_ring R = find_modint_ring(p); var sqrt_mod_p_t init = sqrt_mod_p(R,R->canonhom(-d)); if (init.condition) return init.condition; if (init.solutions != 2) - cl_abort(); + throw runtime_exception(); // Euclidean algorithm. var cl_I a = p; var cl_I b = R->retract(init.solution[0]); @@ -99,3 +101,5 @@ const cornacchia_t cornacchia1 (const cl_I& d, const cl_I& p) return cornacchia_t(0); return cornacchia_t(1, x,y); } + +} // namespace cln