]> www.ginac.de Git - cln.git/blob - src/rational/algebraic/cl_RA_rootp_I.cc
Use paths relative the `src' directory in the #include directives.
[cln.git] / src / rational / algebraic / cl_RA_rootp_I.cc
1 // rootp().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/rational.h"
8
9
10 // Implementation.
11
12 #include "rational/cl_RA.h"
13 #include "cln/integer.h"
14
15 namespace cln {
16
17 bool rootp (const cl_RA& x, const cl_I& n, cl_RA* w)
18 {
19 // Methode:
20 // Bei Integers: klar.
21 // Bei Brüchen a/b : muß a=c^n und b=d^n sein. Dann ist die Wurzel = c/d
22 // (mit ggT(c,d)=1 und d>1).
23         if (integerp(x)) {
24                 DeclareType(cl_I,x);
25                 return rootp(x,n,(cl_I*)w);
26         } else {
27         // x ist Ratio
28         DeclareType(cl_RT,x);
29         var const cl_I& b = denominator(x);
30         var cl_I d;
31         if (!rootp(b,n,&d)) // Nenner auf n-te Potenz testen
32                 return false;
33         var const cl_I& a = numerator(x);
34         var cl_I c;
35         if (!rootp(a,n,&c)) // Zähler auf n-te Potenz testen
36                 return false;
37         // beides n-te Potenzen -> Quotient der Wurzeln bilden
38         *w = I_I_to_RT(c,d); return true;
39 }}
40
41 }  // namespace cln