]> www.ginac.de Git - cln.git/blobdiff - src/numtheory/cl_nt_cornacchia1.cc
Fix scale_float for large factors on x86.
[cln.git] / src / numtheory / cl_nt_cornacchia1.cc
index 36b8e2d28b7b132e2f7b1662c24619e213051207..3224ccff64a123979cccaa1facb70643be0d7cb8 100644 (file)
@@ -1,15 +1,17 @@
 // cornacchia1().
 
 // General includes.
-#include "cl_sysdep.h"
+#include "base/cl_sysdep.h"
 
 // Specification.
-#include "cl_numtheory.h"
+#include "cln/numtheory.h"
 
 
 // Implementation.
 
-#include "cl_xmacros.h"
+#include "base/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
@@ -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