My Project
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)
 
intvecivGetSCAXVarWeights (const ring r)
 
intvecivGetSCAYVarWeights (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.

1361{
1362 if (id == NULL) return true; // zero ideal
1363
1364 const int iSize = IDELEMS(id);
1365
1366 if (iSize == 0) return true;
1367
1368 bool b = true;
1369 int x, y;
1370
1371 for(int i = iSize - 1; (i >= 0 ) && b; i--)
1372 b = p_IsBiHomogeneous(id->m[i], wx, wy, wCx, wCy, x, y, r);
1373
1374 return b;
1375}
int i
Definition cfEzgcd.cc:132
Variable x
Definition cfModGcd.cc:4090
CanonicalForm b
Definition cfModGcd.cc:4111
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53
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
#define NULL
Definition omList.c:12
#define IDELEMS(i)

◆ 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.

1521{
1522 if (id == NULL) return id; // zero ideal
1523
1524 assume( (iFirstAltVar >= 1) && (iLastAltVar <= rVar(r)) && (iFirstAltVar <= iLastAltVar) );
1525
1526 const int iSize = IDELEMS(id);
1527
1528 if (iSize == 0) return id;
1529
1530 ideal temp = idInit(iSize, id->rank);
1531
1532#if 0
1533 PrintS("<id_KillSquares>\n");
1534 {
1535 PrintS("ideal id: \n");
1536 for (unsigned int i = 0; i < IDELEMS(id); i++)
1537 {
1538 Print("; id[%d] = ", i+1);
1539 p_Write(id->m[i], r);
1540 }
1541 PrintS(";\n");
1542 PrintLn();
1543 }
1544#endif
1545
1546
1547 for (int j = 0; j < iSize; j++)
1548 temp->m[j] = p_KillSquares(id->m[j], iFirstAltVar, iLastAltVar, r);
1549
1550 if( bSkipZeroes )
1551 idSkipZeroes(temp);
1552
1553#if 0
1554 PrintS("<id_KillSquares>\n");
1555 {
1556 PrintS("ideal temp: \n");
1557 for (int i = 0; i < IDELEMS(temp); i++)
1558 {
1559 Print("; temp[%d] = ", i+1);
1560 p_Write(temp->m[i], r);
1561 }
1562 PrintS(";\n");
1563 PrintLn();
1564 }
1565 PrintS("</id_KillSquares>\n");
1566#endif
1567
1568// temp->rank = idRankFreeModule(temp, r);
1569
1570 return temp;
1571}
#define Print
Definition emacs.cc:80
int j
Definition facHensel.cc:110
poly p_KillSquares(const poly p, const short iFirstAltVar, const short iLastAltVar, const ring r)
Definition sca.cc:1463
#define assume(x)
Definition mod2.h:389
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
ideal idInit(int idsize, int rank)
initialise an ideal / module
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ ivGetSCAXVarWeights()

intvec * ivGetSCAXVarWeights ( const ring r)

Definition at line 1381 of file sca.cc.

1382{
1383 const unsigned int N = r->N;
1384
1385 const int CommutativeVariable = 0; // bug correction!
1386 const int AntiCommutativeVariable = 0;
1387
1388 intvec* w = new intvec(N, 1, CommutativeVariable);
1389
1390 if(AntiCommutativeVariable != CommutativeVariable)
1391 if( rIsSCA(r) )
1392 {
1393 const unsigned int m_iFirstAltVar = scaFirstAltVar(r);
1394 const unsigned int m_iLastAltVar = scaLastAltVar(r);
1395
1396 for (unsigned int i = m_iFirstAltVar; i<= m_iLastAltVar; i++)
1397 {
1398 (*w)[i-1] = AntiCommutativeVariable;
1399 }
1400 }
1401
1402 return w;
1403}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
const CanonicalForm & w
Definition facAbsFact.cc:51
static bool rIsSCA(const ring r)
Definition nc.h:190
static short scaLastAltVar(ring r)
Definition sca.h:25
static short scaFirstAltVar(ring r)
Definition sca.h:18

◆ ivGetSCAYVarWeights()

intvec * ivGetSCAYVarWeights ( const ring r)

Definition at line 1409 of file sca.cc.

1410{
1411 const unsigned int N = r->N;
1412
1413 const int CommutativeVariable = 0;
1414 const int AntiCommutativeVariable = 1;
1415
1416 intvec* w = new intvec(N, 1, CommutativeVariable);
1417
1418 if(AntiCommutativeVariable != CommutativeVariable)
1419 if( rIsSCA(r) )
1420 {
1421 const unsigned int m_iFirstAltVar = scaFirstAltVar(r);
1422 const unsigned int m_iLastAltVar = scaLastAltVar(r);
1423
1424 for (unsigned int i = m_iFirstAltVar; i<= m_iLastAltVar; i++)
1425 {
1426 (*w)[i-1] = AntiCommutativeVariable;
1427 }
1428 }
1429 return w;
1430}

◆ 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 )
inlinestatic

Definition at line 1273 of file sca.cc.

1277{
1278 const unsigned int N = r->N;
1279
1280 p_Test(m, r);
1281
1282 assume( wx != NULL );
1283 assume( wy != NULL );
1284
1285 assume( wx->cols() == 1 );
1286 assume( wy->cols() == 1 );
1287
1288 assume( (unsigned int)wx->rows() >= N );
1289 assume( (unsigned int)wy->rows() >= N );
1290
1291 int x = 0;
1292 int y = 0;
1293
1294 for(int i = N; i > 0; i--)
1295 {
1296 const int d = p_GetExp(m, i, r);
1297 x += d * (*wx)[i-1];
1298 y += d * (*wy)[i-1];
1299 }
1300
1301 if( (wCx != NULL) && (wCy != NULL) )
1302 {
1303 const int c = p_GetComp(m, r);
1304
1305 if( wCx->range(c) )
1306 x += (*wCx)[c];
1307
1308 if( wCy->range(c) )
1309 x += (*wCy)[c];
1310 }
1311
1312 dx = x;
1313 dy = y;
1314}
int m
Definition cfEzgcd.cc:128
int range(int i) const
Definition intvec.h:60
int cols() const
Definition intvec.h:96
int rows() const
Definition intvec.h:97
#define p_GetComp(p, r)
Definition monomials.h:64
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
#define p_Test(p, r)
Definition p_polys.h:161

◆ m_KillSquares()

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

Definition at line 1437 of file sca.cc.

1440{
1441#ifdef PDEBUG
1442 p_Test(m, r);
1443 assume( (iFirstAltVar >= 1) && (iLastAltVar <= rVar(r)) && (iFirstAltVar <= iLastAltVar) );
1444
1445#if 0
1446 PrintS("m_KillSquares, m = "); // !
1447 p_Write(m, r);
1448#endif
1449#endif
1450
1451 assume( m != NULL );
1452
1453 for(short k = iFirstAltVar; k <= iLastAltVar; k++)
1454 if( p_GetExp(m, k, r) > 1 )
1455 return NULL;
1456
1457 return p_Head(m, r);
1458}
int k
Definition cfEzgcd.cc:99
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.

1323{
1324 if( p == NULL )
1325 {
1326 dx = 0;
1327 dy = 0;
1328 return true;
1329 }
1330
1331 poly q = p;
1332
1333
1334 int ddx, ddy;
1335
1336 m_GetBiDegree( q, wx, wy, wCx, wCy, ddx, ddy, r); // get bi degree of lm(p)
1337
1338 pIter(q);
1339
1340 for(; q != NULL; pIter(q) )
1341 {
1342 int x, y;
1343
1344 m_GetBiDegree( q, wx, wy, wCx, wCy, x, y, r); // get bi degree of q
1345
1346 if ( (x != ddx) || (y != ddy) ) return false;
1347 }
1348
1349 dx = ddx;
1350 dy = ddy;
1351
1352 return true;
1353}
int p
Definition cfModGcd.cc:4086
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
#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.

1466{
1467#ifdef PDEBUG
1468 p_Test(p, r);
1469
1470 assume( (iFirstAltVar >= 1) && (iLastAltVar <= r->N) && (iFirstAltVar <= iLastAltVar) );
1471
1472#if 0
1473 PrintS("p_KillSquares, p = "); // !
1474 p_Write(p, r);
1475#endif
1476#endif
1477
1478
1479 if( p == NULL )
1480 return NULL;
1481
1482 poly pResult = NULL;
1483 poly* ppPrev = &pResult;
1484
1485 for( poly q = p; q!= NULL; pIter(q) )
1486 {
1487#ifdef PDEBUG
1488 p_Test(q, r);
1489#endif
1490
1491 // terms will be in the same order because of quasi-ordering!
1492 poly v = m_KillSquares(q, iFirstAltVar, iLastAltVar, r);
1493
1494 if( v != NULL )
1495 {
1496 *ppPrev = v;
1497 ppPrev = &pNext(v);
1498 }
1499
1500 }
1501
1502#ifdef PDEBUG
1503 p_Test(pResult, r);
1504#if 0
1505 PrintS("p_KillSquares => "); // !
1506 p_Write(pResult, r);
1507#endif
1508#endif
1509
1510 return(pResult);
1511}
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
static poly m_KillSquares(const poly m, const short iFirstAltVar, const short iLastAltVar, const ring r)
Definition sca.cc:1437
#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.

1160{
1161 assume(rGR != NULL);
1162 assume(rIsPluralRing(rGR));
1163 assume(!rIsSCA(rGR));
1164
1165 const int N = rGR->N;
1166
1167// ring rSaveRing = currRing;
1168// if(rSaveRing != rGR)
1169// rChangeCurrRing(rGR);
1170
1171 const ideal idQuotient = rGR->qideal;
1172
1173 ideal tempQ = idQuotient;
1174
1175 if( b <= N && e >= 1 )
1176 tempQ = id_KillSquares(idQuotient, b, e, rGR);
1177
1178 idSkipZeroes( tempQ );
1179
1180 ncRingType( rGR, nc_exterior );
1181
1182 if( idIs0(tempQ) )
1183 rGR->GetNC()->SCAQuotient() = NULL;
1184 else
1185 rGR->GetNC()->SCAQuotient() = tempQ;
1186
1187
1188 scaFirstAltVar( rGR, b );
1189 scaLastAltVar( rGR, e );
1190
1191
1192 nc_p_ProcsSet(rGR, rGR->p_Procs);
1193
1194// if(rSaveRing != rGR)
1195// rChangeCurrRing(rSaveRing);
1196
1197 return true;
1198}
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
@ nc_exterior
Definition nc.h:21
static nc_type & ncRingType(nc_struct *p)
Definition nc.h:159
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
Definition sca.cc:1518
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406

◆ sca_m_Mult_mm()

static poly sca_m_Mult_mm ( poly pMonomM,
const poly pMonomMM,
const ring rRing )
inlinestatic

Definition at line 132 of file sca.cc.

133{
134#ifdef PDEBUG
135 p_Test(pMonomM, rRing);
136 p_Test(pMonomMM, rRing);
137#endif
138
139 const unsigned int iFirstAltVar = scaFirstAltVar(rRing);
140 const unsigned int iLastAltVar = scaLastAltVar(rRing);
141
142 REGISTER unsigned int tpower = 0;
143 REGISTER unsigned int cpower = 0;
144
145 for( REGISTER unsigned int j = iLastAltVar; j >= iFirstAltVar; j-- )
146 {
147 const unsigned int iExpM = p_GetExp(pMonomM, j, rRing);
148 const unsigned int iExpMM = p_GetExp(pMonomMM, j, rRing);
149
150#ifdef PDEBUG
151 assume( iExpM <= 1);
152 assume( iExpMM <= 1);
153#endif
154
155 if( iExpMM != 0 )
156 {
157 if( iExpM != 0 ) // result is zero!
158 {
159 return NULL; // we do nothing with pMonomM in this case!
160 }
161
162 tpower ^= cpower; // compute degree of (-1).
163 }
164
165 cpower ^= iExpM;
166 }
167
168#ifdef PDEBUG
169 assume(tpower <= 1);
170#endif
171
172 p_ExpVectorAdd(pMonomM, pMonomMM, rRing); // "exponents" are additive!!!
173
174 number nCoeffM = p_GetCoeff(pMonomM, rRing); // no new copy! should be deleted!
175
176 if( (tpower) != 0 ) // degree is odd => negate coeff.
177 nCoeffM = n_InpNeg(nCoeffM, rRing->cf); // negate nCoeff (will destroy the original number)
178
179 const number nCoeffMM = p_GetCoeff(pMonomMM, rRing); // no new copy!
180
181 number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing->cf); // new number!
182
183 p_SetCoeff(pMonomM, nCoeff, rRing); // delete lc(pMonomM) and set lc(pMonomM) = nCoeff
184
185#ifdef PDEBUG
186 p_LmTest(pMonomM, rRing);
187#endif
188
189 return(pMonomM);
190}
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:637
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:558
#define p_GetCoeff(p, r)
Definition monomials.h:50
#define REGISTER
Definition omalloc.h:27
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition p_polys.h:1427
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
#define p_LmTest(p, r)
Definition p_polys.h:162

◆ sca_mm_Mult_m()

static poly sca_mm_Mult_m ( const poly pMonomMM,
poly pMonomM,
const ring rRing )
inlinestatic

Definition at line 196 of file sca.cc.

197{
198#ifdef PDEBUG
199 p_Test(pMonomM, rRing);
200 p_Test(pMonomMM, rRing);
201#endif
202
203 const unsigned int iFirstAltVar = scaFirstAltVar(rRing);
204 const unsigned int iLastAltVar = scaLastAltVar(rRing);
205
206 REGISTER unsigned int tpower = 0;
207 REGISTER unsigned int cpower = 0;
208
209 for( REGISTER unsigned int j = iLastAltVar; j >= iFirstAltVar; j-- )
210 {
211 const unsigned int iExpMM = p_GetExp(pMonomMM, j, rRing);
212 const unsigned int iExpM = p_GetExp(pMonomM, j, rRing);
213
214#ifdef PDEBUG
215 assume( iExpM <= 1);
216 assume( iExpMM <= 1);
217#endif
218
219 if( iExpM != 0 )
220 {
221 if( iExpMM != 0 ) // result is zero!
222 {
223 return NULL; // we do nothing with pMonomM in this case!
224 }
225
226 tpower ^= cpower; // compute degree of (-1).
227 }
228
229 cpower ^= iExpMM;
230 }
231
232#ifdef PDEBUG
233 assume(tpower <= 1);
234#endif
235
236 p_ExpVectorAdd(pMonomM, pMonomMM, rRing); // "exponents" are additive!!!
237
238 number nCoeffM = p_GetCoeff(pMonomM, rRing); // no new copy! should be deleted!
239
240 if( (tpower) != 0 ) // degree is odd => negate coeff.
241 nCoeffM = n_InpNeg(nCoeffM, rRing->cf); // negate nCoeff (will destroy the original number), creates new number!
242
243 const number nCoeffMM = p_GetCoeff(pMonomMM, rRing); // no new copy!
244
245 number nCoeff = n_Mult(nCoeffM, nCoeffMM, rRing->cf); // new number!
246
247 p_SetCoeff(pMonomM, nCoeff, rRing); // delete lc(pMonomM) and set lc(pMonomM) = nCoeff
248
249#ifdef PDEBUG
250 p_LmTest(pMonomM, rRing);
251#endif
252
253 return(pMonomM);
254}

◆ sca_mm_Mult_mm()

static poly sca_mm_Mult_mm ( poly pMonom1,
const poly pMonom2,
const ring rRing )
inlinestatic

Definition at line 261 of file sca.cc.

262{
263#ifdef PDEBUG
264 p_Test(pMonom1, rRing);
265 p_Test(pMonom2, rRing);
266#endif
267
268 const unsigned int iFirstAltVar = scaFirstAltVar(rRing);
269 const unsigned int iLastAltVar = scaLastAltVar(rRing);
270
271 REGISTER unsigned int tpower = 0;
272 REGISTER unsigned int cpower = 0;
273
274 for( REGISTER unsigned int j = iLastAltVar; j >= iFirstAltVar; j-- )
275 {
276 const unsigned int iExp1 = p_GetExp(pMonom1, j, rRing);
277 const unsigned int iExp2 = p_GetExp(pMonom2, j, rRing);
278
279#ifdef PDEBUG
280 assume( iExp1 <= 1);
281 assume( iExp2 <= 1);
282#endif
283
284 if( iExp2 != 0 )
285 {
286 if( iExp1 != 0 ) // result is zero!
287 {
288 return NULL;
289 }
290 tpower ^= cpower; // compute degree of (-1).
291 }
292 cpower ^= iExp1;
293 }
294
295#ifdef PDEBUG
296 assume(cpower <= 1);
297#endif
298
299 poly pResult;
300 p_AllocBin(pResult,rRing->PolyBin,rRing);
301
302 p_ExpVectorSum(pResult, pMonom1, pMonom2, rRing); // "exponents" are additive!!!
303
304 pNext(pResult) = NULL;
305
306 const number nCoeff1 = p_GetCoeff(pMonom1, rRing); // no new copy!
307 const number nCoeff2 = p_GetCoeff(pMonom2, rRing); // no new copy!
308
309 number nCoeff = n_Mult(nCoeff1, nCoeff2, rRing->cf); // new number!
310
311 if( (tpower) != 0 ) // degree is odd => negate coeff.
312 nCoeff = n_InpNeg(nCoeff, rRing->cf); // negate nCoeff (will destroy the original number)
313
314 p_SetCoeff0(pResult, nCoeff, rRing); // set lc(pResult) = nCoeff, no destruction!
315
316#ifdef PDEBUG
317 p_LmTest(pResult, rRing);
318#endif
319
320 return(pResult);
321}
#define p_SetCoeff0(p, n, r)
Definition monomials.h:60
#define p_AllocBin(p, bin, r)
Definition monomials.h:210
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1441

◆ sca_p_mm_Mult()

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

Definition at line 635 of file sca.cc.

636{
637 assume( rIsSCA(rRing) );
638
639#ifdef PDEBUG
640 p_Test(pPoly, rRing);
641 p_Test(pMonom, rRing);
642#endif
643
644 if( pPoly == NULL )
645 return NULL;
646
647 assume(pMonom!=NULL);
648 //if( pMonom == NULL )
649 //{
650 // // pPoly != NULL =>
651 // p_Delete( &pPoly, rRing );
652 // return NULL;
653 //}
654
655 const int iComponentMonomM = p_GetComp(pMonom, rRing);
656
657 poly p = pPoly; poly* ppPrev = &pPoly;
658
659 loop
660 {
661#ifdef PDEBUG
662 if( !p_Test(p, rRing) )
663 {
664 PrintS("p is wrong!");
665 p_Write(p,rRing);
666 }
667#endif
668
669 const int iComponent = p_GetComp(p, rRing);
670
671 if( iComponentMonomM!=0 )
672 {
673 if( iComponent!=0 )
674 {
675 // REPORT_ERROR
676 Werror("sca_p_mm_Mult: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
677 // what should we do further?!?
678
679 p_Delete( &pPoly, rRing); // delete the result
680 return NULL;
681 }
682#ifdef PDEBUG
683 if(iComponent==0)
684 {
685 dReportError("sca_p_mm_Mult: Multiplication in the left module from the right!");
686// PrintS("mm = "); p_Write(pMonom, rRing);
687// PrintS("p = "); p_Write(pPoly, rRing);
688// assume(iComponent!=0);
689 }
690#endif
691 }
692
693 // terms will be in the same order because of quasi-ordering!
694 poly v = sca_mm_Mult_m(pMonom, p, rRing);
695
696 if( v != NULL )
697 {
698 ppPrev = &pNext(p);
699
700 // *p is changed if v != NULL ( p == v )
701 pIter(p);
702
703 if( p == NULL )
704 break;
705 }
706 else
707 { // Upps! Zero!!! we must kill this term!
708 p = p_LmDeleteAndNext(p, rRing);
709
710 *ppPrev = p;
711
712 if( p == NULL )
713 break;
714 }
715 }
716
717#ifdef PDEBUG
718 if( !p_Test(pPoly, rRing) )
719 {
720 PrintS("pPoly is wrong!");
721 p_Write(pPoly, rRing);
722 }
723#endif
724
725 return(pPoly);
726}
static poly sca_mm_Mult_m(const poly pMonomMM, poly pMonomM, const ring rRing)
Definition sca.cc:196
int dReportError(const char *fmt,...)
Definition dError.cc:44
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
void Werror(const char *fmt,...)
Definition reporter.cc:189
#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.

372{
373 assume( rIsSCA(rRing) );
374
375#ifdef PDEBUG
376// PrintS("sca_p_Mult_mm\n"); // !
377
378 p_Test(pPoly, rRing);
379 p_Test(pMonom, rRing);
380#endif
381
382 if( pPoly == NULL )
383 return NULL;
384
385 assume(pMonom !=NULL);
386 //if( pMonom == NULL )
387 //{
388 // // pPoly != NULL =>
389 // p_Delete( &pPoly, rRing );
390 // return NULL;
391 //}
392
393 const int iComponentMonomM = p_GetComp(pMonom, rRing);
394
395 poly p = pPoly; poly* ppPrev = &pPoly;
396
397 loop
398 {
399#ifdef PDEBUG
400 p_Test(p, rRing);
401#endif
402 const int iComponent = p_GetComp(p, rRing);
403
404 if( iComponent!=0 )
405 {
406 if( iComponentMonomM!=0 ) // TODO: make global if on iComponentMonomM =?= 0
407 {
408 // REPORT_ERROR
409 Werror("sca_p_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
410 // what should we do further?!?
411
412 p_Delete( &pPoly, rRing); // delete the result AND rest
413 return NULL;
414 }
415#ifdef PDEBUG
416 if(iComponentMonomM==0 )
417 {
418 dReportError("sca_p_Mult_mm: Multiplication in the left module from the right");
419 }
420#endif
421 }
422
423 // terms will be in the same order because of quasi-ordering!
424 poly v = sca_m_Mult_mm(p, pMonom, rRing);
425
426 if( v != NULL )
427 {
428 ppPrev = &pNext(p); // fixed!
429
430 // *p is changed if v != NULL ( p == v )
431 pIter(p);
432
433 if( p == NULL )
434 break;
435 }
436 else
437 { // Upps! Zero!!! we must kill this term!
438
439 //
440 p = p_LmDeleteAndNext(p, rRing);
441
442 *ppPrev = p;
443
444 if( p == NULL )
445 break;
446 }
447 }
448
449#ifdef PDEBUG
450 p_Test(pPoly,rRing);
451#endif
452
453 return(pPoly);
454}
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.

1224{
1225
1226 // "commutative" procedures:
1227 rGR->p_Procs->p_Mult_mm = sca_p_Mult_mm;
1228 rGR->p_Procs->pp_Mult_mm = sca_pp_Mult_mm;
1229
1230 p_Procs->p_Mult_mm = sca_p_Mult_mm;
1231 p_Procs->pp_Mult_mm = sca_pp_Mult_mm;
1232
1233 // non-commutaitve
1234 p_Procs->p_mm_Mult = sca_p_mm_Mult;
1235 p_Procs->pp_mm_Mult = sca_pp_mm_Mult;
1236
1237// rGR->GetNC()->p_Procs.SPoly = sca_SPoly;
1238// rGR->GetNC()->p_Procs.ReduceSPoly = sca_ReduceSpoly;
1239
1240#if 0
1241
1242 // Multiplication procedures:
1243
1244 p_Procs->p_Mult_mm = sca_p_Mult_mm;
1245 _p_procs->p_Mult_mm = sca_p_Mult_mm;
1246
1247 p_Procs->pp_Mult_mm = sca_pp_Mult_mm;
1248 _p_procs->pp_Mult_mm = sca_pp_Mult_mm;
1249
1250 r->GetNC()->mmMultP() = sca_mm_Mult_p;
1251 r->GetNC()->mmMultPP() = sca_mm_Mult_pp;
1252
1253/*
1254 // ??????????????????????????????????????? coefficients swell...
1255 r->GetNC()->SPoly() = sca_SPoly;
1256 r->GetNC()->ReduceSPoly() = sca_ReduceSpoly;
1257*/
1258// r->GetNC()->BucketPolyRed() = gnc_kBucketPolyRed;
1259// r->GetNC()->BucketPolyRed_Z()= gnc_kBucketPolyRed_Z;
1260#endif
1261
1262 // local ordering => Mora, otherwise - Buchberger!
1263 if (rHasLocalOrMixedOrdering(rGR))
1264 rGR->GetNC()->p_Procs.GB = cast_A_to_vptr(sca_mora);
1265 else
1266 rGR->GetNC()->p_Procs.GB = cast_A_to_vptr(sca_bba); // sca_gr_bba?
1267}
void * cast_A_to_vptr(A a)
Definition auxiliary.h:386
EXTERN_VAR BBA_Proc sca_mora
Definition gb_hack.h:10
EXTERN_VAR BBA_Proc sca_bba
Definition gb_hack.h:10
static poly sca_p_mm_Mult(poly pPoly, const poly pMonom, const ring rRing)
Definition sca.cc:635
poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &)
poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing)
Definition sca.cc:371
static poly sca_pp_mm_Mult(const poly pPoly, const poly pMonom, const ring rRing)
Definition sca.cc:567
STATIC_VAR p_Procs_s * _p_procs
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769

◆ sca_pp_mm_Mult()

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

Definition at line 567 of file sca.cc.

568{
569 assume( rIsSCA(rRing) );
570
571#ifdef PDEBUG
572// PrintS("sca_mm_Mult_pp\n"); // !
573
574 p_Test(pPoly, rRing);
575 p_Test(pMonom, rRing);
576#endif
577
578 if ((pPoly==NULL) || (pMonom==NULL)) return NULL;
579
580 assume( (pPoly != NULL) && (pMonom !=NULL));
581
582 const int iComponentMonomM = p_GetComp(pMonom, rRing);
583
584 poly pResult = NULL;
585 poly* ppPrev = &pResult;
586
587 for( poly p = pPoly; p!= NULL; pIter(p) )
588 {
589#ifdef PDEBUG
590 p_Test(p, rRing);
591#endif
592 const int iComponent = p_GetComp(p, rRing);
593
594 if( iComponentMonomM!=0 )
595 {
596 if( iComponent!=0 ) // TODO: make global if on iComponentMonomM =?= 0
597 {
598 // REPORT_ERROR
599 Werror("sca_pp_mm_Mult: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
600 // what should we do further?!?
601
602 p_Delete( &pResult, rRing); // delete the result
603 return NULL;
604 }
605#ifdef PDEBUG
606 if(iComponent==0 )
607 {
608 dReportError("sca_pp_mm_Mult: Multiplication in the left module from the right!");
609// PrintS("mm = "); p_Write(pMonom, rRing);
610// PrintS("pp = "); p_Write(pPoly, rRing);
611// assume(iComponent!=0);
612 }
613#endif
614 }
615
616 // terms will be in the same order because of quasi-ordering!
617 poly v = sca_mm_Mult_mm(pMonom, p, rRing);
618
619 if( v != NULL )
620 {
621 *ppPrev = v;
622 ppPrev = &pNext(*ppPrev); // nice line ;-)
623 }
624 }
625
626#ifdef PDEBUG
627 p_Test(pResult,rRing);
628#endif
629
630 return(pResult);
631}
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.

458{
459 assume( rIsSCA(rRing) );
460
461#ifdef PDEBUG
462// PrintS("sca_pp_Mult_mm\n"); // !
463
464 p_Test(pPoly, rRing);
465 p_Test(pMonom, rRing);
466#endif
467
468 if (/*(*/ pPoly == NULL /*)*/) /*|| ( pMonom == NULL )*/
469 return NULL;
470
471 const int iComponentMonomM = p_GetComp(pMonom, rRing);
472
473 poly pResult = NULL;
474 poly* ppPrev = &pResult;
475
476 for( poly p = pPoly; p!= NULL; pIter(p) )
477 {
478#ifdef PDEBUG
479 p_Test(p, rRing);
480#endif
481 const int iComponent = p_GetComp(p, rRing);
482
483 if( iComponent!=0 )
484 {
485 if( iComponentMonomM!=0 ) // TODO: make global if on iComponentMonomM =?= 0
486 {
487 // REPORT_ERROR
488 Werror("sca_pp_Mult_mm: exponent mismatch %d and %d\n", iComponent, iComponentMonomM);
489 // what should we do further?!?
490
491 p_Delete( &pResult, rRing); // delete the result
492 return NULL;
493 }
494
495#ifdef PDEBUG
496 if(iComponentMonomM==0 )
497 {
498 dReportError("sca_pp_Mult_mm: Multiplication in the left module from the right");
499 }
500#endif
501 }
502
503 // terms will be in the same order because of quasi-ordering!
504 poly v = sca_mm_Mult_mm(p, pMonom, rRing);
505
506 if( v != NULL )
507 {
508 *ppPrev = v;
509 ppPrev = &pNext(v);
510 }
511 }
512
513#ifdef PDEBUG
514 p_Test(pResult,rRing);
515#endif
516
517 return(pResult);
518}

◆ 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.

1202{
1203 assume(1 <= i);
1204 assume(i <= rVar(rRing));
1205
1206 if(rIsSCA(rRing))
1207 return sca_xi_Mult_pp(i, pPoly, rRing);
1208
1209
1210
1211 poly xi = p_One( rRing);
1212 p_SetExp(xi, i, 1, rRing);
1213 p_Setm(xi, rRing);
1214
1215 poly pResult = pp_Mult_qq(xi, pPoly, rRing);
1216
1217 p_Delete( &xi, rRing);
1218
1219 return pResult;
1220
1221}
static poly sca_xi_Mult_pp(short i, const poly pPoly, const ring rRing)
Definition sca.cc:523
poly p_One(const ring r)
Definition p_polys.cc:1314
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
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1162

◆ sca_ReduceSpoly()

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

Definition at line 831 of file sca.cc.

832{
833 assume( rIsSCA(r) );
834
835 assume( p1 != NULL );
836
837 const long lCompP1 = p_GetComp (p1, r);
838 const long lCompP2 = p_GetComp (p2, r);
839
840 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
841 {
842#ifdef PDEBUG
843 dReportError("sca_ReduceSpoly: different non-zero components!");
844#endif
845 return(NULL);
846 }
847
848 poly m = p_ISet (1, r);
849 p_ExpVectorDiff (m, p2, p1, r); // m = lm(p2) / lm(p1)
850 //p_Setm(m,r);
851#ifdef PDEBUG
852 p_Test (m,r);
853#endif
854
855 number C1 = n_Copy( pGetCoeff(p1), r->cf);
856 number C2 = n_Copy( pGetCoeff(p2), r->cf);
857
858 /* GCD stuff */
859 number C = n_Gcd(C1, C2, r->cf);
860
861 if (!n_IsOne(C, r->cf))
862 {
863 C1 = n_Div(C1, C, r->cf);
864 C2 = n_Div(C2, C, r->cf);
865 }
866 n_Delete(&C,r->cf);
867
868 const int iSign = sca_Sign_mm_Mult_mm( m, p1, r );
869
870 if(iSign == 1)
871 C2 = n_InpNeg(C2,r->cf);
872
873 p_SetCoeff(m, C2, r);
874
875#ifdef PDEBUG
876 p_Test(m,r);
877#endif
878
879 p2 = p_LmDeleteAndNext( p2, r );
880
881 p2 = p_Mult_nn(p2, C1, r); // p2 !!!
882 n_Delete(&C1,r->cf);
883
884 poly T = nc_mm_Mult_pp(m, pNext(p1), r);
885 p_Delete(&m, r);
886
887 p2 = p_Add_q(p2, T, r);
888
889 if ( p2!=NULL ) p_Cleardenom(p2,r);
890
891#ifdef PDEBUG
892 p_Test(p2,r);
893#endif
894
895 return(p2);
896}
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455
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:665
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:616
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:472
STATIC_VAR jList * T
Definition janet.cc:30
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition nc.h:224
static int sca_Sign_mm_Mult_mm(const poly pMonomM, const poly pMonomMM, const ring rRing)
Definition sca.cc:81
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
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1490
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.

912{
913
914 //////////////////////////////////////////////////////////////////////////
915 // checks...
916 //////////////////////////////////////////////////////////////////////////
917 if( rG == NULL )
918 rG = rGR;
919
920 assume(rGR != NULL);
921 assume(rG != NULL);
923
924#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
925 PrintS("sca_SetupQuotient(rGR, rG, bCopy)");
926
927 {
928 PrintS("\nrG: \n"); rWrite(rG);
929 PrintS("\nrGR: \n"); rWrite(rGR);
930 PrintLn();
931 }
932#endif
933
934
935 if(bCopy)
936 {
937 if(rIsSCA(rG) && (rG != rGR))
938 return sca_Force(rGR, scaFirstAltVar(rG), scaLastAltVar(rG));
939 else
940 return false;
941 }
942
943 assume(!bCopy);
944
945 const int N = rG->N;
946
947// if( (ncRingType(rG) != nc_skew) || (ncRingType(rG) != nc_comm) )
948// return false;
949
950#if OUTPUT
951 PrintS("sca_SetupQuotient: qring?\n");
952#endif
953
954 if(rGR->qideal == NULL) // there should be a factor!
955 return false;
956
957#if OUTPUT
958 PrintS("sca_SetupQuotient: qideal!!!\n");
959#endif
960
961// if((rG->qideal != NULL) && (rG != rGR) ) // we cannot change from factor to factor at the time, sorry!
962// return false;
963
964
965 int iAltVarEnd = -1;
966 int iAltVarStart = N+1;
967
968 const nc_struct* NC = rG->GetNC();
969 const ring rBase = rG; //NC->basering;
970 const matrix C = NC->C; // live in rBase!
971 const matrix D = NC->D; // live in rBase!
972
973#if OUTPUT
974 PrintS("sca_SetupQuotient: AltVars?!\n");
975#endif
976
977 for(int i = 1; i < N; i++)
978 {
979 for(int j = i + 1; j <= N; j++)
980 {
981 if( MATELEM(D,i,j) != NULL) // !!!???
982 {
983#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
984 Print("Nonzero D[%d, %d]\n", i, j);
985#endif
986 return false;
987 }
988
989
990 assume(MATELEM(C,i,j) != NULL); // after CallPlural!
991 number c = p_GetCoeff(MATELEM(C,i,j), rBase);
992
993 if( n_IsMOne(c, rBase->cf) ) // !!!???
994 {
995 if( i < iAltVarStart)
996 iAltVarStart = i;
997
998 if( j > iAltVarEnd)
999 iAltVarEnd = j;
1000 } else
1001 {
1002 if( !n_IsOne(c, rBase->cf) )
1003 {
1004#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1005 Print("Wrong Coeff at: [%d, %d]\n", i, j);
1006#endif
1007 return false;
1008 }
1009 }
1010 }
1011 }
1012
1013#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1014 Print("AltVars?1: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1015#endif
1016
1017
1018 if((iAltVarEnd == -1) || (iAltVarStart == (N+1)))
1019 {
1020 if (N>1) return false; // no alternating variables
1021 iAltVarEnd=iAltVarStart=1;
1022 }
1023
1024 for(int i = 1; i < N; i++)
1025 {
1026 for(int j = i + 1; j <= N; j++)
1027 {
1028 assume(MATELEM(C,i,j) != NULL); // after CallPlural!
1029 number c = p_GetCoeff(MATELEM(C,i,j), rBase);
1030
1031 if( (iAltVarStart <= i) && (j <= iAltVarEnd) ) // S <= i < j <= E
1032 { // anticommutative part
1033 if( !n_IsMOne(c, rBase->cf) )
1034 {
1035#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1036 Print("Wrong Coeff at: [%d, %d]\n", i, j);
1037#endif
1038 return false;
1039 }
1040 }
1041 else
1042 { // should commute
1043 if( !n_IsOne(c, rBase->cf) )
1044 {
1045#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1046 Print("Wrong Coeff at: [%d, %d]\n", i, j);
1047#endif
1048 return false;
1049 }
1050 }
1051 }
1052 }
1053
1054#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1055 Print("AltVars!?: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1056#endif
1057
1058 assume( 1 <= iAltVarStart );
1059 assume( iAltVarStart <= iAltVarEnd );
1060 assume( iAltVarEnd <= N );
1061
1062
1063// ring rSaveRing = assureCurrentRing(rG);
1064
1065
1066 assume(rGR->qideal != NULL);
1067 assume(rGR->N == rG->N);
1068// assume(rG->qideal == NULL); // ?
1069
1070 const ideal idQuotient = rGR->qideal;
1071
1072
1073#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1074 PrintS("Analyzing quotient ideal:\n");
1075 idPrint(idQuotient); // in rG!!!
1076#endif
1077
1078
1079 // check for
1080 // y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart)
1081 // to be within quotient ideal.
1082
1083 int b = N+1;
1084 int e = -1;
1085
1086 if(rIsSCA(rG))
1087 {
1088 b = si_min(b, scaFirstAltVar(rG));
1089 e = si_max(e, scaLastAltVar(rG));
1090
1091#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1092 Print("AltVars!?: [%d, %d]\n", b, e);
1093#endif
1094 }
1095
1096 for ( int i = iAltVarStart; (i <= iAltVarEnd); i++ )
1097 if( (i < b) || (i > e) ) // otherwise it's ok since rG is an SCA!
1098 {
1099 poly square = p_One( rG);
1100 p_SetExp(square, i, 2, rG); // square = var(i)^2.
1101 p_Setm(square, rG);
1102
1103 // square = NF( var(i)^2 | Q )
1104 // NOTE: there is no better way to check this in general!
1105 square = nc_NF(idQuotient, NULL, square, 0, 1, rG); // must ran in currRing == rG!
1106
1107 if( square != NULL ) // var(i)^2 is not in Q?
1108 {
1109 p_Delete(&square, rG);
1110 return false;
1111 }
1112 }
1113
1114#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1115 Print("ScaVars!: [%d, %d]\n", iAltVarStart, iAltVarEnd);
1116#endif
1117
1118
1119 //////////////////////////////////////////////////////////////////////////
1120 // ok... here we go. let's setup it!!!
1121 //////////////////////////////////////////////////////////////////////////
1122 ideal tempQ = id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG); // in rG!!!
1123
1124
1125#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1126 PrintS("Quotient: \n");
1127 iiWriteMatrix((matrix)idQuotient,"__",1, rG, 0);
1128 PrintS("tempSCAQuotient: \n");
1129 iiWriteMatrix((matrix)tempQ,"__",1, rG, 0);
1130#endif
1131
1132 idSkipZeroes( tempQ );
1133
1134 ncRingType( rGR, nc_exterior );
1135
1136 scaFirstAltVar( rGR, iAltVarStart );
1137 scaLastAltVar( rGR, iAltVarEnd );
1138
1139 if( idIs0(tempQ) )
1140 rGR->GetNC()->SCAQuotient() = NULL;
1141 else
1142 rGR->GetNC()->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ!
1143
1144 nc_p_ProcsSet(rGR, rGR->p_Procs); // !!!!!!!!!!!!!!!!!
1145
1146
1147#if ((defined(PDEBUG) && OUTPUT) || MYTEST)
1148 PrintS("SCAQuotient: \n");
1149 if(tempQ != NULL)
1150 iiWriteMatrix((matrix)tempQ,"__",1, rGR, 0);
1151 else
1152 PrintS("(NULL)\n");
1153#endif
1154
1155 return true;
1156}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
static int si_min(const int a, const int b)
Definition auxiliary.h:126
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:476
EXTERN_VAR NF_Proc nc_NF
Definition gb_hack.h:9
#define D(A)
Definition gentable.cc:128
#define idPrint(id)
Definition ideals.h:46
bool sca_Force(ring rGR, int b, int e)
Definition sca.cc:1159
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition matpol.cc:828
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
Definition nc.h:68
matrix C
Definition nc.h:75
matrix D
Definition nc.h:76

◆ sca_Sign_mm_Mult_mm()

static int sca_Sign_mm_Mult_mm ( const poly pMonomM,
const poly pMonomMM,
const ring rRing )
inlinestatic

Definition at line 81 of file sca.cc.

82{
83#ifdef PDEBUG
84 p_Test(pMonomM, rRing);
85 p_Test(pMonomMM, rRing);
86#endif
87
88 const short iFirstAltVar = scaFirstAltVar(rRing);
89 const short iLastAltVar = scaLastAltVar(rRing);
90
91 REGISTER unsigned int tpower = 0;
92 REGISTER unsigned int cpower = 0;
93
94 for( REGISTER short j = iLastAltVar; j >= iFirstAltVar; j-- )
95 {
96 const unsigned int iExpM = p_GetExp(pMonomM, j, rRing);
97 const unsigned int iExpMM = p_GetExp(pMonomMM, j, rRing);
98
99#ifdef PDEBUG
100 assume( iExpM <= 1);
101 assume( iExpMM <= 1);
102#endif
103
104 if( iExpMM != 0 ) // TODO: think about eliminating there if-s...
105 {
106 if( iExpM != 0 )
107 {
108 return 0; // lm(pMonomM) * lm(pMonomMM) == 0
109 }
110 tpower ^= cpower; // compute degree of (-1).
111 }
112 cpower ^= iExpM;
113 }
114
115#ifdef PDEBUG
116 assume(tpower <= 1);
117#endif
118
119 // 1 => -1 // degree is odd => negate coeff.
120 // 0 => 1
121
122 return(1 - (tpower << 1) );
123}

◆ sca_SPoly()

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

Definition at line 744 of file sca.cc.

745{
746 assume( rIsSCA(r) );
747
748 const long lCompP1 = p_GetComp(p1,r);
749 const long lCompP2 = p_GetComp(p2,r);
750
751 if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
752 {
753#ifdef PDEBUG
754 dReportError("sca_SPoly: different non-zero components!\n");
755#endif
756 return(NULL);
757 }
758
759 poly pL = p_Lcm(p1, p2, r); // pL = lcm( lm(p1), lm(p2) )
760
761 poly m1 = p_One( r);
762 p_ExpVectorDiff(m1, pL, p1, r); // m1 = pL / lm(p1)
763
764 //p_SetComp(m1,0,r);
765 //p_Setm(m1,r);
766#ifdef PDEBUG
767 p_Test(m1,r);
768#endif
769
770
771 poly m2 = p_One( r);
772 p_ExpVectorDiff (m2, pL, p2, r); // m2 = pL / lm(p2)
773
774 //p_SetComp(m2,0,r);
775 //p_Setm(m2,r);
776#ifdef PDEBUG
777 p_Test(m2,r);
778#endif
779
780 p_Delete(&pL,r);
781
782 number C1 = n_Copy(pGetCoeff(p1),r->cf); // C1 = lc(p1)
783 number C2 = n_Copy(pGetCoeff(p2),r->cf); // C2 = lc(p2)
784
785 number C = n_Gcd(C1,C2,r->cf); // C = gcd(C1, C2)
786
787 if (!n_IsOne(C, r->cf)) // if C != 1
788 {
789 C1=n_Div(C1, C, r->cf); // C1 = C1 / C
790 C2=n_Div(C2, C, r->cf); // C2 = C2 / C
791 }
792
793 n_Delete(&C,r->cf); // destroy the number C
794
795 const int iSignSum = sca_Sign_mm_Mult_mm (m1, p1, r) + sca_Sign_mm_Mult_mm (m2, p2, r);
796 // zero if different signs
797
798 assume( (iSignSum*iSignSum == 0) || (iSignSum*iSignSum == 4) );
799
800 if( iSignSum != 0 ) // the same sign!
801 C2=n_InpNeg (C2, r->cf);
802
803 p_SetCoeff(m1, C2, r); // lc(m1) = C2!!!
804 p_SetCoeff(m2, C1, r); // lc(m2) = C1!!!
805
806 poly tmp1 = nc_mm_Mult_pp (m1, pNext(p1), r); // tmp1 = m1 * tail(p1),
807 p_Delete(&m1,r); // => n_Delete(&C1,r);
808
809 poly tmp2 = nc_mm_Mult_pp (m2, pNext(p2), r); // tmp1 = m2 * tail(p2),
810 p_Delete(&m2,r); // => n_Delete(&C1,r);
811
812 poly spoly = p_Add_q (tmp1, tmp2, r); // spoly = spoly(lt(p1), lt(p2)) + m1 * tail(p1), delete tmp1,2
813
814 if (spoly!=NULL) p_Cleardenom (spoly, r);
815
816#ifdef PDEBUG
817 p_Test (spoly, r);
818#endif
819
820 return(spoly);
821}
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659

◆ sca_xi_Mult_mm()

static poly sca_xi_Mult_mm ( short i,
const poly pMonom,
const ring rRing )
inlinestatic

Definition at line 326 of file sca.cc.

327{
328#ifdef PDEBUG
329 p_Test(pMonom, rRing);
330#endif
331
332 assume( i <= scaLastAltVar(rRing));
333 assume( scaFirstAltVar(rRing) <= i );
334
335 if( p_GetExp(pMonom, i, rRing) != 0 ) // => result is zero!
336 return NULL;
337
338 const short iFirstAltVar = scaFirstAltVar(rRing);
339
340 REGISTER unsigned int cpower = 0;
341
342 for( REGISTER short j = iFirstAltVar; j < i ; j++ )
343 cpower ^= p_GetExp(pMonom, j, rRing);
344
345#ifdef PDEBUG
346 assume(cpower <= 1);
347#endif
348
349 poly pResult = p_LmInit(pMonom, rRing);
350
351 p_SetExp(pResult, i, 1, rRing); // pResult*=X_i &&
352 p_Setm(pResult, rRing); // adjust degree after previous step!
353
354 number nCoeff = n_Copy(pGetCoeff(pMonom), rRing->cf); // new number!
355
356 if( cpower != 0 ) // degree is odd => negate coeff.
357 nCoeff = n_InpNeg(nCoeff, rRing->cf); // negate nCoeff (will destroy the original number)
358
359 p_SetCoeff0(pResult, nCoeff, rRing); // set lc(pResult) = nCoeff, no destruction!
360
361#ifdef PDEBUG
362 p_LmTest(pResult, rRing);
363#endif
364
365 return(pResult);
366}
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1351

◆ sca_xi_Mult_pp()

static poly sca_xi_Mult_pp ( short i,
const poly pPoly,
const ring rRing )
inlinestatic

Definition at line 523 of file sca.cc.

524{
525 assume( rIsSCA(rRing) );
526
527#ifdef PDEBUG
528 p_Test(pPoly, rRing);
529#endif
530
531 assume(i <= scaLastAltVar(rRing));
532 assume(scaFirstAltVar(rRing) <= i);
533
534 if( pPoly == NULL )
535 return NULL;
536
537 poly pResult = NULL;
538 poly* ppPrev = &pResult;
539
540 for( poly p = pPoly; p!= NULL; pIter(p) )
541 {
542
543 // terms will be in the same order because of quasi-ordering!
544 poly v = sca_xi_Mult_mm(i, p, rRing);
545
546#ifdef PDEBUG
547 p_Test(v, rRing);
548#endif
549
550 if( v != NULL )
551 {
552 *ppPrev = v;
553 ppPrev = &pNext(*ppPrev);
554 }
555 }
556
557
558#ifdef PDEBUG
559 p_Test(pResult, rRing);
560#endif
561
562 return(pResult);
563}
static poly sca_xi_Mult_mm(short i, const poly pMonom, const ring rRing)
Definition sca.cc:326