14 #include "factory/factory.h" 25 #define TRANSEXT_PRIVATES 67 else if ( r->cf->extRing!=
NULL )
71 if (r->cf->extRing->qideal!=
NULL)
180 else if ( r->cf->extRing )
184 if (r->cf->extRing->qideal!=
NULL)
283 WerrorS(
"3rd argument must be a ring variable");
284 goto resultant_returns_res;
287 goto resultant_returns_res;
298 goto resultant_returns_res;
301 else if (r->cf->extRing!=
NULL)
306 if (r->cf->extRing->qideal!=
NULL)
351 goto resultant_returns_res;
355 resultant_returns_res:
449 else if ( r->cf->extRing!=
NULL )
454 if (r->cf->extRing->qideal!=
NULL)
521 else if (r->cf->extRing!=
NULL)
525 if (r->cf->extRing->qideal!=
NULL)
541 #if 0 // not yet working 546 CanonicalForm F( convSingGFFactoryGF( f ) ),
G( convSingGFFactoryGF( g ) );
547 res = convFactoryGFSingGF( F * G );
568 else if (r->cf->extRing!=
NULL)
572 if (r->cf->extRing->qideal!=
NULL)
588 #if 0 // not yet working 593 CanonicalForm F( convSingGFFactoryGF( f ) ),
G( convSingGFFactoryGF( g ) );
594 res = convFactoryGFSingGF( F / G );
615 else if (r->cf->extRing!=
NULL)
619 if (r->cf->extRing->qideal!=
NULL)
635 #if 0 // not yet working 640 CanonicalForm F( convSingGFFactoryGF( f ) ),
G( convSingGFFactoryGF( g ) );
641 res = convFactoryGFSingGF( F / G );
652 void singclap_divide_content ( poly
f,
const ring r )
681 int sz1=
n_Size(g1, r->cf);
682 int sz2=
n_Size(g2, r->cf);
715 while ( (p !=
NULL) && (g != 1) && ( g != 0))
724 if (( g == 1 ) || (g == 0))
757 #ifdef FACTORIZE2_DEBUG 770 else if (r->cf->extRing!=
NULL)
772 if (r->cf->extRing->qideal!=
NULL)
804 else if (r->cf->extRing!=
NULL)
806 if (r->cf->extRing->qideal!=
NULL)
822 if (r->cf->extRing!=
NULL)
823 if (r->cf->extRing->qideal!=
NULL)
833 if (v!=
NULL) (*v)[
j]=e;
844 #ifdef FACTORIZE2_DEBUG 845 printf(
"singclap_factorize, degree %ld\n",
p_Totaldegree(f,r));
872 if (with_exps==0) n++;
895 for(i=
rVar(r);i>0;i--)
905 if (with_exps!=1) (**v)[n]=e;
970 else if ((r->cf->extRing!=
NULL)
975 if (r->cf->extRing->qideal!=
NULL)
1005 if ( ! L.
getFirst().factor().inCoeffDomain() )
1014 if ((with_exps==2)&&(n>1))
1022 for ( ; J.
hasItem(); J++, j++ )
1024 if (with_exps!=1) (**v)[
j] = J.
getItem().exp();
1033 res->m[j] = convFactoryGFSingGF( J.
getItem().factor() );
1035 else if (r->cf->extRing!=
NULL)
1041 if (r->cf->extRing->qideal==
NULL)
1069 if (r->cf->extRing!=
NULL)
1070 if (r->cf->extRing->qideal!=
NULL)
1079 #ifdef FACTORIZE2_DEBUG 1080 printf(
"factorize_retry\n");
1086 int l=(*v)->length();
1087 (*v)->resize(l+ww->
length());
1088 for(jj=0;jj<ww->
length();jj++)
1089 (**v)[jj+
l]=(*ww)[jj];
1092 for(jj=
IDELEMS(res)-1;jj>=0;jj--)
1094 hh->m[jj]=res->m[jj];
1097 for(jj=
IDELEMS(h)-1;jj>=0;jj--)
1099 hh->m[jj+
IDELEMS(res)]=h->m[jj];
1110 WarnS(
"problem with factorize");
1118 res->m[1]=ff; ff=
NULL;
1136 if ((res->m[i]!=
NULL)
1149 while ((v!=
NULL) && ((*v)!=
NULL) && ((**v)[i]>1))
1154 res->m[0]=
p_Mult_q(res->m[0],res->m[i],r);
1174 (**v)[
j]=(*w)[
i]; j++;
1180 if (res->m[0]==
NULL)
1190 if (with_exps!=0) stop=0;
1195 if (with_exps==0)
p_SetCoeff(res->m[0],old_lead_coeff,r);
1196 else n_Delete(&old_lead_coeff,r->cf);
1221 #ifdef FACTORIZE2_DEBUG 1222 printf(
"singclap_sqrfree, degree %d\n",
pTotaldegree(f));
1235 if (with_exps!=1 && with_exps!=3)
1249 if (with_exps==0 || with_exps==3) n++;
1264 for(i=
rVar(r);i>0;i--)
1274 if (with_exps!=1) (**v)[n]=e;
1295 if (with_exps==0 || with_exps==3)
1302 if (with_exps==0 || with_exps==3)
1314 if (with_exps==0 || with_exps==3)
1320 if (with_exps==0 || with_exps==3)
1334 else if (r->cf->extRing!=
NULL)
1338 if (r->cf->extRing->qideal!=
NULL)
1380 if ((with_exps==2)&&(n>1))
1387 else if (L.
getFirst().factor().inCoeffDomain() && with_exps!=3)
1393 for ( ; J.
hasItem(); J++, j++ )
1395 if (with_exps!=1 && with_exps!=3) (**v)[
j] = J.
getItem().exp();
1399 else if (r->cf->extRing!=
NULL)
1401 if (r->cf->extRing->qideal==
NULL)
1407 if (res->m[0]==
NULL)
1418 if (r->cf->extRing!=
NULL)
1419 if (r->cf->extRing->qideal!=
NULL)
1425 if (with_exps!=0 || with_exps==3) stop=0;
1430 if (with_exps==0 || with_exps==3)
p_SetCoeff(res->m[0],old_lead_coeff,r);
1431 else n_Delete(&old_lead_coeff,r->cf);
1511 for ( LLi = LL; LLi.
hasItem(); LLi++ )
1515 if ((m!=0) && (n!=0))
break;
1517 if (tries>=5)
break;
1519 if ((m==0) || (n==0))
1521 Warn(
"char_series returns %d x %d matrix from %d input polys (%d)",
1529 for ( m=1, LLi = LL; LLi.
hasItem(); LLi++, m++ )
1592 int cnt=
rVar(r)+offs;
1613 for(i=0;i<
rVar(r)+offs;i++)
1633 if (s[strlen(s)-1]==
',') s[strlen(s)-1]=
'\0';
1667 for(i=m->
rows();i>0;i--)
1669 for(j=m->
cols();j>0;j--)
1684 for(i=m->
rows();i>0;i--)
1686 for(j=m->
cols();j>0;j--)
1876 int n= absFactors.
length();
1890 if (iter.
getItem().factor().inCoeffDomain())
1895 for (; iter.
hasItem(); iter++, i++)
1898 alpha= iter.
getItem().minpoly().mvar();
1899 if (iter.
getItem().minpoly().isOne())
1904 if (iter.
getItem().minpoly().isOne())
1914 if (!iter.
getItem().minpoly().isOne())
1916 numFactors +=
count;
int status int void size_t count
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
const CanonicalForm int s
poly singclap_gcd_r(poly f, poly g, const ring r)
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)
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
std::pair< int, int > mark
static BOOLEAN rField_is_Zp_a(const ring r)
poly p_Div_mm(poly p, const poly m, const ring r)
divide polynomial by monomial
CanonicalForm extgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a...
static int si_min(const int a, const int b)
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
static int rPar(const ring r)
(r->cf->P)
factory's class for variables
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
poly p_GcdMon(poly f, poly g, const ring r)
polynomial gcd for f=mon
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
int singclap_det_i(intvec *m, const ring)
static short rVar(const ring r)
#define rVar(r) (r->N)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
intvec * ivCopy(const intvec *o)
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
poly singclap_resultant(poly f, poly g, poly x, const ring r)
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
static BOOLEAN rField_is_Q_a(const ring r)
static long p_Totaldegree(poly p, const ring r)
ListCFList irrCharSeries(const CFList &PS)
irreducible characteristic series
poly singclap_det(const matrix m, const ring s)
static BOOLEAN rField_is_Zn(const ring r)
void WerrorS(const char *s)
static BOOLEAN rField_is_GF(const ring r)
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
static BOOLEAN rField_is_Z(const ring r)
void p_Norm(poly p1, const ring r)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
poly singclap_pdivide(poly f, poly g, const ring r)
static number p_SetCoeff(poly p, number n, ring r)
poly p_Sub(poly p1, poly p2, const ring r)
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
BOOLEAN pb(leftv res, leftv args)
static poly p_Copy(poly p, const ring r)
returns a copy of p
void prune(Variable &alpha)
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Variable rootOf(const CanonicalForm &, char name='@')
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
void p_Cleardenom_n(poly ph, const ring r, number &c)
CFMatrix * cf_LLL(CFMatrix &A)
performs LLL reduction.
BOOLEAN count_Factors(ideal I, intvec *v, int j, poly &f, poly fac, const ring r)
CFFList factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
Coefficient rings, fields and other domains suitable for Singular polynomials.
IntList neworderint(const CFList &PolyList)
int convFactoryISingI(const CanonicalForm &f)
const CanonicalForm CFMap CFMap & N
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
bigintmat * bimCopy(const bigintmat *b)
same as copy constructor - apart from it being able to accept NULL as input
static long pTotaldegree(poly p)
static BOOLEAN p_IsConstant(const poly p, const ring r)
The main handler for Singular numbers which are suitable for Singular polynomials.
void StringSetS(const char *st)
static poly pp_Mult_qq(poly p, poly q, const ring r)
void StringAppendS(const char *st)
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
const char feNotImplemented[]
static const int SW_RATIONAL
set to 1 for computations over Q
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 int si_max(const int a, const int b)
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
void PrintS(const char *s)
matrix singclap_irrCharSeries(ideal I, const ring r)
static BOOLEAN rField_is_Q(const ring r)
matrix singntl_HNF(matrix m, const ring s)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
int pGetExp_Var(poly p, int i, const ring r)
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...
#define BIMATELEM(M, I, J)
static BOOLEAN rField_is_Zp(const ring r)
matrix mpNew(int r, int c)
create a r x c zero-matrix
void p_Write0(poly p, ring lmRing, ring tailRing)
static void p_Delete(poly *p, const ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
const Variable & v
< [in] a sqrfree bivariate poly
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
#define __p_Mult_nn(p, n, r)
CanonicalForm convSingPFactoryP(poly p, const ring r)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
poly singclap_pmult(poly f, poly g, const ring r)
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...
coeffs basecoeffs() const
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
number singclap_det_bi(bigintmat *m, const coeffs cf)
CanonicalForm determinant(const CFMatrix &M, int n)
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
poly singclap_pmod(poly f, poly g, const ring r)
static void p_Setm(poly p, const ring r)
int singclap_factorize_retry
ideal singclap_absFactorize(poly f, ideal &mipos, intvec **exps, int &numFactors, const ring r)
BOOLEAN pa(leftv res, leftv args)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
void p_wrp(poly p, ring lmRing, ring tailRing)
void p_Write(poly p, ring lmRing, ring tailRing)
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
CFAFList absFactorize(const CanonicalForm &G)
absolute factorization of a multivariate poly over Q
static poly p_Add_q(poly p, poly q, const ring r)
char * singclap_neworder(ideal I, const ring r)
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
#define IMATELEM(M, I, J)
CanonicalForm resultant(const CanonicalForm &f, const CanonicalForm &g, const Variable &x)
CanonicalForm resultant ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) ...
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
poly p_Cleardenom(poly p, const ring r)
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 poly p_Mult_q(poly p, poly q, const ring r)
CFFList sqrFree(const CanonicalForm &f, bool sort=false)
squarefree factorization
void Werror(const char *fmt,...)
#define MATELEM(mat, i, j)
1-based access to matrix