My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
factory
cf_roots.cc
Go to the documentation of this file.
1
//*****************************************************************************
2
3
4
#include "config.h"
5
6
7
#include "
cf_assert.h
"
8
#include "
debug.h
"
9
10
#include "
canonicalform.h
"
11
#include "
cf_util.h
"
12
#include "
imm.h
"
13
#include "
cf_iter.h
"
14
15
#ifdef HAVE_NTL
16
#include "
NTLconvert.h
"
17
#endif
18
19
#ifdef HAVE_FLINT
20
#include "
FLINTconvert.h
"
21
#include "flint/nmod_poly_factor.h"
22
#endif
23
24
#include "
cf_roots.h
"
25
26
int
*
Zp_roots
(
const
CanonicalForm
f
)
27
{
28
int
p
=
getCharacteristic
();
29
#if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20503)
30
nmod_poly_t FLINT_f;
31
convertFacCF2nmod_poly_t
(FLINT_f,
f
);
32
nmod_poly_factor_t fac;
33
nmod_poly_factor_init(fac);
34
nmod_poly_roots(fac,FLINT_f,0);
35
int
*
res
=
NEW_ARRAY
(
int
,1+fac->num);
36
37
int
j
=1;
38
for
(
int
i
=fac->num-1;
i
>=0;
i
--)
39
{
40
// root of (linear) factor: -absolute Term
41
if
(nmod_poly_length(fac->p+
i
)==2)
42
{
43
res
[
j
]=
p
-nmod_poly_get_coeff_ui(fac->p+
i
,0);
44
j
++;
45
}
46
}
47
res
[0]=
j
-1;
48
// cleanup
49
nmod_poly_clear
(FLINT_f);
50
nmod_poly_factor_clear(fac);
51
return
res
;
52
#elif defined(HAVE_NTL)
53
if
(
fac_NTL_char
!=
p
)
54
{
55
fac_NTL_char
=
p
;
56
zz_p::init (
p
);
57
}
58
zz_pX NTL_f=
convertFacCF2NTLzzpX
(
f
);
59
vec_zz_p roots= FindRoots (NTL_f);
60
int
*
res
=
NEW_ARRAY
(
int
,1+roots.length());
61
res
[0]=roots.length();
62
for
(
int
i
=roots.length()-1;
i
>=0;
i
--)
63
{
64
res
[
i
+1]=to_long(rep(roots[
i
]));
65
}
66
return
res
;
67
#else
68
factoryError
(
"NTL/FLINT missing: Zp_roots"
);
69
return
NULL
;
70
#endif
71
}
72
FLINTconvert.h
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
convertFacCF2NTLzzpX
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition
NTLconvert.cc:105
fac_NTL_char
VAR long fac_NTL_char
Definition
NTLconvert.cc:46
NTLconvert.h
Conversion to and from NTL.
canonicalform.h
Header for factory's main class CanonicalForm.
getCharacteristic
int FACTORY_PUBLIC getCharacteristic()
Definition
cf_char.cc:70
i
int i
Definition
cfEzgcd.cc:132
p
int p
Definition
cfModGcd.cc:4086
cf_assert.h
assertions for Factory
NEW_ARRAY
#define NEW_ARRAY(T, N)
Definition
cf_defs.h:64
cf_iter.h
Iterators for CanonicalForm's.
Zp_roots
int * Zp_roots(const CanonicalForm f)
Definition
cf_roots.cc:26
cf_roots.h
factoryError
VAR void(* factoryError)(const char *s)
Definition
cf_util.cc:80
cf_util.h
f
FILE * f
Definition
checklibs.c:9
CanonicalForm
factory's main class
Definition
canonicalform.h:86
debug.h
functions to print debug output
res
CanonicalForm res
Definition
facAbsFact.cc:60
j
int j
Definition
facHensel.cc:110
convertFacCF2nmod_poly_t
convertFacCF2nmod_poly_t(FLINTmipo, M)
nmod_poly_clear
nmod_poly_clear(FLINTmipo)
imm.h
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int,...
NULL
#define NULL
Definition
omList.c:12
Generated on
for My Project by
doxygen 1.17.0
for
Singular