My Project
Loading...
Searching...
No Matches
Functions
cf_roots.h File Reference

Go to the source code of this file.

Functions

int *FACTORY_PUBLIC Zp_roots (const CanonicalForm f)
 

Function Documentation

◆ Zp_roots()

int *FACTORY_PUBLIC Zp_roots ( const CanonicalForm  f)

Definition at line 25 of file cf_roots.cc.

26{
27 int p= getCharacteristic ();
28 #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20503)
29 nmod_poly_t FLINT_f;
31 nmod_poly_factor_t fac;
32 nmod_poly_factor_init(fac);
33 nmod_poly_roots(fac,FLINT_f,0);
34 int *res=NEW_ARRAY(int,1+fac->num);
35
36 int j=1;
37 for(int i=fac->num-1; i>=0;i--)
38 {
39 // root of (linear) factor: -absolute Term
40 if (nmod_poly_length(fac->p+i)==2)
41 {
42 res[j]=p-nmod_poly_get_coeff_ui(fac->p+i,0);
43 j++;
44 }
45 }
46 res[0]=j-1;
47 // cleanup
48 nmod_poly_clear(FLINT_f);
49 nmod_poly_factor_clear(fac);
50 return res;
51 #elif defined(HAVE_NTL)
52 if (fac_NTL_char != p)
53 {
55 zz_p::init (p);
56 }
57 zz_pX NTL_f= convertFacCF2NTLzzpX (f);
58 vec_zz_p roots= FindRoots (NTL_f);
59 int *res=NEW_ARRAY(int,1+roots.length());
60 res[0]=roots.length();
61 for(int i=roots.length()-1;i>=0;i--)
62 {
63 res[i+1]=to_long(rep(roots[i]));
64 }
65 return res;
66 #else
67 factoryError("NTL/FLINT missing: Zp_roots");
68 return NULL;
69 #endif
70}
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:105
VAR long fac_NTL_char
Definition: NTLconvert.cc:46
int FACTORY_PUBLIC getCharacteristic()
Definition: cf_char.cc:70
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
#define NEW_ARRAY(T, N)
Definition: cf_defs.h:64
VAR void(* factoryError)(const char *s)
Definition: cf_util.cc:80
FILE * f
Definition: checklibs.c:9
CanonicalForm res
Definition: facAbsFact.cc:60
int j
Definition: facHensel.cc:110
convertFacCF2nmod_poly_t(FLINTmipo, M)
nmod_poly_clear(FLINTmipo)
#define NULL
Definition: omList.c:12