# source:git/factory/facBivar.h@5f9b47

fieker-DuValspielwiese
Last change on this file since 5f9b47 was 5f9b47, checked in by Martin Lee <martinlee84@…>, 13 years ago
use sqrfree factorization instead of sqrfree part extraction for factorization ove Q(a) git-svn-id: file:///usr/local/Singular/svn/trunk@14412 2c84dea3-7e68-4137-9b89-c4e89433aadc
• 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.
41inline
42CFList 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.
94inline
95CFFList 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  CFFList sqrfFactors= sqrFree (F);
129  for (CFFListIterator i= sqrfFactors; i.hasItem(); i++)
130  {
131    CFList tmp= ratBiSqrfFactorize (i.getItem().factor(), v);
132    for (CFListIterator j= tmp; j.hasItem(); j++)
133    {
134      if (j.getItem().inCoeffDomain()) continue;
135      result.append (CFFactor (N (decompress (j.getItem(), M, S)), i.getItem().exp()));
136    }
137  }
138  result= Union (result, contentXFactors);
139  result= Union (result, contentYFactors);
140  if (isOn (SW_RATIONAL))
141  {
142    normalize (result);
143    result.insert (CFFactor (LcF, 1));
144  }
145  return result;
146}
147
148/// convert a CFFList to a CFList by dropping the multiplicity
149CFList conv (const CFFList& L ///< [in] a CFFList
150            );
151
152#endif
153
Note: See TracBrowser for help on using the repository browser.