1 | /*****************************************************************************\ |
---|
2 | * Computer Algebra System SINGULAR |
---|
3 | \*****************************************************************************/ |
---|
4 | /** @file facFqSquarefree.h |
---|
5 | * |
---|
6 | * This file provides functions for squarefrees factorizing over |
---|
7 | * \f$ F_{p} \f$ , \f$ F_{p}(\alpha ) \f$ or GF. |
---|
8 | * |
---|
9 | * @author Martin Lee |
---|
10 | * |
---|
11 | **/ |
---|
12 | /*****************************************************************************/ |
---|
13 | |
---|
14 | #ifndef FAC_FQ_SQUAREFREE_H |
---|
15 | #define FAC_FQ_SQUAREFREE_H |
---|
16 | |
---|
17 | #include "cf_assert.h" |
---|
18 | #include "cf_factory.h" |
---|
19 | #include "fac_sqrfree.h" |
---|
20 | |
---|
21 | /// squarefree factorization over a finite field |
---|
22 | /// @a return a list of squarefree factors with multiplicity |
---|
23 | CFFList |
---|
24 | squarefreeFactorization |
---|
25 | (const CanonicalForm & F, ///<[in] a poly |
---|
26 | const Variable & alpha ///<[in] either an algebraic variable, |
---|
27 | ///< i.e. we are over some F_p (alpha) |
---|
28 | ///< or a variable of level 1, i.e. |
---|
29 | ///< we are F_p or GF |
---|
30 | ); |
---|
31 | |
---|
32 | /// squarefree factorization over \f$ F_{p} \f$. |
---|
33 | /// If input is not monic, the leading coefficient is dropped |
---|
34 | /// |
---|
35 | /// @return a list of squarefree factors with multiplicity |
---|
36 | inline |
---|
37 | CFFList FpSqrf (const CanonicalForm& F, ///< [in] a poly |
---|
38 | bool sort= true ///< [in] sort factors by exponent? |
---|
39 | ) |
---|
40 | { |
---|
41 | Variable a= 1; |
---|
42 | int n= F.level(); |
---|
43 | CanonicalForm cont, bufF= F; |
---|
44 | CFFList bufResult; |
---|
45 | |
---|
46 | CFFList result; |
---|
47 | for (int i= n; i >= 1; i++) |
---|
48 | { |
---|
49 | cont= content (bufF, i); |
---|
50 | bufResult= squarefreeFactorization (cont, a); |
---|
51 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
52 | bufResult.removeFirst(); |
---|
53 | result= Union (result, bufResult); |
---|
54 | bufF /= cont; |
---|
55 | if (bufF.inCoeffDomain()) |
---|
56 | break; |
---|
57 | } |
---|
58 | if (!bufF.inCoeffDomain()) |
---|
59 | { |
---|
60 | bufResult= squarefreeFactorization (bufF, a); |
---|
61 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
62 | bufResult.removeFirst(); |
---|
63 | result= Union (result, bufResult); |
---|
64 | } |
---|
65 | if (sort) |
---|
66 | result= sortCFFList (result); |
---|
67 | result.insert (CFFactor (Lc(F), 1)); |
---|
68 | return result; |
---|
69 | } |
---|
70 | |
---|
71 | /// squarefree factorization over \f$ F_{p}(\alpha ) \f$. |
---|
72 | /// If input is not monic, the leading coefficient is dropped |
---|
73 | /// |
---|
74 | /// @return a list of squarefree factors with multiplicity |
---|
75 | inline |
---|
76 | CFFList FqSqrf (const CanonicalForm& F, ///< [in] a poly |
---|
77 | const Variable& alpha, ///< [in] algebraic variable |
---|
78 | bool sort= true ///< [in] sort factors by exponent? |
---|
79 | ) |
---|
80 | { |
---|
81 | int n= F.level(); |
---|
82 | CanonicalForm cont, bufF= F; |
---|
83 | CFFList bufResult; |
---|
84 | |
---|
85 | CFFList result; |
---|
86 | for (int i= n; i >= 1; i++) |
---|
87 | { |
---|
88 | cont= content (bufF, i); |
---|
89 | bufResult= squarefreeFactorization (cont, alpha); |
---|
90 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
91 | bufResult.removeFirst(); |
---|
92 | result= Union (result, bufResult); |
---|
93 | bufF /= cont; |
---|
94 | if (bufF.inCoeffDomain()) |
---|
95 | break; |
---|
96 | } |
---|
97 | if (!bufF.inCoeffDomain()) |
---|
98 | { |
---|
99 | bufResult= squarefreeFactorization (bufF, alpha); |
---|
100 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
101 | bufResult.removeFirst(); |
---|
102 | result= Union (result, bufResult); |
---|
103 | } |
---|
104 | if (sort) |
---|
105 | result= sortCFFList (result); |
---|
106 | result.insert (CFFactor (Lc(F), 1)); |
---|
107 | return result; |
---|
108 | } |
---|
109 | |
---|
110 | /// squarefree factorization over GF. |
---|
111 | /// If input is not monic, the leading coefficient is dropped |
---|
112 | /// |
---|
113 | /// @return a list of squarefree factors with multiplicity |
---|
114 | inline |
---|
115 | CFFList GFSqrf (const CanonicalForm& F, ///< [in] a poly |
---|
116 | bool sort= true ///< [in] sort factors by exponent? |
---|
117 | ) |
---|
118 | { |
---|
119 | ASSERT (CFFactory::gettype() == GaloisFieldDomain, |
---|
120 | "GF as base field expected"); |
---|
121 | return FpSqrf (F, sort); |
---|
122 | } |
---|
123 | |
---|
124 | /// squarefree part of @a F/g, where g is the product of those squarefree |
---|
125 | /// factors whose multiplicity is 0 mod p, if @a F a pth power pthPower= F. |
---|
126 | /// |
---|
127 | /// @return @a sqrfPart returns 1, if F is a pthPower, else it returns the |
---|
128 | /// squarefree part of @a F/g, where g is the product of those |
---|
129 | /// squarefree factors whose multiplicity is 0 mod p |
---|
130 | CanonicalForm |
---|
131 | sqrfPart (const CanonicalForm& F, ///< [in] a poly |
---|
132 | CanonicalForm& pthPower, ///< [in,out] returns F is F is a pthPower |
---|
133 | const Variable& alpha ///< [in] algebraic variable |
---|
134 | ); |
---|
135 | |
---|
136 | /// p^l-th root extraction, where l is maximal |
---|
137 | /// |
---|
138 | /// @return @a maxpthRoot returns a p^l-th root of @a F, where @a l is maximal |
---|
139 | /// @sa pthRoot() |
---|
140 | CanonicalForm |
---|
141 | maxpthRoot (const CanonicalForm & F, ///< [in] a poly which is a pth power |
---|
142 | const int & q, ///< [in] size of the field |
---|
143 | int& l ///< [in,out] @a l maximal, s.t. @a F is |
---|
144 | ///< a p^l-th power |
---|
145 | ); |
---|
146 | |
---|
147 | #endif |
---|
148 | /* FAC_FQ_SQUAREFREE_H */ |
---|
149 | |
---|