source: git/factory/facBivar.h @ c770dc

spielwiese
Last change on this file since c770dc was d990001, checked in by Martin Lee <martinlee84@…>, 13 years ago
HAVE_NTL stuff
  • Property mode set to 100644
File size: 4.5 KB
Line 
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.
32CFList
33biFactorize (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#ifdef HAVE_NTL
42inline
43CFList ratBiSqrfFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
44                           const Variable& v
45                         )
46{
47  CFMap N;
48  CanonicalForm F= compress (G, N);
49  CanonicalForm contentX= content (F, 1);
50  CanonicalForm contentY= content (F, 2);
51  F /= (contentX*contentY);
52  CFFList contentXFactors, contentYFactors;
53  contentXFactors= factorize (contentX, v);
54  contentYFactors= factorize (contentY, v);
55  if (contentXFactors.getFirst().factor().inCoeffDomain())
56    contentXFactors.removeFirst();
57  if (contentYFactors.getFirst().factor().inCoeffDomain())
58    contentYFactors.removeFirst();
59  if (F.inCoeffDomain())
60  {
61    CFList result;
62    for (CFFListIterator i= contentXFactors; i.hasItem(); i++)
63      result.append (N (i.getItem().factor()));
64    for (CFFListIterator i= contentYFactors; i.hasItem(); i++)
65      result.append (N (i.getItem().factor()));
66    if (isOn (SW_RATIONAL))
67    {
68      normalize (result);
69      result.insert (Lc (G));
70    }
71    return result;
72  }
73  mat_ZZ M;
74  vec_ZZ S;
75  F= compress (F, M, S);
76  CFList result= biFactorize (F, v);
77  for (CFListIterator i= result; i.hasItem(); i++)
78    i.getItem()= N (decompress (i.getItem(), M, S));
79  for (CFFListIterator i= contentXFactors; i.hasItem(); i++)
80    result.append (N(i.getItem().factor()));
81  for (CFFListIterator i= contentYFactors; i.hasItem(); i++)
82    result.append (N (i.getItem().factor()));
83  if (isOn (SW_RATIONAL))
84  {
85    normalize (result);
86    result.insert (Lc (G));
87  }
88  return result;
89}
90
91/// factorize a bivariate polynomial over \f$ Q(\alpha) \f$
92///
93/// @return @a ratBiFactorize returns a list of monic factors with
94///         multiplicity, the first element is the leading coefficient.
95inline
96CFFList ratBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
97                        const Variable& v
98                      )
99{
100  CFMap N;
101  CanonicalForm F= compress (G, N);
102  CanonicalForm LcF= Lc (F);
103  CanonicalForm contentX= content (F, 1);
104  CanonicalForm contentY= content (F, 2);
105  F /= (contentX*contentY);
106  CFFList contentXFactors, contentYFactors;
107  contentXFactors= factorize (contentX, v);
108  contentYFactors= factorize (contentY, v);
109  if (contentXFactors.getFirst().factor().inCoeffDomain())
110    contentXFactors.removeFirst();
111  if (contentYFactors.getFirst().factor().inCoeffDomain())
112    contentYFactors.removeFirst();
113  decompress (contentXFactors, N);
114  decompress (contentYFactors, N);
115  CFFList result, resultRoot;
116  if (F.inCoeffDomain())
117  {
118    result= Union (contentXFactors, contentYFactors);
119    if (isOn (SW_RATIONAL))
120    {
121      normalize (result);
122      result.insert (CFFactor (LcF, 1));
123    }
124    return result;
125  }
126  mat_ZZ M;
127  vec_ZZ S;
128  F= compress (F, M, S);
129  CFFList sqrfFactors= sqrFree (F);
130  for (CFFListIterator i= sqrfFactors; i.hasItem(); i++)
131  {
132    CFList tmp= ratBiSqrfFactorize (i.getItem().factor(), v);
133    for (CFListIterator j= tmp; j.hasItem(); j++)
134    {
135      if (j.getItem().inCoeffDomain()) continue;
136      result.append (CFFactor (N (decompress (j.getItem(), M, S)), i.getItem().exp()));
137    }
138  }
139  result= Union (result, contentXFactors);
140  result= Union (result, contentYFactors);
141  if (isOn (SW_RATIONAL))
142  {
143    normalize (result);
144    result.insert (CFFactor (LcF, 1));
145  }
146  return result;
147}
148
149#endif
150
151/// convert a CFFList to a CFList by dropping the multiplicity
152CFList conv (const CFFList& L ///< [in] a CFFList
153            );
154
155#endif
156
Note: See TracBrowser for help on using the repository browser.