14#include "factory/factory.h"
27#include <NTL/config.h>
32# define OSTREAM std::ostream
33# define ISTREAM std::istream
34# elif defined(HAVE_IOSTREAM_H)
36# define OSTREAM ostream
37# define ISTREAM istream
41#include <NTL/mat_ZZ.h>
42#include <NTL/mat_lzz_p.h>
51#define TRANSEXT_PRIVATES
84 #if __FLINT_RELEASE >= 20503
88 if (!convSingRFlintR(ctx,r))
98 if (!convSingRFlintR(ctx,r))
109 fmpz_mpoly_ctx_t ctx;
110 if (!convSingRFlintR(ctx,r))
132 else if ( r->cf->extRing!=
NULL )
136 if (r->cf->extRing->qideal!=
NULL)
248 else if ( r->cf->extRing )
252 if (r->cf->extRing->qideal!=
NULL)
351 WerrorS(
"3rd argument must be a ring variable");
352 goto resultant_returns_res;
355 goto resultant_returns_res;
366 goto resultant_returns_res;
369 else if (r->cf->extRing!=
NULL)
374 if (r->cf->extRing->qideal!=
NULL)
419 goto resultant_returns_res;
423resultant_returns_res:
517 else if ( r->cf->extRing!=
NULL )
522 if (r->cf->extRing->qideal!=
NULL)
589 else if (r->cf->extRing!=
NULL)
593 if (r->cf->extRing->qideal!=
NULL)
615 res = convFactoryGFSingGF( F *
G );
629 #if __FLINT_RELEASE >= 20503
636 nmod_mpoly_ctx_t ctx;
637 if (!convSingRFlintR(ctx,r))
639 res = Flint_Divide_MP(
f,0,
g,0,ctx,r);
647 fmpq_mpoly_ctx_t ctx;
648 if (!convSingRFlintR(ctx,r))
650 res = Flint_Divide_MP(
f,0,
g,0,ctx,r);
667 else if (r->cf->extRing!=
NULL)
671 if (r->cf->extRing->qideal!=
NULL)
693 res = convFactoryGFSingGF( F /
G );
717 else if (r->cf->extRing!=
NULL)
721 if (r->cf->extRing->qideal!=
NULL)
749 res = convFactoryGFSingGF( F /
G );
760void singclap_divide_content ( poly
f,
const ring r )
789 int sz1=
n_Size(g1, r->cf);
790 int sz2=
n_Size(g2, r->cf);
823 while ( (
p !=
NULL) && (
g != 1) && (
g != 0))
832 if ((
g == 1 ) || (
g == 0))
865#ifdef FACTORIZE2_DEBUG
878 else if (r->cf->extRing!=
NULL)
880 if (r->cf->extRing->qideal!=
NULL)
912 else if (r->cf->extRing!=
NULL)
914 if (r->cf->extRing->qideal!=
NULL)
930 if (r->cf->extRing!=
NULL)
931 if (r->cf->extRing->qideal!=
NULL)
952#ifdef FACTORIZE2_DEBUG
980 if (with_exps==0) n++;
1013 if (with_exps!=1) (**v)[n]=e;
1080 else if (r->cf->extRing!=
NULL)
1085 if (r->cf->extRing->qideal!=
NULL)
1116 if ( ! L.
getFirst().factor().inCoeffDomain() )
1125 if ((with_exps==2)&&(n>1))
1135 if (with_exps!=1) (**v)[
j] = J.
getItem().exp();
1144 res->m[
j] = convFactoryGFSingGF( J.
getItem().factor() );
1146 else if (r->cf->extRing!=
NULL)
1152 if (r->cf->extRing->qideal==
NULL)
1180 if (r->cf->extRing!=
NULL)
1181 if (r->cf->extRing->qideal!=
NULL)
1190#ifdef FACTORIZE2_DEBUG
1191 printf(
"factorize_retry\n");
1197 int l=(*v)->length();
1199 for(jj=0;jj<ww->
length();jj++)
1200 (**
v)[jj+
l]=(*ww)[jj];
1205 hh->m[jj]=
res->m[jj];
1221 WarnS(
"problem with factorize");
1285 (**v)[
j]=(*w)[
i];
j++;
1301 if (with_exps!=0) stop=0;
1307 else n_Delete(&old_lead_coeff,r->cf);
1317 if ((
v!=
NULL) && ((*
v)!=
NULL) &&(with_exps==2))
1341#ifdef FACTORIZE2_DEBUG
1355 if (with_exps!=1 && with_exps!=3)
1369 if (with_exps==0 || with_exps==3) n++;
1394 if (with_exps!=1) (**v)[n]=e;
1414 number n0=
n_Copy(old_lead_coeff,r->cf);
1415 if (with_exps==0 || with_exps==3)
1422 if (with_exps==0 || with_exps==3)
1433 number n0=
n_Copy(old_lead_coeff,r->cf);
1434 if (with_exps==0 || with_exps==3)
1440 if (with_exps==0 || with_exps==3)
1454 else if (r->cf->extRing!=
NULL)
1458 if (r->cf->extRing->qideal!=
NULL)
1500 if ((with_exps==2)&&(n>1))
1507 else if (L.
getFirst().factor().inCoeffDomain() && with_exps!=3)
1515 if (with_exps!=1 && with_exps!=3) (**v)[
j] = J.
getItem().exp();
1519 else if (r->cf->extRing!=
NULL)
1521 if (r->cf->extRing->qideal==
NULL)
1538 if (r->cf->extRing!=
NULL)
1539 if (r->cf->extRing->qideal!=
NULL)
1545 if (with_exps!=0 || with_exps==3) stop=0;
1550 if (with_exps==0 || with_exps==3)
p_SetCoeff(
res->m[0],old_lead_coeff,r);
1551 else n_Delete(&old_lead_coeff,r->cf);
1631 for ( LLi = LL; LLi.
hasItem(); LLi++ )
1635 if ((
m!=0) && (n!=0))
break;
1637 if (tries>=5)
break;
1639 if ((
m==0) || (n==0))
1641 Warn(
"char_series returns %d x %d matrix from %d input polys (%d)",
1649 for (
m=1, LLi = LL; LLi.
hasItem(); LLi++,
m++ )
1712 int cnt=
rVar(r)+offs;
1753 if (
s[strlen(
s)-1]==
',')
s[strlen(
s)-1]=
'\0';
1762 Werror(
"det of %d x %d matrix",r,
m->cols());
1787 for(
i=
m->rows();
i>0;
i--)
1789 for(
j=
m->cols();
j>0;
j--)
1804 for(
i=
m->rows();
i>0;
i--)
1806 for(
j=
m->cols();
j>0;
j--)
1816#if defined(HAVE_NTL) || defined(AHVE_FLINT)
1822 Werror(
"HNF of %d x %d matrix",r,
m->cols());
1858 Werror(
"HNF of %d x %d matrix",r,
m->cols());
1889 Werror(
"HNF of %d x %d matrix",r,
b->cols());
2006 mat_zz_p *NTLM=
new mat_zz_p;
2021 WerrorS(
"smatrix for rref is not constant");
2032 number n=
n_Init(rep((*NTLM)(
i,
j)),
R->cf);
2044 WerrorS(
"not implemented for these coefficients");
2060 mat_zz_p *NTLM=
new mat_zz_p;
2072 WerrorS(
"smatrix for rref is not constant");
2083 number n=
n_Init(rep((*NTLM)(
i,
j)),
R->cf);
2096 WerrorS(
"not implemented for these coefficients");
2102#if defined(HAVE_NTL) || defined(HAVE_FLINT)
2128 int n= absFactors.
length();
2168 numFactors +=
count;
2182 WerrorS(
"NTL/FLINT missing: absFactorize");
static int si_max(const int a, const int b)
static int si_min(const int a, const int b)
bigintmat * bimCopy(const bigintmat *b)
same as copy constructor - apart from it being able to accept NULL as input
#define BIMATELEM(M, I, J)
ListCFList irrCharSeries(const CFList &PS)
irreducible characteristic series
IntList neworderint(const CFList &PolyList)
const CanonicalForm CFMap CFMap & N
CanonicalForm extgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a,...
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
CanonicalForm FACTORY_PUBLIC determinant(const CFMatrix &M, int n)
CFFList FACTORY_PUBLIC sqrFree(const CanonicalForm &f, bool sort=false)
squarefree factorization
CFFList FACTORY_PUBLIC factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
CanonicalForm FACTORY_PUBLIC resultant(const CanonicalForm &f, const CanonicalForm &g, const Variable &x)
CanonicalForm resultant ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x )
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
static const int SW_RATIONAL
set to 1 for computations over Q
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
CFMatrix * cf_LLL(CFMatrix &A)
performs LLL reduction.
CFMatrix * cf_HNF(CFMatrix &A)
The input matrix A is an n x m matrix of rank m (so n >= m), and D is a multiple of the determinant o...
CanonicalForm convSingPFactoryP(poly p, const ring r)
BOOLEAN convSingTrP(poly p, const ring r)
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
int convFactoryISingI(const CanonicalForm &f)
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
poly singclap_resultant(poly f, poly g, poly x, const ring r)
BOOLEAN count_Factors(ideal I, intvec *v, int j, poly &f, poly fac, const ring r)
matrix singntl_HNF(matrix m, const ring s)
poly singclap_pmod(poly f, poly g, const ring r)
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
matrix singclap_irrCharSeries(ideal I, const ring r)
int pGetExp_Var(poly p, int i, const ring r)
VAR int singclap_factorize_retry
poly singclap_pdivide(poly f, poly g, const ring r)
int * Zp_roots(poly p, const ring r)
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
matrix singntl_rref(matrix m, const ring R)
poly singclap_det(const matrix m, const ring s)
poly singclap_gcd_and_divide(poly &f, poly &g, const ring r)
clears denominators of f and g, divides by gcd(f,g)
matrix singntl_LLL(matrix m, const ring s)
number singclap_det_bi(bigintmat *m, const coeffs cf)
poly singclap_pmult(poly f, poly g, const ring r)
poly singclap_gcd_r(poly f, poly g, const ring r)
int singclap_det_i(intvec *m, const ring)
ideal singclap_absFactorize(poly f, ideal &mipos, intvec **exps, int &numFactors, const ring r)
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
char * singclap_neworder(ideal I, const ring r)
factory's class for variables
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
static FORCE_INLINE number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
static FORCE_INLINE CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
static BOOLEAN pa(leftv res, leftv args)
static BOOLEAN pb(leftv res, leftv args)
CFAFList absFactorize(const CanonicalForm &G)
absolute factorization of a multivariate poly over Q
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
STATIC_VAR int nfMinPoly[16]
This file is work in progress and currently not part of the official Singular.
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
intvec * ivCopy(const intvec *o)
#define IMATELEM(M, I, J)
matrix mpNew(int r, int c)
create a r x c zero-matrix
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
#define MATELEM(mat, i, j)
1-based access to matrix
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
The main handler for Singular numbers which are suitable for Singular polynomials.
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
void p_Cleardenom_n(poly ph, const ring r, number &c)
poly p_GcdMon(poly f, poly g, const ring r)
polynomial gcd for f=mon
void p_Content(poly ph, const ring r)
void p_Norm(poly p1, const ring r)
poly p_Div_mm(poly p, const poly m, const ring r)
divide polynomial by monomial
poly p_Cleardenom(poly p, const ring r)
poly p_Sub(poly p1, poly p2, const ring r)
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
static poly p_Neg(poly p, const ring r)
static int pLength(poly a)
static poly p_Add_q(poly p, poly q, const ring r)
static poly p_Mult_q(poly p, poly q, const ring r)
void p_Write(poly p, ring lmRing, ring tailRing)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static void p_Setm(poly p, const ring r)
static number p_SetCoeff(poly p, number n, ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static BOOLEAN p_IsConstant(const poly p, const ring r)
static void p_Delete(poly *p, const ring r)
void p_Write0(poly p, ring lmRing, ring tailRing)
static poly pp_Mult_qq(poly p, poly q, const ring r)
static poly p_Copy(poly p, const ring r)
returns a copy of p
static long p_Totaldegree(poly p, const ring r)
#define __p_Mult_nn(p, n, r)
void p_wrp(poly p, ring lmRing, ring tailRing)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static long pTotaldegree(poly p)
std::pair< int, int > mark
void StringSetS(const char *st)
void StringAppendS(const char *st)
const char feNotImplemented[]
void PrintS(const char *s)
void Werror(const char *fmt,...)
static BOOLEAN rField_is_Zp_a(const ring r)
static BOOLEAN rField_is_Z(const ring r)
static BOOLEAN rField_is_Zp(const ring r)
static BOOLEAN rField_is_Zn(const ring r)
static int rPar(const ring r)
(r->cf->P)
static int rInternalChar(const ring r)
static BOOLEAN rField_is_Q_a(const ring r)
static BOOLEAN rField_is_Q(const ring r)
static BOOLEAN rField_is_GF(const ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
int status int void size_t count
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void prune(Variable &alpha)
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables