Loading...
Searching...
No Matches
facBivar.h
Go to the documentation of this file.
/*****************************************************************************\
* Computer Algebra System SINGULAR
\*****************************************************************************/
/** @file facBivar.h
*
* bivariate factorization over Q(a)
*
* @author Martin Lee
*
**/
/*****************************************************************************/
#ifndef FAC_BIVAR_H
#define FAC_BIVAR_H
// #include "config.h"
#include "cf_assert.h"
#include "timing.h"
#include "facFqBivarUtil.h"
#include "DegreePattern.h"
#include "cf_util.h"
#include "facFqSquarefree.h"
#include "cf_map.h"
#include "cf_algorithm.h"
#include "cfNewtonPolygon.h"
#include "fac_util.h"
#include "cf_algorithm.h"
TIMING_DEFINE_PRINT(fac_bi_sqrf)
TIMING_DEFINE_PRINT(fac_bi_factor_sqrf)
/// @return @a biFactorize returns a list of factors of F. If F is not monic
/// its leading coefficient is not outputted.
CFList
biFactorize (const CanonicalForm& F, ///< [in] a sqrfree bivariate poly
const Variable& v ///< [in] some algebraic variable
);
/// factorize a squarefree bivariate polynomial over \f$ Q(\alpha) \f$.
///
/// @ return @a ratBiSqrfFactorize returns a list of monic factors, the first
/// element is the leading coefficient.
inline
CFList
ratBiSqrfFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
const Variable& v= Variable (1) ///< [in] algebraic variable
)
{
CFMap N;
CanonicalForm F= compress (G, N);
CanonicalForm contentX= content (F, 1); //erwarte hier primitiven input: primitiv über Z bzw. Z[a]
CanonicalForm contentY= content (F, 2);
F /= (contentX*contentY);
CFFList contentXFactors, contentYFactors;
if (v.level() != 1)
{
contentXFactors= factorize (contentX, v);
contentYFactors= factorize (contentY, v);
}
else
{
contentXFactors= factorize (contentX);
contentYFactors= factorize (contentY);
}
if (contentXFactors.getFirst().factor().inCoeffDomain())
contentXFactors.removeFirst();
if (contentYFactors.getFirst().factor().inCoeffDomain())
contentYFactors.removeFirst();
if (F.inCoeffDomain())
{
CFList result;
for (CFFListIterator i= contentXFactors; i.hasItem(); i++)
result.append (N (i.getItem().factor()));
for (CFFListIterator i= contentYFactors; i.hasItem(); i++)
result.append (N (i.getItem().factor()));
if (isOn (SW_RATIONAL))
{
normalize (result);
result.insert (Lc (G));
}
return result;
}
mpz_t * M=new mpz_t [4];
mpz_init (M[0]);
mpz_init (M[1]);
mpz_init (M[2]);
mpz_init (M[3]);
mpz_t * S=new mpz_t [2];
mpz_init (S[0]);
mpz_init (S[1]);
F= compress (F, M, S);
CFList result= biFactorize (F, v);
for (CFListIterator i= result; i.hasItem(); i++)
i.getItem()= N (decompress (i.getItem(), M, S));
for (CFFListIterator i= contentXFactors; i.hasItem(); i++)
result.append (N(i.getItem().factor()));
for (CFFListIterator i= contentYFactors; i.hasItem(); i++)
result.append (N (i.getItem().factor()));
if (isOn (SW_RATIONAL))
{
normalize (result);
result.insert (Lc (G));
}
mpz_clear (M[0]);
mpz_clear (M[1]);
mpz_clear (M[2]);
mpz_clear (M[3]);
delete [] M;
mpz_clear (S[0]);
mpz_clear (S[1]);
delete [] S;
return result;
}
/// factorize a bivariate polynomial over \f$ Q(\alpha) \f$
///
/// @return @a ratBiFactorize returns a list of monic factors with
/// multiplicity, the first element is the leading coefficient.
inline
CFFList
ratBiFactorize (const CanonicalForm & G, ///< [in] a bivariate poly
const Variable& v= Variable (1), ///< [in] algebraic variable
bool substCheck= true ///< [in] enables substitute check
)
{
CFMap N;
CanonicalForm F= compress (G, N);
if (substCheck)
{
bool foundOne= false;
int * substDegree= new int [F.level()];
for (int i= 1; i <= F.level(); i++)
{
substDegree[i-1]= substituteCheck (F, Variable (i));
if (substDegree [i-1] > 1)
{
foundOne= true;
subst (F, F, substDegree[i-1], Variable (i));
}
}
if (foundOne)
{
CFFList result= ratBiFactorize (F, v, false);
CFFList newResult, tmp;
CanonicalForm tmp2;
newResult.insert (result.getFirst());
result.removeFirst();
for (CFFListIterator i= result; i.hasItem(); i++)
{
tmp2= i.getItem().factor();
for (int j= 1; j <= F.level(); j++)
{
if (substDegree[j-1] > 1)
tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j));
}
tmp= ratBiFactorize (tmp2, v, false);
tmp.removeFirst();
for (CFFListIterator j= tmp; j.hasItem(); j++)
newResult.append (CFFactor (j.getItem().factor(),
j.getItem().exp()*i.getItem().exp()));
}
decompress (newResult, N);
delete [] substDegree;
return newResult;
}
delete [] substDegree;
}
CanonicalForm LcF= Lc (F);
CanonicalForm contentX= content (F, 1);
CanonicalForm contentY= content (F, 2);
F /= (contentX*contentY);
CFFList contentXFactors, contentYFactors;
if (v.level() != 1)
{
contentXFactors= factorize (contentX, v);
contentYFactors= factorize (contentY, v);
}
else
{
contentXFactors= factorize (contentX);
contentYFactors= factorize (contentY);
}
if (contentXFactors.getFirst().factor().inCoeffDomain())
contentXFactors.removeFirst();
if (contentYFactors.getFirst().factor().inCoeffDomain())
contentYFactors.removeFirst();
decompress (contentXFactors, N);
decompress (contentYFactors, N);
CFFList result, resultRoot;
if (F.inCoeffDomain())
{
result= Union (contentXFactors, contentYFactors);
if (isOn (SW_RATIONAL))
{
normalize (result);
if (v.level() == 1)
{
for (CFFListIterator i= result; i.hasItem(); i++)
{
LcF /= power (bCommonDen (i.getItem().factor()), i.getItem().exp());
i.getItem()= CFFactor (i.getItem().factor()*
bCommonDen(i.getItem().factor()), i.getItem().exp());
}
}
result.insert (CFFactor (LcF, 1));
}
return result;
}
mpz_t * M=new mpz_t [4];
mpz_init (M[0]);
mpz_init (M[1]);
mpz_init (M[2]);
mpz_init (M[3]);
mpz_t * S=new mpz_t [2];
mpz_init (S[0]);
mpz_init (S[1]);
F= compress (F, M, S);
TIMING_START (fac_bi_sqrf);
CFFList sqrfFactors= sqrFree (F);
TIMING_END_AND_PRINT (fac_bi_sqrf,
"time for bivariate sqrf factors over Q: ");
for (CFFListIterator i= sqrfFactors; i.hasItem(); i++)
{
TIMING_START (fac_bi_factor_sqrf);
CFList tmp= ratBiSqrfFactorize (i.getItem().factor(), v);
TIMING_END_AND_PRINT (fac_bi_factor_sqrf,
"time to factor bivariate sqrf factors over Q: ");
for (CFListIterator j= tmp; j.hasItem(); j++)
{
if (j.getItem().inCoeffDomain()) continue;
result.append (CFFactor (N (decompress (j.getItem(), M, S)),
i.getItem().exp()));
}
}
result= Union (result, contentXFactors);
result= Union (result, contentYFactors);
if (isOn (SW_RATIONAL))
{
normalize (result);
if (v.level() == 1)
{
for (CFFListIterator i= result; i.hasItem(); i++)
{
LcF /= power (bCommonDen (i.getItem().factor()), i.getItem().exp());
i.getItem()= CFFactor (i.getItem().factor()*
bCommonDen(i.getItem().factor()), i.getItem().exp());
}
}
result.insert (CFFactor (LcF, 1));
}
mpz_clear (M[0]);
mpz_clear (M[1]);
mpz_clear (M[2]);
mpz_clear (M[3]);
delete [] M;
mpz_clear (S[0]);
mpz_clear (S[1]);
delete [] S;
return result;
}
/// convert a CFFList to a CFList by dropping the multiplicity
CFList conv (const CFFList& L ///< [in] a CFFList
);
/// compute p^k larger than the bound on the coefficients of a factor of @a f
/// over Q (mipo)
modpk
coeffBound (const CanonicalForm & f, ///< [in] poly over Z[a]
int p, ///< [in] some positive integer
const CanonicalForm& mipo ///< [in] minimal polynomial with
///< denominator 1
);
/// find a big prime p from our tables such that no term of f vanishes mod p
void findGoodPrime(const CanonicalForm &f, ///< [in] poly over Z or Z[a]
int &start ///< [in,out] index of big prime in
/// cf_primetab.h
);
/// compute p^k larger than the bound on the coefficients of a factor of @a f
/// over Z
modpk
coeffBound (const CanonicalForm & f, ///< [in] poly over Z
int p ///< [in] some positive integer
);
#endif
DegreePattern.h
This file provides a class to handle degree patterns.
isOn
bool isOn(int sw)
switches
Definition canonicalform.cc:1971
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition canonicalform.cc:1896
content
CanonicalForm FACTORY_PUBLIC content(const CanonicalForm &)
CanonicalForm content ( const CanonicalForm & f ).
Definition cf_gcd.cc:603
CFFListIterator
ListIterator< CFFactor > CFFListIterator
Definition canonicalform.h:394
CFListIterator
ListIterator< CanonicalForm > CFListIterator
Definition canonicalform.h:396
CFFList
List< CFFactor > CFFList
Definition canonicalform.h:393
Lc
CanonicalForm Lc(const CanonicalForm &f)
Definition canonicalform.h:307
CFFactor
Factor< CanonicalForm > CFFactor
Definition canonicalform.h:392
CFList
List< CanonicalForm > CFList
Definition canonicalform.h:395
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
decompress
CanonicalForm decompress(const CanonicalForm &F, const mpz_t *inverseM, const mpz_t *A)
decompress a bivariate poly
Definition cfNewtonPolygon.cc:853
cfNewtonPolygon.h
This file provides functions to compute the Newton polygon of a bivariate polynomial.
bCommonDen
CanonicalForm bCommonDen(const CanonicalForm &f)
void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r,...
Definition cf_algorithm.cc:293
cf_algorithm.h
declarations of higher level algorithms.
sqrFree
CFFList FACTORY_PUBLIC sqrFree(const CanonicalForm &f, bool sort=false)
squarefree factorization
Definition cf_factor.cc:961
factorize
CFFList FACTORY_PUBLIC factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
Definition cf_factor.cc:409
cf_assert.h
assertions for Factory
SW_RATIONAL
static const int SW_RATIONAL
set to 1 for computations over Q
Definition cf_defs.h:31
compress
CanonicalForm compress(const CanonicalForm &f, CFMap &m)
CanonicalForm compress ( const CanonicalForm & f, CFMap & m ).
Definition cf_map.cc:210
cf_map.h
map polynomials
cf_util.h
f
FILE * f
Definition checklibs.c:9
CFMap
class CFMap
Definition cf_map.h:85
CanonicalForm
factory's main class
Definition canonicalform.h:86
CanonicalForm::inCoeffDomain
bool inCoeffDomain() const
Definition canonicalform.cc:122
CanonicalForm::level
int level() const
level() returns the level of CO.
Definition canonicalform.cc:576
Factor::factor
T factor() const
Definition ftmpl_factor.h:30
List::getFirst
T getFirst() const
Definition ftmpl_list.cc:279
List::removeFirst
void removeFirst()
Definition ftmpl_list.cc:287
List::append
void append(const T &)
Definition ftmpl_list.cc:256
List::insert
void insert(const T &)
Definition ftmpl_list.cc:193
Variable
factory's class for variables
Definition factory.h:127
modpk
class to do operations mod p^k for int's p and k
Definition fac_util.h:23
LcF
CanonicalForm LcF
Definition facAbsBiFact.cc:51
result
return result
Definition facAbsBiFact.cc:76
mipo
CanonicalForm mipo
Definition facAlgExt.cc:57
subst
CanonicalForm subst(const CanonicalForm &f, const CFList &a, const CFList &b, const CanonicalForm &Rstar, bool isFunctionField)
Definition facAlgFuncUtil.cc:120
biFactorize
CFList biFactorize(const CanonicalForm &F, const Variable &v)
Definition facBivar.cc:188
coeffBound
modpk coeffBound(const CanonicalForm &f, int p, const CanonicalForm &mipo)
compute p^k larger than the bound on the coefficients of a factor of f over Q (mipo)
Definition facBivar.cc:97
ratBiSqrfFactorize
CFList ratBiSqrfFactorize(const CanonicalForm &G, const Variable &v=Variable(1))
factorize a squarefree bivariate polynomial over .
Definition facBivar.h:47
conv
CFList conv(const CFFList &L)
convert a CFFList to a CFList by dropping the multiplicity
Definition facBivar.cc:126
ratBiFactorize
CFFList ratBiFactorize(const CanonicalForm &G, const Variable &v=Variable(1), bool substCheck=true)
factorize a bivariate polynomial over
Definition facBivar.h:129
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
findGoodPrime
void findGoodPrime(const CanonicalForm &f, int &start)
find a big prime p from our tables such that no term of f vanishes mod p
Definition facBivar.cc:61
reverseSubst
CanonicalForm reverseSubst(const CanonicalForm &F, const int d, const Variable &x)
reverse a substitution x^d->x
Definition facFqBivarUtil.cc:1295
substituteCheck
int substituteCheck(const CanonicalForm &F, const Variable &x)
check if a substitution x^n->x is possible
Definition facFqBivarUtil.cc:1089
facFqBivarUtil.h
This file provides utility functions for bivariate factorization.
tmp2
CFList tmp2
Definition facFqBivar.cc:75
facFqSquarefree.h
This file provides functions for squarefrees factorizing over , or GF.
j
int j
Definition facHensel.cc:110
fac_util.h
operations mod p^k and some other useful functions for factorization
Union
template List< Variable > Union(const List< Variable > &, const List< Variable > &)
G
STATIC_VAR TreeM * G
Definition janet.cc:31
M
#define M
Definition sirandom.c:25
normalize
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition syz3.cc:1027
timing.h
TIMING_DEFINE_PRINT
#define TIMING_DEFINE_PRINT(t)
Definition timing.h:95
TIMING_START
#define TIMING_START(t)
Definition timing.h:92
TIMING_END_AND_PRINT
#define TIMING_END_AND_PRINT(t, msg)
Definition timing.h:94