29 #define PLURAL_INTERNAL_DECLARATIONS 100 register unsigned int tpower = 0;
101 register unsigned int cpower = 0;
103 for(
register short j = iLastAltVar;
j >= iFirstAltVar;
j-- )
105 const unsigned int iExpM =
p_GetExp(pMonomM,
j, rRing);
106 const unsigned int iExpMM =
p_GetExp(pMonomMM,
j, rRing);
131 return(1 - (tpower << 1) );
151 register unsigned int tpower = 0;
152 register unsigned int cpower = 0;
154 for(
register unsigned int j = iLastAltVar;
j >= iFirstAltVar;
j-- )
156 const unsigned int iExpM =
p_GetExp(pMonomM,
j, rRing);
157 const unsigned int iExpMM =
p_GetExp(pMonomMM,
j, rRing);
186 nCoeffM =
n_InpNeg(nCoeffM, rRing->cf);
188 const number nCoeffMM =
p_GetCoeff(pMonomMM, rRing);
190 number nCoeff =
n_Mult(nCoeffM, nCoeffMM, rRing->cf);
215 register unsigned int tpower = 0;
216 register unsigned int cpower = 0;
218 for(
register unsigned int j = iLastAltVar;
j >= iFirstAltVar;
j-- )
220 const unsigned int iExpMM =
p_GetExp(pMonomMM,
j, rRing);
221 const unsigned int iExpM =
p_GetExp(pMonomM,
j, rRing);
250 nCoeffM =
n_InpNeg(nCoeffM, rRing->cf);
252 const number nCoeffMM =
p_GetCoeff(pMonomMM, rRing);
254 number nCoeff =
n_Mult(nCoeffM, nCoeffMM, rRing->cf);
280 register unsigned int tpower = 0;
281 register unsigned int cpower = 0;
283 for(
register unsigned int j = iLastAltVar;
j >= iFirstAltVar;
j-- )
285 const unsigned int iExp1 =
p_GetExp(pMonom1,
j, rRing);
286 const unsigned int iExp2 =
p_GetExp(pMonom2,
j, rRing);
315 const number nCoeff1 =
p_GetCoeff(pMonom1, rRing);
316 const number nCoeff2 =
p_GetCoeff(pMonom2, rRing);
318 number nCoeff =
n_Mult(nCoeff1, nCoeff2, rRing->cf);
321 nCoeff =
n_InpNeg(nCoeff, rRing->cf);
344 if(
p_GetExp(pMonom, i, rRing) != 0 )
349 register unsigned int cpower = 0;
351 for(
register short j = iFirstAltVar;
j <
i ;
j++ )
366 nCoeff =
n_InpNeg(nCoeff, rRing->cf);
402 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
411 const int iComponent =
p_GetComp(p, rRing);
415 if( iComponentMonomM!=0 )
418 Werror(
"sca_p_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
425 if(iComponentMonomM==0 )
427 dReportError(
"sca_p_Mult_mm: Multiplication in the left module from the right");
480 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
483 poly* ppPrev = &pResult;
494 if( iComponentMonomM!=0 )
497 Werror(
"sca_pp_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
505 if(iComponentMonomM==0 )
507 dReportError(
"sca_pp_Mult_mm: Multiplication in the left module from the right");
547 poly* ppPrev = &pResult;
562 ppPrev = &
pNext(*ppPrev);
591 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
594 poly* ppPrev = &pResult;
603 if( iComponentMonomM!=0 )
608 Werror(
"sca_mm_Mult_pp: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
617 dReportError(
"sca_mm_Mult_pp: Multiplication in the left module from the right!");
631 ppPrev = &
pNext(*ppPrev);
664 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
678 const int iComponent =
p_GetComp(p, rRing);
680 if( iComponentMonomM!=0 )
685 Werror(
"sca_mm_Mult_p: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
694 dReportError(
"sca_mm_Mult_p: Multiplication in the left module from the right!");
727 if( !
p_Test(pPoly, rRing) )
729 PrintS(
"pPoly is wrong!");
760 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
763 dReportError(
"sca_SPoly: different non-zero components!\n");
794 number C =
n_Gcd(C1,C2,r->cf);
798 C1=
n_Div(C1, C, r->cf);
799 C2=
n_Div(C2, C, r->cf);
807 assume( (iSignSum*iSignSum == 0) || (iSignSum*iSignSum == 4) );
850 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
853 dReportError(
"sca_ReduceSpoly: different non-zero components!");
869 number C =
n_Gcd(C1, C2, r->cf);
873 C1 =
n_Div(C1, C, r->cf);
874 C2 =
n_Div(C2, C, r->cf);
934 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 935 PrintS(
"sca_SetupQuotient(rGR, rG, bCopy)");
947 if(
rIsSCA(rG) && (rG != rGR))
965 PrintS(
"sca_SetupQuotient: qring?\n");
968 if(rGR->qideal ==
NULL)
972 PrintS(
"sca_SetupQuotient: qideal!!!\n");
980 int iAltVarStart = N+1;
983 const ring rBase = rG;
988 PrintS(
"sca_SetupQuotient: AltVars?!\n");
991 for(
int i = 1;
i <
N;
i++)
993 for(
int j =
i + 1;
j <=
N;
j++)
997 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 998 Print(
"Nonzero D[%d, %d]\n",
i,
j);
1009 if(
i < iAltVarStart)
1018 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1019 Print(
"Wrong Coeff at: [%d, %d]\n",
i,
j);
1027 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1028 Print(
"AltVars?1: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1032 if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) )
1036 for(
int i = 1;
i <
N;
i++)
1038 for(
int j =
i + 1;
j <=
N;
j++)
1043 if( (iAltVarStart <=
i) && (
j <= iAltVarEnd) )
1047 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1048 Print(
"Wrong Coeff at: [%d, %d]\n",
i,
j);
1057 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1058 Print(
"Wrong Coeff at: [%d, %d]\n",
i,
j);
1066 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1067 Print(
"AltVars!?: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1070 assume( 1 <= iAltVarStart );
1071 assume( iAltVarStart < iAltVarEnd );
1072 assume( iAltVarEnd <= N );
1082 const ideal idQuotient = rGR->qideal;
1085 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1086 PrintS(
"Analyzing quotient ideal:\n");
1105 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1106 Print(
"AltVars!?: [%d, %d]\n", b, e);
1110 for (
int i = iAltVarStart; (
i <= iAltVarEnd) && bSCA;
i++ )
1111 if( (
i < b) || (
i > e) )
1119 square =
nc_NF(idQuotient,
NULL, square, 0, 1, rG);
1121 if( square !=
NULL )
1129 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1130 Print(
"ScaVars!: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1137 ideal tempQ =
id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG);
1140 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1143 PrintS(
"tempSCAQuotient: \n");
1155 rGR->GetNC()->SCAQuotient() =
NULL;
1157 rGR->GetNC()->SCAQuotient() =
idrMoveR(tempQ, rG, rGR);
1162 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1163 PrintS(
"SCAQuotient: \n");
1180 const int N = rGR->N;
1186 const ideal idQuotient = rGR->qideal;
1188 ideal tempQ = idQuotient;
1190 if( b <= N && e >= 1 )
1198 rGR->GetNC()->SCAQuotient() =
NULL;
1200 rGR->GetNC()->SCAQuotient() = tempQ;
1291 int& dx,
int& dy,
const ring
r)
1293 const unsigned int N = r->N;
1309 for(
int i = N;
i > 0;
i--)
1312 x += d * (*wx)[
i-1];
1313 y += d * (*wy)[
i-1];
1316 if( (wCx !=
NULL) && (wCy !=
NULL) )
1361 if ( (x != ddx) || (y != ddy) )
return false;
1377 if (
id ==
NULL)
return true;
1379 const int iSize =
IDELEMS(
id);
1381 if (iSize == 0)
return true;
1386 for(
int i = iSize - 1; (
i >= 0 ) && b;
i--)
1398 const unsigned int N = r->N;
1400 const int CommutativeVariable = 0;
1401 const int AntiCommutativeVariable = 0;
1405 if(AntiCommutativeVariable != CommutativeVariable)
1411 for (
unsigned int i = m_iFirstAltVar;
i<= m_iLastAltVar;
i++)
1413 (*w)[
i-1] = AntiCommutativeVariable;
1426 const unsigned int N = r->N;
1428 const int CommutativeVariable = 0;
1429 const int AntiCommutativeVariable = 1;
1433 if(AntiCommutativeVariable != CommutativeVariable)
1439 for (
unsigned int i = m_iFirstAltVar;
i<= m_iLastAltVar;
i++)
1441 (*w)[
i-1] = AntiCommutativeVariable;
1453 const short iFirstAltVar,
const short iLastAltVar,
1458 assume( (iFirstAltVar >= 1) && (iLastAltVar <=
rVar(r)) && (iFirstAltVar <= iLastAltVar) );
1461 PrintS(
"m_KillSquares, m = ");
1468 for(
short k = iFirstAltVar;
k <= iLastAltVar;
k++)
1479 const short iFirstAltVar,
const short iLastAltVar,
1485 assume( (iFirstAltVar >= 1) && (iLastAltVar <= r->
N) && (iFirstAltVar <= iLastAltVar) );
1488 PrintS(
"p_KillSquares, p = ");
1498 poly* ppPrev = &pResult;
1520 PrintS(
"p_KillSquares => ");
1534 const short iFirstAltVar,
const short iLastAltVar,
1535 const ring
r,
const bool bSkipZeroes)
1537 if (
id ==
NULL)
return id;
1539 assume( (iFirstAltVar >= 1) && (iLastAltVar <=
rVar(r)) && (iFirstAltVar <= iLastAltVar) );
1541 const int iSize =
IDELEMS(
id);
1543 if (iSize == 0)
return id;
1545 ideal temp =
idInit(iSize, id->rank);
1548 PrintS(
"<id_KillSquares>\n");
1551 for (
unsigned int i = 0;
i <
IDELEMS(
id);
i++)
1553 Print(
"; id[%d] = ",
i+1);
1562 for (
int j = 0;
j < iSize;
j++)
1569 PrintS(
"<id_KillSquares>\n");
1571 PrintS(
"ideal temp: \n");
1574 Print(
"; temp[%d] = ",
i+1);
1580 PrintS(
"</id_KillSquares>\n");
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
static poly sca_xi_Mult_pp(short i, const poly pPoly, const ring rRing)
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
static poly sca_xi_Mult_mm(short i, const poly pMonom, const ring rRing)
const CanonicalForm int const CFList const Variable & y
static poly p_LmDeleteAndNext(poly p, const ring r)
static poly sca_mm_Mult_p(const poly pMonom, poly pPoly, const ring rRing)
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.
static poly sca_m_Mult_mm(poly pMonomM, const poly pMonomMM, const ring rRing)
struct p_Procs_s p_Procs_s
static short rVar(const ring r)
#define rVar(r) (r->N)
void p_Lcm(const poly a, const poly b, poly m, const ring r)
#define p_AllocBin(p, bin, r)
poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing)
static poly m_KillSquares(const poly m, const short iFirstAltVar, const short iLastAltVar, const ring r)
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
poly p_KillSquares(const poly p, const short iFirstAltVar, const short iLastAltVar, const ring r)
static number p_SetCoeff(poly p, number n, ring r)
static int sca_Sign_mm_Mult_mm(const poly pMonomM, const poly pMonomMM, const ring rRing)
poly sca_ReduceSpoly(const poly p1, poly p2, const ring r)
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
bool sca_Force(ring rGR, int b, int e)
static poly p_Head(poly p, const ring r)
bool id_IsBiHomogeneous(const ideal id, const intvec *wx, const intvec *wy, const intvec *wCx, const intvec *wCy, const ring r)
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:
bool p_IsBiHomogeneous(const poly p, const intvec *wx, const intvec *wy, const intvec *wCx, const intvec *wCy, int &dx, int &dy, const ring r)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static poly sca_mm_Mult_mm(poly pMonom1, const poly pMonom2, const ring rRing)
static poly pp_Mult_qq(poly p, poly q, const ring r)
intvec * ivGetSCAYVarWeights(const ring r)
poly sca_pp_Mult_xi_pp(short i, const poly pPoly, const ring rRing)
poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &)
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
static int si_max(const int a, const int b)
void PrintS(const char *s)
static poly p_Mult_nn(poly p, number n, const ring r)
void sca_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
void rWrite(ring r, BOOLEAN details)
void p_Content(poly ph, const ring r)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static short scaFirstAltVar(ring r)
poly sca_SPoly(const poly p1, const poly p2, const ring r)
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 void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
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
static poly sca_mm_Mult_pp(const poly pMonom, const poly pPoly, const ring rRing)
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
void * cast_A_to_vptr(A a)
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 poly sca_mm_Mult_m(const poly pMonomMM, poly pMonomM, const ring rRing)
bool sca_SetupQuotient(ring rGR, ring rG, bool bCopy)
static short scaLastAltVar(ring r)
static p_Procs_s * _p_procs
static bool rIsSCA(const ring r)
static poly p_LmInit(poly p, const ring r)
static void p_Setm(poly p, const ring r)
static nc_type & ncRingType(nc_struct *p)
int dReportError(const char *fmt,...)
#define p_SetCoeff0(p, n, r)
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
void p_Write(poly p, ring lmRing, ring tailRing)
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
static poly p_Add_q(poly p, poly q, const ring r)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
poly p_Cleardenom(poly p, const ring r)
static void m_GetBiDegree(const poly m, const intvec *wx, const intvec *wy, const intvec *wCx, const intvec *wCy, int &dx, int &dy, const ring r)
intvec * ivGetSCAXVarWeights(const ring r)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
void Werror(const char *fmt,...)
#define MATELEM(mat, i, j)