1 | /*****************************************************************************\ |
---|
2 | * Computer Algebra System SINGULAR |
---|
3 | \*****************************************************************************/ |
---|
4 | /** @file facBivar.h |
---|
5 | * |
---|
6 | * bivariate factorization over Q(a) |
---|
7 | * |
---|
8 | * @author Martin Lee |
---|
9 | * |
---|
10 | * @internal @version \$Id$ |
---|
11 | * |
---|
12 | **/ |
---|
13 | /*****************************************************************************/ |
---|
14 | |
---|
15 | #ifndef FAC_BIVAR_H |
---|
16 | #define FAC_BIVAR_H |
---|
17 | |
---|
18 | #include <config.h> |
---|
19 | |
---|
20 | #include "assert.h" |
---|
21 | |
---|
22 | #include "facFqBivarUtil.h" |
---|
23 | #include "DegreePattern.h" |
---|
24 | #include "cf_util.h" |
---|
25 | #include "facFqSquarefree.h" |
---|
26 | #include "cf_map.h" |
---|
27 | #include "cfNewtonPolygon.h" |
---|
28 | #include "algext.h" |
---|
29 | |
---|
30 | /// @return @a biFactorize returns a list of factors of F. If F is not monic |
---|
31 | /// its leading coefficient is not outputted. |
---|
32 | CFList |
---|
33 | biFactorize (const CanonicalForm& F, ///< [in] a bivariate poly |
---|
34 | const Variable& v ///< [in] some algebraic variable |
---|
35 | ); |
---|
36 | |
---|
37 | /// factorize a squarefree bivariate polynomial over \f$ Q(\alpha) \f$. |
---|
38 | /// |
---|
39 | /// @ return @a ratBiSqrfFactorize returns a list of monic factors, the first |
---|
40 | /// element is the leading coefficient. |
---|
41 | inline |
---|
42 | CFList ratBiSqrfFactorize (const CanonicalForm & G, ///< [in] a bivariate poly |
---|
43 | const Variable& v |
---|
44 | ) |
---|
45 | { |
---|
46 | CFMap N; |
---|
47 | CanonicalForm F= compress (G, N); |
---|
48 | CanonicalForm contentX= content (F, 1); |
---|
49 | CanonicalForm contentY= content (F, 2); |
---|
50 | F /= (contentX*contentY); |
---|
51 | CFFList contentXFactors, contentYFactors; |
---|
52 | contentXFactors= factorize (contentX, v); |
---|
53 | contentYFactors= factorize (contentY, v); |
---|
54 | if (contentXFactors.getFirst().factor().inCoeffDomain()) |
---|
55 | contentXFactors.removeFirst(); |
---|
56 | if (contentYFactors.getFirst().factor().inCoeffDomain()) |
---|
57 | contentYFactors.removeFirst(); |
---|
58 | if (F.inCoeffDomain()) |
---|
59 | { |
---|
60 | CFList result; |
---|
61 | for (CFFListIterator i= contentXFactors; i.hasItem(); i++) |
---|
62 | result.append (N (i.getItem().factor())); |
---|
63 | for (CFFListIterator i= contentYFactors; i.hasItem(); i++) |
---|
64 | result.append (N (i.getItem().factor())); |
---|
65 | if (isOn (SW_RATIONAL)) |
---|
66 | { |
---|
67 | normalize (result); |
---|
68 | result.insert (Lc (G)); |
---|
69 | } |
---|
70 | return result; |
---|
71 | } |
---|
72 | mat_ZZ M; |
---|
73 | vec_ZZ S; |
---|
74 | F= compress (F, M, S); |
---|
75 | CFList result= biFactorize (F, v); |
---|
76 | for (CFListIterator i= result; i.hasItem(); i++) |
---|
77 | i.getItem()= N (decompress (i.getItem(), M, S)); |
---|
78 | for (CFFListIterator i= contentXFactors; i.hasItem(); i++) |
---|
79 | result.append (N(i.getItem().factor())); |
---|
80 | for (CFFListIterator i= contentYFactors; i.hasItem(); i++) |
---|
81 | result.append (N (i.getItem().factor())); |
---|
82 | if (isOn (SW_RATIONAL)) |
---|
83 | { |
---|
84 | normalize (result); |
---|
85 | result.insert (Lc (G)); |
---|
86 | } |
---|
87 | return result; |
---|
88 | } |
---|
89 | |
---|
90 | /// factorize a bivariate polynomial over \f$ Q(\alpha) \f$ |
---|
91 | /// |
---|
92 | /// @return @a ratBiFactorize returns a list of monic factors with |
---|
93 | /// multiplicity, the first element is the leading coefficient. |
---|
94 | inline |
---|
95 | CFFList ratBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly |
---|
96 | const Variable& v |
---|
97 | ) |
---|
98 | { |
---|
99 | CFMap N; |
---|
100 | CanonicalForm F= compress (G, N); |
---|
101 | CanonicalForm LcF= Lc (F); |
---|
102 | CanonicalForm contentX= content (F, 1); |
---|
103 | CanonicalForm contentY= content (F, 2); |
---|
104 | F /= (contentX*contentY); |
---|
105 | CFFList contentXFactors, contentYFactors; |
---|
106 | contentXFactors= factorize (contentX, v); |
---|
107 | contentYFactors= factorize (contentY, v); |
---|
108 | if (contentXFactors.getFirst().factor().inCoeffDomain()) |
---|
109 | contentXFactors.removeFirst(); |
---|
110 | if (contentYFactors.getFirst().factor().inCoeffDomain()) |
---|
111 | contentYFactors.removeFirst(); |
---|
112 | decompress (contentXFactors, N); |
---|
113 | decompress (contentYFactors, N); |
---|
114 | CFFList result, resultRoot; |
---|
115 | if (F.inCoeffDomain()) |
---|
116 | { |
---|
117 | result= Union (contentXFactors, contentYFactors); |
---|
118 | if (isOn (SW_RATIONAL)) |
---|
119 | { |
---|
120 | normalize (result); |
---|
121 | result.insert (CFFactor (LcF, 1)); |
---|
122 | } |
---|
123 | return result; |
---|
124 | } |
---|
125 | mat_ZZ M; |
---|
126 | vec_ZZ S; |
---|
127 | F= compress (F, M, S); |
---|
128 | CanonicalForm sqrfP= sqrfPart (F); |
---|
129 | CFList buf; |
---|
130 | buf= biFactorize (sqrfP, v); |
---|
131 | result= multiplicity (F, buf); |
---|
132 | for (CFFListIterator i= result; i.hasItem(); i++) |
---|
133 | i.getItem()= CFFactor (N (decompress (i.getItem().factor(), M, S)), |
---|
134 | i.getItem().exp()); |
---|
135 | result= Union (result, contentXFactors); |
---|
136 | result= Union (result, contentYFactors); |
---|
137 | if (isOn (SW_RATIONAL)) |
---|
138 | { |
---|
139 | normalize (result); |
---|
140 | result.insert (CFFactor (LcF, 1)); |
---|
141 | } |
---|
142 | return result; |
---|
143 | } |
---|
144 | |
---|
145 | /// convert a CFFList to a CFList by dropping the multiplicity |
---|
146 | CFList conv (const CFFList& L ///< [in] a CFFList |
---|
147 | ); |
---|
148 | |
---|
149 | #endif |
---|
150 | |
---|