Loading...
Searching...
No Matches
sca.cc File Reference
`#include "misc/auxiliary.h"`
`#include "polys/nc/sca.h"`
`#include "polys/nc/nc.h"`
`#include "polys/nc/gb_hack.h"`
`#include "coeffs/numbers.h"`
`#include "misc/options.h"`
`#include "polys/monomials/p_polys.h"`
`#include "polys/simpleideals.h"`
`#include "misc/intvec.h"`
`#include "polys/monomials/ring.h"`
`#include "polys/kbuckets.h"`
`#include "polys/sbuckets.h"`
`#include "polys/prCopy.h"`
`#include "polys/operations/p_Mult_q.h"`
`#include "polys/templates/p_MemAdd.h"`
`#include "polys/weight.h"`

Go to the source code of this file.

## Macros

#define | OUTPUT 0
#define | MYTEST 0
#define | PLURAL_INTERNAL_DECLARATIONS

## Functions

poly | sca_pp_Mult_mm (const poly pPoly, const poly pMonom, const ring rRing, poly &)
static poly | sca_pp_mm_Mult (const poly pPoly, const poly pMonom, const ring rRing)
poly | sca_p_Mult_mm (poly pPoly, const poly pMonom, const ring rRing)
static poly | sca_p_mm_Mult (poly pPoly, const poly pMonom, const ring rRing)
poly | sca_SPoly (const poly p1, const poly p2, const ring r)
poly | sca_ReduceSpoly (const poly p1, poly p2, const ring r)
static int | sca_Sign_mm_Mult_mm (const poly pMonomM, const poly pMonomMM, const ring rRing)
static poly | sca_m_Mult_mm (poly pMonomM, const poly pMonomMM, const ring rRing)
static poly | sca_mm_Mult_m (const poly pMonomMM, poly pMonomM, const ring rRing)
static poly | sca_mm_Mult_mm (poly pMonom1, const poly pMonom2, const ring rRing)
static poly | sca_xi_Mult_mm (short i, const poly pMonom, const ring rRing)
poly | sca_pp_Mult_mm (const poly pPoly, const poly pMonom, const ring rRing)
static poly | sca_xi_Mult_pp (short i, const poly pPoly, const ring rRing)
bool | sca_SetupQuotient (ring rGR, ring rG, bool bCopy)
bool | sca_Force (ring rGR, int b, int e)
poly | sca_pp_Mult_xi_pp (short i, const poly pPoly, const ring rRing)
void | sca_p_ProcsSet (ring rGR, p_Procs_s *p_Procs)
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)
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)
bool | id_IsBiHomogeneous (const ideal id, const intvec *wx, const intvec *wy, const intvec *wCx, const intvec *wCy, const ring r)
intvec * | ivGetSCAXVarWeights (const ring r)
intvec * | ivGetSCAYVarWeights (const ring r)
static poly | m_KillSquares (const poly m, const short iFirstAltVar, const short iLastAltVar, const ring r)
poly | p_KillSquares (const poly p, const short iFirstAltVar, const short iLastAltVar, const ring r)
ideal | id_KillSquares (const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)

## Macro Definition Documentation

## MYTEST

#define MYTEST 0

Definition at line 13 of file sca.cc.

## OUTPUT

#define OUTPUT 0

Definition at line 12 of file sca.cc.

## PLURAL_INTERNAL_DECLARATIONS

#define PLURAL_INTERNAL_DECLARATIONS

Definition at line 29 of file sca.cc.

## Function Documentation

## id_IsBiHomogeneous()

bool id_IsBiHomogeneous | ( | const ideal | id,
|  | const intvec * | wx,
|  | const intvec * | wy,
|  | const intvec * | wCx,
|  | const intvec * | wCy,
|  | const ring | r )

Definition at line 1357 of file sca.cc.

{
if (id == NULL) return true; // zero ideal
const int iSize = IDELEMS(id);
if (iSize == 0) return true;
bool b = true;
int x, y;
for(int i = iSize - 1; (i >= 0 ) && b; i--)
b = p_IsBiHomogeneous(id->m[i], wx, wy, wCx, wCy, x, y, r);
return b;
}
i
int i
Definition cfEzgcd.cc:132
x
Variable x
Definition cfModGcd.cc:4090
b
CanonicalForm b
Definition cfModGcd.cc:4111
y
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53
p_IsBiHomogeneous
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)
Definition sca.cc:1318
NULL
#define NULL
Definition omList.c:12
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23

## id_KillSquares()

ideal id_KillSquares | ( | const ideal | id,
|  | const short | iFirstAltVar,
|  | const short | iLastAltVar,
|  | const ring | r,
|  | const bool | bSkipZeroes )

Definition at line 1518 of file sca.cc.

{
if (id == NULL) return id; // zero ideal
assume( (iFirstAltVar >= 1) && (iLastAltVar <= rVar(r)) && (iFirstAltVar <= iLastAltVar) );
const int iSize = IDELEMS(id);
if (iSize == 0) return id;
ideal temp = idInit(iSize, id->rank);
#if 0
PrintS("<id_KillSquares>\n");
{
PrintS("ideal id: \n");
for (unsigned int i = 0; i < IDELEMS(id); i++)
{
Print("; id[%d] = ", i+1);
p_Write(id->m[i], r);
}
PrintS(";\n");
PrintLn();
}
#endif
for (int j = 0; j < iSize; j++)
temp->m[j] = p_KillSquares(id->m[j], iFirstAltVar, iLastAltVar, r);
if( bSkipZeroes )
idSkipZeroes(temp);
#if 0
PrintS("<id_KillSquares>\n");
{
PrintS("ideal temp: \n");
for (int i = 0; i < IDELEMS(temp); i++)
{
Print("; temp[%d] = ", i+1);
p_Write(temp->m[i], r);
}
PrintS(";\n");
PrintLn();
}
PrintS("</id_KillSquares>\n");
#endif
// temp->rank = idRankFreeModule(temp, r);
return temp;
}
Print
#define Print
Definition emacs.cc:80
j
int j
Definition facHensel.cc:110
p_KillSquares
poly p_KillSquares(const poly p, const short iFirstAltVar, const short iLastAltVar, const ring r)
Definition sca.cc:1463
assume
#define assume(x)
Definition mod2.h:389
p_Write
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
PrintLn
void PrintLn()
Definition reporter.cc:314
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition simpleideals.cc:201

## ivGetSCAXVarWeights()

intvec * ivGetSCAXVarWeights | ( | const ring | r | ) |

Definition at line 1381 of file sca.cc.

{
const unsigned int N = r->N;
const int CommutativeVariable = 0; // bug correction!
const int AntiCommutativeVariable = 0;
intvec* w = new intvec(N, 1, CommutativeVariable);
if(AntiCommutativeVariable != CommutativeVariable)
if( rIsSCA(r) )
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(r);
const unsigned int m_iLastAltVar = scaLastAltVar(r);
for (unsigned int i = m_iFirstAltVar; i<= m_iLastAltVar; i++)
{
(*w)[i-1] = AntiCommutativeVariable;
}
}
return w;
}
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
intvec
Definition intvec.h:24
w
const CanonicalForm & w
Definition facAbsFact.cc:51
rIsSCA
static bool rIsSCA(const ring r)
Definition nc.h:190
scaLastAltVar
static short scaLastAltVar(ring r)
Definition sca.h:25
scaFirstAltVar
static short scaFirstAltVar(ring r)
Definition sca.h:18

## ivGetSCAYVarWeights()

intvec * ivGetSCAYVarWeights | ( | const ring | r | ) |

Definition at line 1409 of file sca.cc.

{
const unsigned int N = r->N;
const int CommutativeVariable = 0;
const int AntiCommutativeVariable = 1;
intvec* w = new intvec(N, 1, CommutativeVariable);
if(AntiCommutativeVariable != CommutativeVariable)
if( rIsSCA(r) )
{
const unsigned int m_iFirstAltVar = scaFirstAltVar(r);
const unsigned int m_iLastAltVar = scaLastAltVar(r);
for (unsigned int i = m_iFirstAltVar; i<= m_iLastAltVar; i++)
{
(*w)[i-1] = AntiCommutativeVariable;
}
}
return w;
}

## m_GetBiDegree()

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 )

inline static

Definition at line 1273 of file sca.cc.

{
const unsigned int N = r->N;
p_Test(m, r);
assume( wx != NULL );
assume( wy != NULL );
assume( wx->cols() == 1 );
assume( wy->cols() == 1 );
assume( (unsigned int)wx->rows() >= N );
assume( (unsigned int)wy->rows() >= N );
int x = 0;
int y = 0;
for(int i = N; i > 0; i--)
{
const int d = p_GetExp(m, i, r);
x += d * (*wx)[i-1];
y += d * (*wy)[i-1];
}
if( (wCx != NULL) && (wCy != NULL) )
{
const int c = p_GetComp(m, r);
if( wCx->range(c) )
x += (*wCx)[c];
if( wCy->range(c) )
x += (*wCy)[c];
}
dx = x;
dy = y;
}
m
int m
Definition cfEzgcd.cc:128
intvec::range
int range(int i) const
Definition intvec.h:60
intvec::cols
int cols() const
Definition intvec.h:96
intvec::rows
int rows() const
Definition intvec.h:97
p_GetComp
#define p_GetComp(p, r)
Definition monomials.h:64
p_GetExp
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
p_Test
#define p_Test(p, r)
Definition p_polys.h:161

## m_KillSquares()

poly m_KillSquares | ( | const poly | m,
|  | const short | iFirstAltVar,
|  | const short | iLastAltVar,
|  | const ring | r )

inline static

Definition at line 1437 of file sca.cc.

{
#ifdef PDEBUG
p_Test(m, r);
assume( (iFirstAltVar >= 1) && (iLastAltVar <= rVar(r)) && (iFirstAltVar <= iLastAltVar) );
#if 0
PrintS("m_KillSquares, m = "); // !
p_Write(m, r);
#endif
#endif
assume( m != NULL );
for(short k = iFirstAltVar; k <= iLastAltVar; k++)
if( p_GetExp(m, k, r) > 1 )
return NULL;
return p_Head(m, r);
}
k
int k
Definition cfEzgcd.cc:99
p_Head
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862

## p_IsBiHomogeneous()

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 )

Definition at line 1318 of file sca.cc.

{
if( p == NULL )
{
dx = 0;
dy = 0;
return true;
}
poly q = p;
int ddx, ddy;
m_GetBiDegree( q, wx, wy, wCx, wCy, ddx, ddy, r); // get bi degree of lm(p)
pIter(q);
for(; q != NULL; pIter(q) )
{
int x, y;
m_GetBiDegree( q, wx, wy, wCx, wCy, x, y, r); // get bi degree of q
if ( (x != ddx) || (y != ddy) ) return false;
}
dx = ddx;
dy = ddy;
return true;
}
p
int p
Definition cfModGcd.cc:4086
m_GetBiDegree
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)
Definition sca.cc:1273
pIter
#define pIter(p)
Definition monomials.h:37

## p_KillSquares()

poly p_KillSquares | ( | const poly | p,
|  | const short | iFirstAltVar,
|  | const short | iLastAltVar,
|  | const ring | r )

Definition at line 1463 of file sca.cc.

{
#ifdef PDEBUG
p_Test(p, r);
assume( (iFirstAltVar >= 1) && (iLastAltVar <= r->N) && (iFirstAltVar <= iLastAltVar) );
#if 0
PrintS("p_KillSquares, p = "); // !
p_Write(p, r);
#endif
#endif
if( p == NULL )
return NULL;
poly pResult = NULL;
poly* ppPrev = &pResult;
for( poly q = p; q!= NULL; pIter(q) )
{
#ifdef PDEBUG
p_Test(q, r);
#endif
// terms will be in the same order because of quasi-ordering!
poly v = m_KillSquares(q, iFirstAltVar, iLastAltVar, r);
if( v != NULL )
{
*ppPrev = v;
ppPrev = &pNext(v);
}
}
#ifdef PDEBUG
p_Test(pResult, r);
#if 0
PrintS("p_KillSquares => "); // !
p_Write(pResult, r);
#endif
#endif
return(pResult);
}
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
m_KillSquares
static poly m_KillSquares(const poly m, const short iFirstAltVar, const short iLastAltVar, const ring r)
Definition sca.cc:1437
pNext
#define pNext(p)
Definition monomials.h:36

## sca_Force()

bool sca_Force | ( | ring | rGR,
|  | int | b,
|  | int | e )

Definition at line 1159 of file sca.cc.

{
assume(rGR != NULL);
assume(rIsPluralRing(rGR));
assume(!rIsSCA(rGR));
const int N = rGR->N;
// ring rSaveRing = currRing;
// if(rSaveRing != rGR)
// rChangeCurrRing(rGR);
const ideal idQuotient = rGR->qideal;
ideal tempQ = idQuotient;
if( b <= N && e >= 1 )
tempQ = id_KillSquares(idQuotient, b, e, rGR);
idSkipZeroes( tempQ );
ncRingType( rGR, nc_exterior );
if( idIs0(tempQ) )
rGR->GetNC()->SCAQuotient() = NULL;
else
rGR->GetNC()->SCAQuotient() = tempQ;
scaFirstAltVar( rGR, b );
scaLastAltVar( rGR, e );
nc_p_ProcsSet(rGR, rGR->p_Procs);
// if(rSaveRing != rGR)
// rChangeCurrRing(rSaveRing);
return true;
}
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition simpleideals.cc:960
nc_p_ProcsSet
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
Definition old.gring.cc:3161
nc_exterior
@ nc_exterior
Definition nc.h:21
ncRingType
static nc_type & ncRingType(nc_struct *p)
Definition nc.h:159
id_KillSquares
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
Definition sca.cc:1518
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406

## sca_m_Mult_mm()

poly sca_m_Mult_mm | ( | poly | pMonomM,
|  | const poly | pMonomMM,
|  | const ring | rRing )

inline static

Definition at line 132 of file sca.cc.

{
#ifdef PDEBUG
p_Test(pMonomM, rRing);
p_Test(pMonomMM, rRing);
#endif
const unsigned int iFirstAltVar = scaFirstAltVar(rRing);
const unsigned int iLastAltVar = scaLastAltVar(rRing);
REGISTER unsigned int tpower = 0;
REGISTER unsigned int cpower = 0;
for( REGISTER unsigned int j = iLastAltVar; j >= iFirstAltVar; j-- )
{
const unsigned int iExpM = p_GetExp(pMonomM, j, rRing);
const unsigned int iExpMM = p_GetExp(pMonomMM, j, rRing);
#ifdef PDEBUG
assume( iExpM <= 1);
assume( iExpMM <= 1);
#endif
if( iExpMM != 0 )
{
if( iExpM != 0 ) // result is zero!
{
return NULL; // we do nothing with pMonomM in this case!
}
tpower ^= cpower; // compute degree of (-1).
}
cpower ^= iExpM;
}
#ifdef PDEBUG
assume(tpower <= 1);
#endif
p_ExpVectorAdd(pMonomM, pMonomMM, rRing); // "exponents" are additive!!!
number nCoeffM = p_GetCoeff(pMonomM, rRing); // no new copy! should be deleted!
if( (tpower) != 0 ) // degree is odd => negate coeff.
nCoeffM = n_InpNeg(nCoeffM, rRing->cf); // negate nCoeff (will destroy the original number)
const number nCoeffMM = p_GetCoeff(pMonomMM, rRing); // no new copy!
number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing->cf); // new number!
p_SetCoeff(pMonomM, nCoeff, rRing); // delete lc(pMonomM) and set lc(pMonomM) = nCoeff
#ifdef PDEBUG
p_LmTest(pMonomM, rRing);
#endif
return(pMonomM);
}
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
n_InpNeg
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)
Definition coeffs.h:560
p_GetCoeff
#define p_GetCoeff(p, r)
Definition monomials.h:50
REGISTER
#define REGISTER
Definition omalloc.h:27
p_ExpVectorAdd
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition p_polys.h:1432
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
p_LmTest
#define p_LmTest(p, r)
Definition p_polys.h:162

## sca_mm_Mult_m()

poly sca_mm_Mult_m | ( | const poly | pMonomMM,
|  | poly | pMonomM,
|  | const ring | rRing )

inline static

Definition at line 196 of file sca.cc.

{
#ifdef PDEBUG
p_Test(pMonomM, rRing);
p_Test(pMonomMM, rRing);
#endif
const unsigned int iFirstAltVar = scaFirstAltVar(rRing);
const unsigned int iLastAltVar = scaLastAltVar(rRing);
REGISTER unsigned int tpower = 0;
REGISTER unsigned int cpower = 0;
for( REGISTER unsigned int j = iLastAltVar; j >= iFirstAltVar; j-- )
{
const unsigned int iExpMM = p_GetExp(pMonomMM, j, rRing);
const unsigned int iExpM = p_GetExp(pMonomM, j, rRing);
#ifdef PDEBUG
assume( iExpM <= 1);
assume( iExpMM <= 1);
#endif
if( iExpM != 0 )
{
if( iExpMM != 0 ) // result is zero!
{
return NULL; // we do nothing with pMonomM in this case!
}
tpower ^= cpower; // compute degree of (-1).
}
cpower ^= iExpMM;
}
#ifdef PDEBUG
assume(tpower <= 1);
#endif
p_ExpVectorAdd(pMonomM, pMonomMM, rRing); // "exponents" are additive!!!
number nCoeffM = p_GetCoeff(pMonomM, rRing); // no new copy! should be deleted!
if( (tpower) != 0 ) // degree is odd => negate coeff.
nCoeffM = n_InpNeg(nCoeffM, rRing->cf); // negate nCoeff (will destroy the original number), creates new number!
const number nCoeffMM = p_GetCoeff(pMonomMM, rRing); // no new copy!
number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing->cf); // new number!
p_SetCoeff(pMonomM, nCoeff, rRing); // delete lc(pMonomM) and set lc(pMonomM) = nCoeff
#ifdef PDEBUG
p_LmTest(pMonomM, rRing);
#endif
return(pMonomM);
}

## sca_mm_Mult_mm()

poly sca_mm_Mult_mm | ( | poly | pMonom1,
|  | const poly | pMonom2,
|  | const ring | rRing )

inline static

Definition at line 261 of file sca.cc.

{
#ifdef PDEBUG
p_Test(pMonom1, rRing);
p_Test(pMonom2, rRing);
#endif
const unsigned int iFirstAltVar = scaFirstAltVar(rRing);
const unsigned int iLastAltVar = scaLastAltVar(rRing);
REGISTER unsigned int tpower = 0;
REGISTER unsigned int cpower = 0;
for( REGISTER unsigned int j = iLastAltVar; j >= iFirstAltVar; j-- )
{
const unsigned int iExp1 = p_GetExp(pMonom1, j, rRing);
const unsigned int iExp2 = p_GetExp(pMonom2, j, rRing);
#ifdef PDEBUG
assume( iExp1 <= 1);
assume( iExp2 <= 1);
#endif
if( iExp2 != 0 )
{
if( iExp1 != 0 ) // result is zero!
{
return NULL;
}
tpower ^= cpower; // compute degree of (-1).
}
cpower ^= iExp1;
}
#ifdef PDEBUG
assume(cpower <= 1);
#endif
poly pResult;
p_AllocBin(pResult,rRing->PolyBin,rRing);
p_ExpVectorSum(pResult, pMonom1, pMonom2, rRing); // "exponents" are additive!!!
pNext(pResult) = NULL;
const number nCoeff1 = p_GetCoeff(pMonom1, rRing); // no new copy!
const number nCoeff2 = p_GetCoeff(pMonom2, rRing); // no new copy!
number nCoeff = n_Mult(nCoeff1, nCoeff2, rRing->cf); // new number!
if( (tpower) != 0 ) // degree is odd => negate coeff.
nCoeff = n_InpNeg(nCoeff, rRing->cf); // negate nCoeff (will destroy the original number)
p_SetCoeff0(pResult, nCoeff, rRing); // set lc(pResult) = nCoeff, no destruction!
#ifdef PDEBUG
p_LmTest(pResult, rRing);
#endif
return(pResult);
}
p_SetCoeff0
#define p_SetCoeff0(p, n, r)
Definition monomials.h:60
p_AllocBin
#define p_AllocBin(p, bin, r)
Definition monomials.h:210
p_ExpVectorSum
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1446

## sca_p_mm_Mult()

poly sca_p_mm_Mult | ( | poly | pPoly,
|  | const poly | pMonom,
|  | const ring | rRing )

static

Definition at line 635 of file sca.cc.

{
assume( rIsSCA(rRing) );
#ifdef PDEBUG
p_Test(pPoly, rRing);
p_Test(pMonom, rRing);
#endif
if( pPoly == NULL )
return NULL;
assume(pMonom!=NULL);
//if( pMonom == NULL )
//{
// // pPoly != NULL =>
// p_Delete( &pPoly, rRing );
// return NULL;
//}
const int iComponentMonomM = p_GetComp(pMonom, rRing);
poly p = pPoly; poly* ppPrev = &pPoly;
loop
{
#ifdef PDEBUG
if( !p_Test(p, rRing) )
{
PrintS("p is wrong!");
p_Write(p,rRing);
}
#endif
const int iComponent = p_GetComp(p, rRing);
if( iComponentMonomM!=0 )
{
if( iComponent!=0 )
{
// REPORT_ERROR
Werror("sca_p_mm_Mult: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
// what should we do further?!?
p_Delete( &pPoly, rRing); // delete the result
return NULL;
}
#ifdef PDEBUG
if(iComponent==0)
{
dReportError("sca_p_mm_Mult: Multiplication in the left module from the right!");
// PrintS("mm = "); p_Write(pMonom, rRing);
// PrintS("p = "); p_Write(pPoly, rRing);
// assume(iComponent!=0);
}
#endif
}
// terms will be in the same order because of quasi-ordering!
poly v = sca_mm_Mult_m(pMonom, p, rRing);
if( v != NULL )
{
ppPrev = &pNext(p);
// *p is changed if v != NULL ( p == v )
pIter(p);
if( p == NULL )
break;
}
else
{ // Upps! Zero!!! we must kill this term!
p = p_LmDeleteAndNext(p, rRing);
*ppPrev = p;
if( p == NULL )
break;
}
}
#ifdef PDEBUG
if( !p_Test(pPoly, rRing) )
{
PrintS("pPoly is wrong!");
p_Write(pPoly, rRing);
}
#endif
return(pPoly);
}
sca_mm_Mult_m
static poly sca_mm_Mult_m(const poly pMonomMM, poly pMonomM, const ring rRing)
Definition sca.cc:196
dReportError
int dReportError(const char *fmt,...)
Definition dError.cc:44
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
p_LmDeleteAndNext
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
loop
#define loop
Definition structs.h:71

## sca_p_Mult_mm()

poly sca_p_Mult_mm | ( | poly | pPoly,
|  | const poly | pMonom,
|  | const ring | rRing )

Definition at line 371 of file sca.cc.

{
assume( rIsSCA(rRing) );
#ifdef PDEBUG
// PrintS("sca_p_Mult_mm\n"); // !
p_Test(pPoly, rRing);
p_Test(pMonom, rRing);
#endif
if( pPoly == NULL )
return NULL;
assume(pMonom !=NULL);
//if( pMonom == NULL )
//{
// // pPoly != NULL =>
// p_Delete( &pPoly, rRing );
// return NULL;
//}
const int iComponentMonomM = p_GetComp(pMonom, rRing);
poly p = pPoly; poly* ppPrev = &pPoly;
loop
{
#ifdef PDEBUG
p_Test(p, rRing);
#endif
const int iComponent = p_GetComp(p, rRing);
if( iComponent!=0 )
{
if( iComponentMonomM!=0 ) // TODO: make global if on iComponentMonomM =?= 0
{
// REPORT_ERROR
Werror("sca_p_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
// what should we do further?!?
p_Delete( &pPoly, rRing); // delete the result AND rest
return NULL;
}
#ifdef PDEBUG
if(iComponentMonomM==0 )
{
dReportError("sca_p_Mult_mm: Multiplication in the left module from the right");
}
#endif
}
// terms will be in the same order because of quasi-ordering!
poly v = sca_m_Mult_mm(p, pMonom, rRing);
if( v != NULL )
{
ppPrev = &pNext(p); // fixed!
// *p is changed if v != NULL ( p == v )
pIter(p);
if( p == NULL )
break;
}
else
{ // Upps! Zero!!! we must kill this term!
//
p = p_LmDeleteAndNext(p, rRing);
*ppPrev = p;
if( p == NULL )
break;
}
}
#ifdef PDEBUG
p_Test(pPoly,rRing);
#endif
return(pPoly);
}
sca_m_Mult_mm
static poly sca_m_Mult_mm(poly pMonomM, const poly pMonomMM, const ring rRing)
Definition sca.cc:132

## sca_p_ProcsSet()

void sca_p_ProcsSet | ( | ring | rGR,
|  | p_Procs_s * | p_Procs )

Definition at line 1223 of file sca.cc.

{
// "commutative" procedures:
rGR->p_Procs->p_Mult_mm = sca_p_Mult_mm;
rGR->p_Procs->pp_Mult_mm = sca_pp_Mult_mm;
p_Procs->p_Mult_mm = sca_p_Mult_mm;
p_Procs->pp_Mult_mm = sca_pp_Mult_mm;
// non-commutaitve
p_Procs->p_mm_Mult = sca_p_mm_Mult;
p_Procs->pp_mm_Mult = sca_pp_mm_Mult;
// rGR->GetNC()->p_Procs.SPoly = sca_SPoly;
// rGR->GetNC()->p_Procs.ReduceSPoly = sca_ReduceSpoly;
#if 0
// Multiplication procedures:
p_Procs->p_Mult_mm = sca_p_Mult_mm;
_p_procs->p_Mult_mm = sca_p_Mult_mm;
p_Procs->pp_Mult_mm = sca_pp_Mult_mm;
_p_procs->pp_Mult_mm = sca_pp_Mult_mm;
r->GetNC()->mmMultP() = sca_mm_Mult_p;
r->GetNC()->mmMultPP() = sca_mm_Mult_pp;
/*
// ??????????????????????????????????????? coefficients swell...
r->GetNC()->SPoly() = sca_SPoly;
r->GetNC()->ReduceSPoly() = sca_ReduceSpoly;
*/
// r->GetNC()->BucketPolyRed() = gnc_kBucketPolyRed;
// r->GetNC()->BucketPolyRed_Z()= gnc_kBucketPolyRed_Z;
#endif
// local ordering => Mora, otherwise - Buchberger!
if (rHasLocalOrMixedOrdering(rGR))
rGR->GetNC()->p_Procs.GB = cast_A_to_vptr(sca_mora);
else
rGR->GetNC()->p_Procs.GB = cast_A_to_vptr(sca_bba); // sca_gr_bba?
}
cast_A_to_vptr
void * cast_A_to_vptr(A a)
Definition auxiliary.h:386
sca_mora
EXTERN_VAR BBA_Proc sca_mora
Definition gb_hack.h:10
sca_bba
EXTERN_VAR BBA_Proc sca_bba
Definition gb_hack.h:10
sca_p_mm_Mult
static poly sca_p_mm_Mult(poly pPoly, const poly pMonom, const ring rRing)
Definition sca.cc:635
sca_pp_Mult_mm
poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &)
sca_p_Mult_mm
poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing)
Definition sca.cc:371
sca_pp_mm_Mult
static poly sca_pp_mm_Mult(const poly pPoly, const poly pMonom, const ring rRing)
Definition sca.cc:567
_p_procs
STATIC_VAR p_Procs_s * _p_procs
Definition p_Procs_Set.h:116
rHasLocalOrMixedOrdering
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769

## sca_pp_mm_Mult()

poly sca_pp_mm_Mult | ( | const poly | pPoly,
|  | const poly | pMonom,
|  | const ring | rRing )

static

Definition at line 567 of file sca.cc.

{
assume( rIsSCA(rRing) );
#ifdef PDEBUG
// PrintS("sca_mm_Mult_pp\n"); // !
p_Test(pPoly, rRing);
p_Test(pMonom, rRing);
#endif
if ((pPoly==NULL) || (pMonom==NULL)) return NULL;
assume( (pPoly != NULL) && (pMonom !=NULL));
const int iComponentMonomM = p_GetComp(pMonom, rRing);
poly pResult = NULL;
poly* ppPrev = &pResult;
for( poly p = pPoly; p!= NULL; pIter(p) )
{
#ifdef PDEBUG
p_Test(p, rRing);
#endif
const int iComponent = p_GetComp(p, rRing);
if( iComponentMonomM!=0 )
{
if( iComponent!=0 ) // TODO: make global if on iComponentMonomM =?= 0
{
// REPORT_ERROR
Werror("sca_pp_mm_Mult: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
// what should we do further?!?
p_Delete( &pResult, rRing); // delete the result
return NULL;
}
#ifdef PDEBUG
if(iComponent==0 )
{
dReportError("sca_pp_mm_Mult: Multiplication in the left module from the right!");
// PrintS("mm = "); p_Write(pMonom, rRing);
// PrintS("pp = "); p_Write(pPoly, rRing);
// assume(iComponent!=0);
}
#endif
}
// terms will be in the same order because of quasi-ordering!
poly v = sca_mm_Mult_mm(pMonom, p, rRing);
if( v != NULL )
{
*ppPrev = v;
ppPrev = &pNext(*ppPrev); // nice line ;-)
}
}
#ifdef PDEBUG
p_Test(pResult,rRing);
#endif
return(pResult);
}
sca_mm_Mult_mm
static poly sca_mm_Mult_mm(poly pMonom1, const poly pMonom2, const ring rRing)
Definition sca.cc:261

## sca_pp_Mult_mm() [1/2]

poly sca_pp_Mult_mm | ( | const poly | pPoly,
|  | const poly | pMonom,
|  | const ring | rRing )

Definition at line 457 of file sca.cc.

{
assume( rIsSCA(rRing) );
#ifdef PDEBUG
// PrintS("sca_pp_Mult_mm\n"); // !
p_Test(pPoly, rRing);
p_Test(pMonom, rRing);
#endif
if (/*(*/ pPoly == NULL /*)*/) /*|| ( pMonom == NULL )*/
return NULL;
const int iComponentMonomM = p_GetComp(pMonom, rRing);
poly pResult = NULL;
poly* ppPrev = &pResult;
for( poly p = pPoly; p!= NULL; pIter(p) )
{
#ifdef PDEBUG
p_Test(p, rRing);
#endif
const int iComponent = p_GetComp(p, rRing);
if( iComponent!=0 )
{
if( iComponentMonomM!=0 ) // TODO: make global if on iComponentMonomM =?= 0
{
// REPORT_ERROR
Werror("sca_pp_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
// what should we do further?!?
p_Delete( &pResult, rRing); // delete the result
return NULL;
}
#ifdef PDEBUG
if(iComponentMonomM==0 )
{
dReportError("sca_pp_Mult_mm: Multiplication in the left module from the right");
}
#endif
}
// terms will be in the same order because of quasi-ordering!
poly v = sca_mm_Mult_mm(p, pMonom, rRing);
if( v != NULL )
{
*ppPrev = v;
ppPrev = &pNext(v);
}
}
#ifdef PDEBUG
p_Test(pResult,rRing);
#endif
return(pResult);
}

## sca_pp_Mult_mm() [2/2]

poly sca_pp_Mult_mm | ( | const poly | pPoly,
|  | const poly | pMonom,
|  | const ring | rRing,
|  | poly & | )

## sca_pp_Mult_xi_pp()

poly sca_pp_Mult_xi_pp | ( | short | i,
|  | const poly | pPoly,
|  | const ring | rRing )

Definition at line 1201 of file sca.cc.

{
assume(1 <= i);
assume(i <= rVar(rRing));
if(rIsSCA(rRing))
return sca_xi_Mult_pp(i, pPoly, rRing);
poly xi = p_One( rRing);
p_SetExp(xi, i, 1, rRing);
p_Setm(xi, rRing);
poly pResult = pp_Mult_qq(xi, pPoly, rRing);
p_Delete( &xi, rRing);
return pResult;
}
sca_xi_Mult_pp
static poly sca_xi_Mult_pp(short i, const poly pPoly, const ring rRing)
Definition sca.cc:523
p_One
poly p_One(const ring r)
Definition p_polys.cc:1314
p_SetExp
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
Definition p_polys.h:490
p_Setm
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167

## sca_ReduceSpoly()

poly sca_ReduceSpoly | ( | const poly | p1,
|  | poly | p2,
|  | const ring | r )

Definition at line 831 of file sca.cc.

{
assume( rIsSCA(r) );
assume( p1 != NULL );
const long lCompP1 = p_GetComp (p1, r);
const long lCompP2 = p_GetComp (p2, r);
if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
{
#ifdef PDEBUG
dReportError("sca_ReduceSpoly: different non-zero components!");
#endif
return(NULL);
}
poly m = p_ISet (1, r);
p_ExpVectorDiff (m, p2, p1, r); // m = lm(p2) / lm(p1)
//p_Setm(m,r);
#ifdef PDEBUG
p_Test (m,r);
#endif
number C1 = n_Copy( pGetCoeff(p1), r->cf);
number C2 = n_Copy( pGetCoeff(p2), r->cf);
/* GCD stuff */
number C = n_Gcd(C1, C2, r->cf);
if (!n_IsOne(C, r->cf))
{
C1 = n_Div(C1, C, r->cf);
C2 = n_Div(C2, C, r->cf);
}
n_Delete(&C,r->cf);
const int iSign = sca_Sign_mm_Mult_mm( m, p1, r );
if(iSign == 1)
C2 = n_InpNeg(C2,r->cf);
p_SetCoeff(m, C2, r);
#ifdef PDEBUG
p_Test(m,r);
#endif
p2 = p_LmDeleteAndNext( p2, r );
p2 = p_Mult_nn(p2, C1, r); // p2 !!!
n_Delete(&C1,r->cf);
poly T = nc_mm_Mult_pp(m, pNext(p1), r);
p_Delete(&m, r);
p2 = p_Add_q(p2, T, r);
if ( p2!=NULL ) p_Cleardenom(p2,r);
#ifdef PDEBUG
p_Test(p2,r);
#endif
return(p2);
}
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457
n_Gcd
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,...
Definition coeffs.h:667
n_Div
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...
Definition coeffs.h:618
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:474
T
STATIC_VAR jList * T
Definition janet.cc:30
nc_mm_Mult_pp
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition nc.h:224
sca_Sign_mm_Mult_mm
static int sca_Sign_mm_Mult_mm(const poly pMonomM, const poly pMonomMM, const ring rRing)
Definition sca.cc:81
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
p_ISet
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
p_Cleardenom
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
p_ExpVectorDiff
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1495
p_Mult_nn
static poly p_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:960

## sca_SetupQuotient()

bool sca_SetupQuotient | ( | ring | rGR,
|  | ring | rG,
|  | bool | bCopy )

Definition at line 911 of file sca.cc.

{
//////////////////////////////////////////////////////////////////////////
// checks...
//////////////////////////////////////////////////////////////////////////
if( rG == NULL )
rG = rGR;
assume(rGR != NULL);
assume(rG != NULL);
assume(rIsPluralRing(rG));
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
PrintS("sca_SetupQuotient(rGR, rG, bCopy)");
{
PrintS("\nrG: \n"); rWrite(rG);
PrintS("\nrGR: \n"); rWrite(rGR);
PrintLn();
}
#endif
if(bCopy)
{
if(rIsSCA(rG) && (rG != rGR))
return sca_Force(rGR, scaFirstAltVar(rG), scaLastAltVar(rG));
else
return false;
}
assume(!bCopy);
const int N = rG->N;
// if( (ncRingType(rG) != nc_skew) || (ncRingType(rG) != nc_comm) )
// return false;
#if OUTPUT
PrintS("sca_SetupQuotient: qring?\n");
#endif
if(rGR->qideal == NULL) // there should be a factor!
return false;
#if OUTPUT
PrintS("sca_SetupQuotient: qideal!!!\n");
#endif
// if((rG->qideal != NULL) && (rG != rGR) ) // we cannot change from factor to factor at the time, sorry!
// return false;
int iAltVarEnd = -1;
int iAltVarStart = N+1;
const nc_struct* NC = rG->GetNC();
const ring rBase = rG; //NC->basering;
const matrix C = NC->C; // live in rBase!
const matrix D = NC->D; // live in rBase!
#if OUTPUT
PrintS("sca_SetupQuotient: AltVars?!\n");
#endif
for(int i = 1; i < N; i++)
{
for(int j = i + 1; j <= N; j++)
{
if( MATELEM(D,i,j) != NULL) // !!!???
{
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("Nonzero D[%d, %d]\n", i, j);
#endif
return false;
}
assume(MATELEM(C,i,j) != NULL); // after CallPlural!
number c = p_GetCoeff(MATELEM(C,i,j), rBase);
if( n_IsMOne(c, rBase->cf) ) // !!!???
{
if( i < iAltVarStart)
iAltVarStart = i;
if( j > iAltVarEnd)
iAltVarEnd = j;
} else
{
if( !n_IsOne(c, rBase->cf) )
{
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("Wrong Coeff at: [%d, %d]\n", i, j);
#endif
return false;
}
}
}
}
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("AltVars?1: [%d, %d]\n", iAltVarStart, iAltVarEnd);
#endif
if((iAltVarEnd == -1) || (iAltVarStart == (N+1)))
{
if (N>1) return false; // no alternating variables
iAltVarEnd=iAltVarStart=1;
}
for(int i = 1; i < N; i++)
{
for(int j = i + 1; j <= N; j++)
{
assume(MATELEM(C,i,j) != NULL); // after CallPlural!
number c = p_GetCoeff(MATELEM(C,i,j), rBase);
if( (iAltVarStart <= i) && (j <= iAltVarEnd) ) // S <= i < j <= E
{ // anticommutative part
if( !n_IsMOne(c, rBase->cf) )
{
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("Wrong Coeff at: [%d, %d]\n", i, j);
#endif
return false;
}
}
else
{ // should commute
if( !n_IsOne(c, rBase->cf) )
{
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("Wrong Coeff at: [%d, %d]\n", i, j);
#endif
return false;
}
}
}
}
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("AltVars!?: [%d, %d]\n", iAltVarStart, iAltVarEnd);
#endif
assume( 1 <= iAltVarStart );
assume( iAltVarStart <= iAltVarEnd );
assume( iAltVarEnd <= N );
// ring rSaveRing = assureCurrentRing(rG);
assume(rGR->qideal != NULL);
assume(rGR->N == rG->N);
// assume(rG->qideal == NULL); // ?
const ideal idQuotient = rGR->qideal;
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
PrintS("Analyzing quotient ideal:\n");
idPrint(idQuotient); // in rG!!!
#endif
// check for
// y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart)
// to be within quotient ideal.
int b = N+1;
int e = -1;
if(rIsSCA(rG))
{
b = si_min(b, scaFirstAltVar(rG));
e = si_max(e, scaLastAltVar(rG));
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("AltVars!?: [%d, %d]\n", b, e);
#endif
}
for ( int i = iAltVarStart; (i <= iAltVarEnd); i++ )
if( (i < b) || (i > e) ) // otherwise it's ok since rG is an SCA!
{
poly square = p_One( rG);
p_SetExp(square, i, 2, rG); // square = var(i)^2.
p_Setm(square, rG);
// square = NF( var(i)^2 | Q )
// NOTE: there is no better way to check this in general!
square = nc_NF(idQuotient, NULL, square, 0, 1, rG); // must ran in currRing == rG!
if( square != NULL ) // var(i)^2 is not in Q?
{
p_Delete(&square, rG);
return false;
}
}
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
Print("ScaVars!: [%d, %d]\n", iAltVarStart, iAltVarEnd);
#endif
//////////////////////////////////////////////////////////////////////////
// ok... here we go. let's setup it!!!
//////////////////////////////////////////////////////////////////////////
ideal tempQ = id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG); // in rG!!!
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
PrintS("Quotient: \n");
iiWriteMatrix((matrix)idQuotient,"__",1, rG, 0);
PrintS("tempSCAQuotient: \n");
iiWriteMatrix((matrix)tempQ,"__",1, rG, 0);
#endif
idSkipZeroes( tempQ );
ncRingType( rGR, nc_exterior );
scaFirstAltVar( rGR, iAltVarStart );
scaLastAltVar( rGR, iAltVarEnd );
if( idIs0(tempQ) )
rGR->GetNC()->SCAQuotient() = NULL;
else
rGR->GetNC()->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ!
nc_p_ProcsSet(rGR, rGR->p_Procs); // !!!!!!!!!!!!!!!!!
#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
PrintS("SCAQuotient: \n");
if(tempQ != NULL)
iiWriteMatrix((matrix)tempQ,"__",1, rGR, 0);
else
PrintS("(NULL)\n");
#endif
return true;
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126
n_IsMOne
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.
Definition coeffs.h:478
nc_NF
EXTERN_VAR NF_Proc nc_NF
Definition gb_hack.h:9
D
#define D(A)
Definition gentable.cc:128
idPrint
#define idPrint(id)
Definition ideals.h:46
sca_Force
bool sca_Force(ring rGR, int b, int e)
Definition sca.cc:1159
iiWriteMatrix
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition matpol.cc:828
MATELEM
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
matrix
ip_smatrix * matrix
Definition matpol.h:43
idrMoveR
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
rWrite
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
nc_struct
Definition nc.h:68
nc_struct::C
matrix C
Definition nc.h:75
nc_struct::D
matrix D
Definition nc.h:76

## sca_Sign_mm_Mult_mm()

int sca_Sign_mm_Mult_mm | ( | const poly | pMonomM,
|  | const poly | pMonomMM,
|  | const ring | rRing )

inline static

Definition at line 81 of file sca.cc.

{
#ifdef PDEBUG
p_Test(pMonomM, rRing);
p_Test(pMonomMM, rRing);
#endif
const short iFirstAltVar = scaFirstAltVar(rRing);
const short iLastAltVar = scaLastAltVar(rRing);
REGISTER unsigned int tpower = 0;
REGISTER unsigned int cpower = 0;
for( REGISTER short j = iLastAltVar; j >= iFirstAltVar; j-- )
{
const unsigned int iExpM = p_GetExp(pMonomM, j, rRing);
const unsigned int iExpMM = p_GetExp(pMonomMM, j, rRing);
#ifdef PDEBUG
assume( iExpM <= 1);
assume( iExpMM <= 1);
#endif
if( iExpMM != 0 ) // TODO: think about eliminating there if-s...
{
if( iExpM != 0 )
{
return 0; // lm(pMonomM) * lm(pMonomMM) == 0
}
tpower ^= cpower; // compute degree of (-1).
}
cpower ^= iExpM;
}
#ifdef PDEBUG
assume(tpower <= 1);
#endif
// 1 => -1 // degree is odd => negate coeff.
// 0 => 1
return(1 - (tpower << 1) );
}

## sca_SPoly()

poly sca_SPoly | ( | const poly | p1,
|  | const poly | p2,
|  | const ring | r )

Definition at line 744 of file sca.cc.

{
assume( rIsSCA(r) );
const long lCompP1 = p_GetComp(p1,r);
const long lCompP2 = p_GetComp(p2,r);
if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
{
#ifdef PDEBUG
dReportError("sca_SPoly: different non-zero components!\n");
#endif
return(NULL);
}
poly pL = p_Lcm(p1, p2, r); // pL = lcm( lm(p1), lm(p2) )
poly m1 = p_One( r);
p_ExpVectorDiff(m1, pL, p1, r); // m1 = pL / lm(p1)
//p_SetComp(m1,0,r);
//p_Setm(m1,r);
#ifdef PDEBUG
p_Test(m1,r);
#endif
poly m2 = p_One( r);
p_ExpVectorDiff (m2, pL, p2, r); // m2 = pL / lm(p2)
//p_SetComp(m2,0,r);
//p_Setm(m2,r);
#ifdef PDEBUG
p_Test(m2,r);
#endif
p_Delete(&pL,r);
number C1 = n_Copy(pGetCoeff(p1),r->cf); // C1 = lc(p1)
number C2 = n_Copy(pGetCoeff(p2),r->cf); // C2 = lc(p2)
number C = n_Gcd(C1,C2,r->cf); // C = gcd(C1, C2)
if (!n_IsOne(C, r->cf)) // if C != 1
{
C1=n_Div(C1, C, r->cf); // C1 = C1 / C
C2=n_Div(C2, C, r->cf); // C2 = C2 / C
}
n_Delete(&C,r->cf); // destroy the number C
const int iSignSum = sca_Sign_mm_Mult_mm (m1, p1, r) + sca_Sign_mm_Mult_mm (m2, p2, r);
// zero if different signs
assume( (iSignSum*iSignSum == 0) || (iSignSum*iSignSum == 4) );
if( iSignSum != 0 ) // the same sign!
C2=n_InpNeg (C2, r->cf);
p_SetCoeff(m1, C2, r); // lc(m1) = C2!!!
p_SetCoeff(m2, C1, r); // lc(m2) = C1!!!
poly tmp1 = nc_mm_Mult_pp (m1, pNext(p1), r); // tmp1 = m1 * tail(p1),
p_Delete(&m1,r); // => n_Delete(&C1,r);
poly tmp2 = nc_mm_Mult_pp (m2, pNext(p2), r); // tmp1 = m2 * tail(p2),
p_Delete(&m2,r); // => n_Delete(&C1,r);
poly spoly = p_Add_q (tmp1, tmp2, r); // spoly = spoly(lt(p1), lt(p2)) + m1 * tail(p1), delete tmp1,2
if (spoly!=NULL) p_Cleardenom (spoly, r);
#ifdef PDEBUG
p_Test (spoly, r);
#endif
return(spoly);
}
tmp1
CFList tmp1
Definition facFqBivar.cc:75
tmp2
CFList tmp2
Definition facFqBivar.cc:75
p_Lcm
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659

## sca_xi_Mult_mm()

poly sca_xi_Mult_mm | ( | short | i,
|  | const poly | pMonom,
|  | const ring | rRing )

inline static

Definition at line 326 of file sca.cc.

{
#ifdef PDEBUG
p_Test(pMonom, rRing);
#endif
assume( i <= scaLastAltVar(rRing));
assume( scaFirstAltVar(rRing) <= i );
if( p_GetExp(pMonom, i, rRing) != 0 ) // => result is zero!
return NULL;
const short iFirstAltVar = scaFirstAltVar(rRing);
REGISTER unsigned int cpower = 0;
for( REGISTER short j = iFirstAltVar; j < i ; j++ )
cpower ^= p_GetExp(pMonom, j, rRing);
#ifdef PDEBUG
assume(cpower <= 1);
#endif
poly pResult = p_LmInit(pMonom, rRing);
p_SetExp(pResult, i, 1, rRing); // pResult*=X_i &&
p_Setm(pResult, rRing); // adjust degree after previous step!
number nCoeff = n_Copy(pGetCoeff(pMonom), rRing->cf); // new number!
if( cpower != 0 ) // degree is odd => negate coeff.
nCoeff = n_InpNeg(nCoeff, rRing->cf); // negate nCoeff (will destroy the original number)
p_SetCoeff0(pResult, nCoeff, rRing); // set lc(pResult) = nCoeff, no destruction!
#ifdef PDEBUG
p_LmTest(pResult, rRing);
#endif
return(pResult);
}
p_LmInit
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1356

## sca_xi_Mult_pp()

poly sca_xi_Mult_pp | ( | short | i,
|  | const poly | pPoly,
|  | const ring | rRing )

inline static

Definition at line 523 of file sca.cc.

{
assume( rIsSCA(rRing) );
#ifdef PDEBUG
p_Test(pPoly, rRing);
#endif
assume(i <= scaLastAltVar(rRing));
assume(scaFirstAltVar(rRing) <= i);
if( pPoly == NULL )
return NULL;
poly pResult = NULL;
poly* ppPrev = &pResult;
for( poly p = pPoly; p!= NULL; pIter(p) )
{
// terms will be in the same order because of quasi-ordering!
poly v = sca_xi_Mult_mm(i, p, rRing);
#ifdef PDEBUG
p_Test(v, rRing);
#endif
if( v != NULL )
{
*ppPrev = v;
ppPrev = &pNext(*ppPrev);
}
}
#ifdef PDEBUG
p_Test(pResult, rRing);
#endif
return(pResult);
}
sca_xi_Mult_mm
static poly sca_xi_Mult_mm(short i, const poly pMonom, const ring rRing)
Definition sca.cc:326