source: git/factory/facFactorize.h @ dccceb

spielwiese
Last change on this file since dccceb was d990001, checked in by Martin Lee <martinlee84@…>, 13 years ago
HAVE_NTL stuff
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR
3\*****************************************************************************/
4/** @file facFactorize.h
5 *
6 * multivariate factorization over Q(a)
7 *
8 * @author Martin Lee
9 *
10 * @internal @version \$Id$
11 *
12 **/
13/*****************************************************************************/
14
15#ifndef FAC_FACTORIZE_H
16#define FAC_FACTORIZE_H
17
18// #include "config.h"
19
20#include "facBivar.h"
21#include "facFqBivarUtil.h"
22
23/// Factorization over Q (a)
24///
25/// @return @a multiFactorize returns a factorization of F
26CFList
27multiFactorize (const CanonicalForm& F,     ///< [in] poly to be factored
28                const Variable& v           ///< [in] some algebraic variable
29               );
30
31/// factorize a squarefree multivariate polynomial over \f$ Q(\alpha) \f$
32///
33/// @return @a ratSqrfFactorize returns a list of monic factors, the first
34///         element is the leading coefficient.
35#ifdef HAVE_NTL
36inline
37CFList ratSqrfFactorize (const CanonicalForm & G, ///< [in] a multivariate poly
38                         const Variable& v
39                       )
40{
41  if (getNumVars (G) == 2)
42    return ratBiSqrfFactorize (G, v);
43  CanonicalForm F= G;
44  if (isOn (SW_RATIONAL))
45    F *= bCommonDen (F);
46  CFList result= multiFactorize (F, v);
47  if (isOn (SW_RATIONAL))
48  {
49    normalize (result);
50    result.insert (Lc(F));
51  }
52  return result;
53}
54
55/// factorize a multivariate polynomial over \f$ Q(\alpha) \f$
56///
57/// @return @a ratFactorize returns a list of monic factors with
58///         multiplicity, the first element is the leading coefficient.
59inline
60CFFList ratFactorize (const CanonicalForm& G, ///< [in] a multivariate poly
61                      const Variable& v
62                    )
63{
64  if (getNumVars (G) == 2)
65  {
66    CFFList result= ratBiFactorize (G,v);
67    return result;
68  }
69  CanonicalForm F= G;
70  CanonicalForm LcF= Lc (F);
71  if (isOn (SW_RATIONAL))
72    F *= bCommonDen (F);
73
74  CFFList result;
75  CFFList sqrfFactors= sqrFree (F);
76  for (CFFListIterator i= sqrfFactors; i.hasItem(); i++)
77  {
78    CFList tmp= ratSqrfFactorize (i.getItem().factor(), v);
79    for (CFListIterator j= tmp; j.hasItem(); j++)
80    {
81      if (j.getItem().inCoeffDomain()) continue;
82      result.append (CFFactor (j.getItem(), i.getItem().exp()));
83    }
84  }
85  if (isOn (SW_RATIONAL))
86  {
87    normalize (result);
88    result.insert (CFFactor (LcF, 1));
89  }
90  return result;
91}
92#endif
93
94#endif
95
Note: See TracBrowser for help on using the repository browser.