29 #define PLURAL_INTERNAL_DECLARATIONS 102 register unsigned int tpower = 0;
103 register unsigned int cpower = 0;
105 for(
register short j = iLastAltVar;
j >= iFirstAltVar;
j-- )
107 const unsigned int iExpM =
p_GetExp(pMonomM,
j, rRing);
108 const unsigned int iExpMM =
p_GetExp(pMonomMM,
j, rRing);
133 return(1 - (tpower << 1) );
153 register unsigned int tpower = 0;
154 register unsigned int cpower = 0;
156 for(
register unsigned int j = iLastAltVar;
j >= iFirstAltVar;
j-- )
158 const unsigned int iExpM =
p_GetExp(pMonomM,
j, rRing);
159 const unsigned int iExpMM =
p_GetExp(pMonomMM,
j, rRing);
190 const number nCoeffMM =
p_GetCoeff(pMonomMM, rRing);
192 number nCoeff =
n_Mult(nCoeffM, nCoeffMM, rRing);
217 register unsigned int tpower = 0;
218 register unsigned int cpower = 0;
220 for(
register unsigned int j = iLastAltVar;
j >= iFirstAltVar;
j-- )
222 const unsigned int iExpMM =
p_GetExp(pMonomMM,
j, rRing);
223 const unsigned int iExpM =
p_GetExp(pMonomM,
j, rRing);
254 const number nCoeffMM =
p_GetCoeff(pMonomMM, rRing);
256 number nCoeff =
n_Mult(nCoeffM, nCoeffMM, rRing);
282 register unsigned int tpower = 0;
283 register unsigned int cpower = 0;
285 for(
register unsigned int j = iLastAltVar;
j >= iFirstAltVar;
j-- )
287 const unsigned int iExp1 =
p_GetExp(pMonom1,
j, rRing);
288 const unsigned int iExp2 =
p_GetExp(pMonom2,
j, rRing);
317 const number nCoeff1 =
p_GetCoeff(pMonom1, rRing);
318 const number nCoeff2 =
p_GetCoeff(pMonom2, rRing);
320 number nCoeff =
n_Mult(nCoeff1, nCoeff2, rRing);
346 if(
p_GetExp(pMonom, i, rRing) != 0 )
351 register unsigned int cpower = 0;
353 for(
register short j = iFirstAltVar;
j <
i ;
j++ )
404 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
413 const int iComponent =
p_GetComp(p, rRing);
417 if( iComponentMonomM!=0 )
420 Werror(
"sca_p_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
427 if(iComponentMonomM==0 )
429 dReportError(
"sca_p_Mult_mm: Multiplication in the left module from the right");
482 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
485 poly* ppPrev = &pResult;
496 if( iComponentMonomM!=0 )
499 Werror(
"sca_pp_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
507 if(iComponentMonomM==0 )
509 dReportError(
"sca_pp_Mult_mm: Multiplication in the left module from the right");
549 poly* ppPrev = &pResult;
564 ppPrev = &
pNext(*ppPrev);
593 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
596 poly* ppPrev = &pResult;
605 if( iComponentMonomM!=0 )
610 Werror(
"sca_mm_Mult_pp: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
619 dReportError(
"sca_mm_Mult_pp: Multiplication in the left module from the right!");
633 ppPrev = &
pNext(*ppPrev);
666 const int iComponentMonomM =
p_GetComp(pMonom, rRing);
680 const int iComponent =
p_GetComp(p, rRing);
682 if( iComponentMonomM!=0 )
687 Werror(
"sca_mm_Mult_p: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
696 dReportError(
"sca_mm_Mult_p: Multiplication in the left module from the right!");
729 if( !
p_Test(pPoly, rRing) )
731 PrintS(
"pPoly is wrong!");
762 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
765 dReportError(
"sca_SPoly: different non-zero components!\n");
796 number C =
n_Gcd(C1,C2,r);
809 assume( (iSignSum*iSignSum == 0) || (iSignSum*iSignSum == 4) );
852 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
855 dReportError(
"sca_ReduceSpoly: different non-zero components!");
871 number C =
n_Gcd(C1, C2, r);
875 C1 =
n_Div(C1, C, r);
876 C2 =
n_Div(C2, C, r);
936 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 937 PrintS(
"sca_SetupQuotient(rGR, rG, bCopy)");
949 if(
rIsSCA(rG) && (rG != rGR))
967 PrintS(
"sca_SetupQuotient: qring?\n");
970 if(rGR->qideal ==
NULL)
974 PrintS(
"sca_SetupQuotient: qideal!!!\n");
982 int iAltVarStart = N+1;
985 const ring rBase = rG;
990 PrintS(
"sca_SetupQuotient: AltVars?!\n");
993 for(
int i = 1;
i <
N;
i++)
995 for(
int j =
i + 1;
j <=
N;
j++)
999 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1000 Print(
"Nonzero D[%d, %d]\n",
i,
j);
1011 if(
i < iAltVarStart)
1020 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1021 Print(
"Wrong Coeff at: [%d, %d]\n",
i,
j);
1029 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1030 Print(
"AltVars?1: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1034 if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) )
1038 for(
int i = 1;
i <
N;
i++)
1040 for(
int j =
i + 1;
j <=
N;
j++)
1045 if( (iAltVarStart <=
i) && (
j <= iAltVarEnd) )
1049 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1050 Print(
"Wrong Coeff at: [%d, %d]\n",
i,
j);
1058 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1059 Print(
"Wrong Coeff at: [%d, %d]\n",
i,
j);
1067 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1068 Print(
"AltVars!?: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1071 assume( 1 <= iAltVarStart );
1072 assume( iAltVarStart < iAltVarEnd );
1073 assume( iAltVarEnd <= N );
1083 const ideal idQuotient = rGR->qideal;
1086 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1087 PrintS(
"Analyzing quotient ideal:\n");
1106 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1107 Print(
"AltVars!?: [%d, %d]\n", b, e);
1111 for (
int i = iAltVarStart; (
i <= iAltVarEnd) && bSCA;
i++ )
1112 if( (
i < b) || (
i > e) )
1120 square =
nc_NF(idQuotient,
NULL, square, 0, 1, rG);
1122 if( square !=
NULL )
1130 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1131 Print(
"ScaVars!: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1138 ideal tempQ =
id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG);
1141 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1144 PrintS(
"tempSCAQuotient: \n");
1156 rGR->GetNC()->SCAQuotient() =
NULL;
1158 rGR->GetNC()->SCAQuotient() =
idrMoveR(tempQ, rG, rGR);
1163 #if ((defined(PDEBUG) && OUTPUT) || MYTEST) 1164 PrintS(
"SCAQuotient: \n");
1181 const int N = rGR->N;
1187 const ideal idQuotient = rGR->qideal;
1189 ideal tempQ = idQuotient;
1191 if( b <= N && e >= 1 )
1199 rGR->GetNC()->SCAQuotient() =
NULL;
1201 rGR->GetNC()->SCAQuotient() = tempQ;
1292 int& dx,
int& dy,
const ring
r)
1294 const unsigned int N = r->N;
1310 for(
int i = N;
i > 0;
i--)
1313 x += d * (*wx)[
i-1];
1314 y += d * (*wy)[
i-1];
1317 if( (wCx !=
NULL) && (wCy !=
NULL) )
1362 if ( (x != ddx) || (y != ddy) )
return false;
1378 if (
id ==
NULL)
return true;
1380 const int iSize =
IDELEMS(
id);
1382 if (iSize == 0)
return true;
1387 for(
int i = iSize - 1; (
i >= 0 ) && b;
i--)
1399 const unsigned int N = r->N;
1401 const int CommutativeVariable = 0;
1402 const int AntiCommutativeVariable = 0;
1406 if(AntiCommutativeVariable != CommutativeVariable)
1412 for (
unsigned int i = m_iFirstAltVar;
i<= m_iLastAltVar;
i++)
1414 (*w)[
i-1] = AntiCommutativeVariable;
1427 const unsigned int N = r->N;
1429 const int CommutativeVariable = 0;
1430 const int AntiCommutativeVariable = 1;
1434 if(AntiCommutativeVariable != CommutativeVariable)
1440 for (
unsigned int i = m_iFirstAltVar;
i<= m_iLastAltVar;
i++)
1442 (*w)[
i-1] = AntiCommutativeVariable;
1454 const short iFirstAltVar,
const short iLastAltVar,
1459 assume( (iFirstAltVar >= 1) && (iLastAltVar <=
rVar(r)) && (iFirstAltVar <= iLastAltVar) );
1462 Print(
"m_KillSquares, m = ");
1469 for(
short k = iFirstAltVar;
k <= iLastAltVar;
k++)
1480 const short iFirstAltVar,
const short iLastAltVar,
1486 assume( (iFirstAltVar >= 1) && (iLastAltVar <= r->
N) && (iFirstAltVar <= iLastAltVar) );
1489 Print(
"p_KillSquares, p = ");
1499 poly* ppPrev = &pResult;
1521 Print(
"p_KillSquares => ");
1535 const short iFirstAltVar,
const short iLastAltVar,
1536 const ring
r,
const bool bSkipZeroes)
1538 if (
id ==
NULL)
return id;
1540 assume( (iFirstAltVar >= 1) && (iLastAltVar <=
rVar(r)) && (iFirstAltVar <= iLastAltVar) );
1542 const int iSize =
IDELEMS(
id);
1544 if (iSize == 0)
return id;
1546 ideal temp =
idInit(iSize, id->rank);
1549 PrintS(
"<id_KillSquares>\n");
1552 for (
unsigned int i = 0;
i <
IDELEMS(
id);
i++)
1554 Print(
"; id[%d] = ",
i+1);
1563 for (
int j = 0;
j < iSize;
j++)
1570 PrintS(
"<id_KillSquares>\n");
1572 PrintS(
"ideal temp: \n");
1575 Print(
"; temp[%d] = ",
i+1);
1581 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 bool rIsPluralRing(const ring r)
we must always have this test!
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 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)