]> www.ginac.de Git - cln.git/blob - src/integer/algebraic/cl_I_rootp.cc
Avoid "suggest explicit braces to avoid ambiguous 'else'" warnings.
[cln.git] / src / integer / algebraic / cl_I_rootp.cc
1 // rootp().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "integer/cl_I.h"
13
14 namespace cln {
15
16 // Methode:
17 // Falls x=0 oder x=1: x = x^n -> JA, x als Ergebnis.
18 // Hier also x>1. Suche ein Integer y > 1 mit x=y^n.
19 // Falls n >= integer_length(x): NEIN. (Da y>=2, müßte x>=2^n gelten.)
20 // Hier also n>0 klein...
21
22 bool rootp (const cl_I& x, uintL n, cl_I* w)
23 {
24         if (eq(x,0) || eq(x,1)) // x=0 oder x=1 ?
25           { *w = x; return true; } // ja -> x als Ergebnis
26         if (n >= integer_length(x))
27           { return false; }
28         return cl_rootp_aux(x,n,w);
29 }
30
31 }  // namespace cln