7 #include "cln/rational.h"
13 #include "cln/integer.h"
17 cl_boolean sqrtp (const cl_RA& x, cl_RA* w)
20 // Bei Integers: klar.
21 // Bei Brüchen a/b : muß a=c^2 und b=d^2 sein. Dann ist die Wurzel = c/d
22 // (mit ggT(c,d)=1 und d>1).
25 return sqrtp(x,(cl_I*)w);
29 var const cl_I& b = denominator(x);
31 if (!sqrtp(b,&d)) // Nenner auf Quadratzahl testen
33 var const cl_I& a = numerator(x);
35 if (!sqrtp(a,&c)) // Zähler auf Quadratzahl testen
37 // beides Quadratzahlen -> Quotient der Wurzeln bilden
38 *w = I_I_to_RT(c,d); return cl_true;