My Project
Loading...
Searching...
No Matches
tgb.cc File Reference
#include "kernel/mod2.h"
#include "kernel/GBEngine/tgb.h"
#include "kernel/GBEngine/tgb_internal.h"
#include "kernel/GBEngine/tgbgauss.h"
#include "misc/options.h"
#include "kernel/digitech.h"
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#include "polys/prCopy.h"
#include "coeffs/longrat.h"
#include <stdlib.h>
#include <stdio.h>
#include <queue>

Go to the source code of this file.

Data Structures

class  poly_tree_node
 
class  exp_number_builder
 

Macros

#define BUCKETS_FOR_NORO_RED   1
 @TODO: delay nur auf Sugarvergroesserung @TODO: grade aus ecartS, setze dazu strat->honey; und nutze p.ecart @TODO: no tail reductions in syz comp
 
#define SR_HDL(A)
 
#define ADD_LATER_SIZE   500
 
#define LEN_VAR3
 
#define degbound(p)
 
#define ENLARGE(pointer, type)
 
#define ENLARGE_ALIGN(pointer, type)
 

Functions

static void add_to_reductors (slimgb_alg *c, poly h, int len, int ecart, BOOLEAN simplified=FALSE)
 
static void multi_reduction (red_object *los, int &losl, slimgb_alg *c)
 
static void multi_reduce_step (find_erg &erg, red_object *r, slimgb_alg *c)
 
static BOOLEAN extended_product_criterion (poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg *c)
 
static poly gcd_of_terms (poly p, ring r)
 
static int tgb_pair_better_gen (const void *ap, const void *bp)
 
static BOOLEAN pair_better (sorted_pair_node *a, sorted_pair_node *b, slimgb_alg *c=NULL)
 
static BOOLEAN state_is (calc_state state, const int &i, const int &j, slimgb_alg *c)
 
static void super_clean_top_of_pair_list (slimgb_alg *c)
 
static int simple_posInS (kStrategy strat, poly p, int len, wlen_type wlen)
 
static int * make_connections (int from, int to, poly bound, slimgb_alg *c)
 
static BOOLEAN has_t_rep (const int &arg_i, const int &arg_j, slimgb_alg *state)
 
static void shorten_tails (slimgb_alg *c, poly monom)
 
static poly redNF2 (poly h, slimgb_alg *c, int &len, number &m, int n=0)
 
static poly redNFTail (poly h, const int sl, kStrategy strat, int len)
 
static int bucket_guess (kBucket *bucket)
 
static void simplify_poly (poly p, ring r)
 
int slim_nsize (number n, ring r)
 
static BOOLEAN monomial_root (poly m, ring r)
 
static BOOLEAN polynomial_root (poly h, ring r)
 
static poly p_Init_Special (const ring r)
 
static poly pOne_Special (const ring r=currRing)
 
static wlen_type pSLength (poly p, int l)
 
wlen_type kSBucketLength (kBucket *b, poly lm=NULL)
 TODO CoefBuckets bercksichtigen.
 
static BOOLEAN elength_is_normal_length (poly p, slimgb_alg *c)
 
static BOOLEAN lies_in_last_dp_block (poly p, slimgb_alg *c)
 
static int get_last_dp_block_start (ring r)
 
static wlen_type do_pELength (poly p, slimgb_alg *c, int dlm=-1)
 
wlen_type kEBucketLength (kBucket *b, poly lm, slimgb_alg *ca)
 
static int pELength (poly p, slimgb_alg *c, int l)
 
static wlen_type pQuality (poly p, slimgb_alg *c, int l=-1)
 
static int red_object_better_gen (const void *ap, const void *bp)
 
int tgb_pair_better_gen2 (const void *ap, const void *bp)
 
int kFindDivisibleByInS_easy (kStrategy strat, const red_object &obj)
 
int kFindDivisibleByInS_easy (kStrategy strat, poly p, long sev)
 
static int posInPairs (sorted_pair_node **p, int pn, sorted_pair_node *qe, slimgb_alg *c, int an=0)
 
static BOOLEAN ascending (int *i, int top)
 
sorted_pair_node ** spn_merge (sorted_pair_node **p, int pn, sorted_pair_node **q, int qn, slimgb_alg *c)
 
static BOOLEAN trivial_syzygie (int pos1, int pos2, poly bound, slimgb_alg *c)
 
int find_best (red_object *r, int l, int u, wlen_type &w, slimgb_alg *c)
 returns position sets w as weight
 
BOOLEAN good_has_t_rep (int i, int j, slimgb_alg *c)
 
BOOLEAN lenS_correct (kStrategy strat)
 
static void cleanS (kStrategy strat, slimgb_alg *c)
 
static void length_one_crit (slimgb_alg *c, int pos, int len)
 
static void move_forward_in_S (int old_pos, int new_pos, kStrategy strat)
 
static void move_backward_in_S (int old_pos, int new_pos, kStrategy strat)
 
static void replace_pair (int &i, int &j, slimgb_alg *c)
 
static void add_later (poly p, const char *prot, slimgb_alg *c)
 
static void clearS (poly p, unsigned long p_sev, int l, int *at, int *k, kStrategy strat)
 
static int iq_crit (const void *ap, const void *bp)
 
static wlen_type coeff_mult_size_estimate (int s1, int s2, ring r)
 
static wlen_type pair_weighted_length (int i, int j, slimgb_alg *c)
 
sorted_pair_node ** add_to_basis_ideal_quotient (poly h, slimgb_alg *c, int *ip)
 
static poly redTailShort (poly h, kStrategy strat)
 
static void line_of_extended_prod (int fixpos, slimgb_alg *c)
 
static void c_S_element_changed_hook (int pos, slimgb_alg *c)
 
BOOLEAN is_valid_ro (red_object &ro)
 
int terms_sort_crit (const void *a, const void *b)
 
static void mass_add (poly *p, int pn, slimgb_alg *c)
 
static void go_on (slimgb_alg *c)
 
void init_with_mac_poly (tgb_sparse_matrix *mat, int row, mac_poly m)
 
poly free_row_to_poly (tgb_sparse_matrix *mat, int row, poly *monoms, int monom_index)
 
static int poly_crit (const void *ap1, const void *ap2)
 
ideal t_rep_gb (const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
 
ideal do_t_rep_gb (ring, ideal arg_I, int syz_comp, BOOLEAN F4_mode, int deg_pos)
 
void now_t_rep (const int &arg_i, const int &arg_j, slimgb_alg *c)
 
sorted_pair_nodetop_pair (slimgb_alg *c)
 
sorted_pair_nodequick_pop_pair (slimgb_alg *c)
 
void clean_top_of_pair_list (slimgb_alg *c)
 
void free_sorted_pair_node (sorted_pair_node *s, const ring r)
 
static BOOLEAN pHasNotCFExtended (poly p1, poly p2, poly m)
 
static wlen_type quality_of_pos_in_strat_S (int pos, slimgb_alg *c)
 
static wlen_type quality_of_pos_in_strat_S_mult_high (int pos, poly high, slimgb_alg *c)
 
static void multi_reduction_lls_trick (red_object *los, int, slimgb_alg *c, find_erg &erg)
 
static int fwbw (red_object *los, int i)
 
static void canonicalize_region (red_object *los, int l, int u, slimgb_alg *)
 
static void multi_reduction_find (red_object *los, int, slimgb_alg *c, int startf, find_erg &erg)
 
static int multi_reduction_clear_zeroes (red_object *los, int losl, int l, int u, int syzComp)
 
int search_red_object_pos (red_object *a, int top, red_object *key)
 
static void sort_region_down (red_object *los, int l, int u, slimgb_alg *)
 

Variables

static const int bundle_size = 100
 
static const int bundle_size_noro = 10000
 
static const int delay_factor = 3
 
STATIC_VAR omBin lm_bin = NULL
 

Macro Definition Documentation

◆ ADD_LATER_SIZE

#define ADD_LATER_SIZE   500

Definition at line 39 of file tgb.cc.

◆ BUCKETS_FOR_NORO_RED

#define BUCKETS_FOR_NORO_RED   1

@TODO: delay nur auf Sugarvergroesserung @TODO: grade aus ecartS, setze dazu strat->honey; und nutze p.ecart @TODO: no tail reductions in syz comp

Definition at line 34 of file tgb.cc.

◆ degbound

#define degbound ( p)
Value:
int p
Definition cfModGcd.cc:4086
#define assume(x)
Definition mod2.h:389
static long pTotaldegree(poly p)
Definition polys.h:283

Definition at line 153 of file tgb.cc.

◆ ENLARGE

#define ENLARGE ( pointer,
type )
Value:
pointer=(type*) omreallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type))
#define omreallocSize(addr, o_size, size)

◆ ENLARGE_ALIGN

#define ENLARGE_ALIGN ( pointer,
type )
Value:
{if(pointer)\
pointer=(type*)omReallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type));\
else pointer=(type*)omAllocAligned(c->array_lengths*sizeof(type));}
#define omReallocSize(addr, o_size, size)
#define omAllocAligned

◆ LEN_VAR3

#define LEN_VAR3

Definition at line 152 of file tgb.cc.

◆ SR_HDL

#define SR_HDL ( A)
Value:
((long)(A))
#define A
Definition sirandom.c:24

Definition at line 35 of file tgb.cc.

Function Documentation

◆ add_later()

static void add_later ( poly p,
const char * prot,
slimgb_alg * c )
static

Definition at line 1244 of file tgb.cc.

1245{
1246 int i = 0;
1247 //check, if it is already in the queue
1248
1249 while(c->add_later->m[i] != NULL)
1250 {
1251 if(p_LmEqual (c->add_later->m[i], p, c->r))
1252 return;
1253 i++;
1254 }
1255 if(TEST_OPT_PROT)
1256 PrintS (prot);
1257 c->add_later->m[i] = p;
1258}
int i
Definition cfEzgcd.cc:132
ideal add_later
#define NULL
Definition omList.c:12
#define TEST_OPT_PROT
Definition options.h:105
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1739
void PrintS(const char *s)
Definition reporter.cc:284

◆ add_to_basis_ideal_quotient()

sorted_pair_node ** add_to_basis_ideal_quotient ( poly h,
slimgb_alg * c,
int * ip )

Definition at line 1378 of file tgb.cc.

1380{
1381 p_Test (h, c->r);
1382 assume (h != NULL);
1383 poly got = gcd_of_terms (h, c->r);
1384 if((got != NULL) && (TEST_V_UPTORADICAL))
1385 {
1386 poly copy = p_Copy (got, c->r);
1387 //p_wrp(got,c->r);
1388 BOOLEAN changed = monomial_root (got, c->r);
1389 if(changed)
1390 {
1391 poly div_by = pMDivide (copy, got);
1392 poly iter = h;
1393 while(iter)
1394 {
1395 pExpVectorSub (iter, div_by);
1396 pIter (iter);
1397 }
1398 p_Delete (&div_by, c->r);
1399 PrintS ("U");
1400 }
1401 p_Delete (&copy, c->r);
1402 }
1403
1404#define ENLARGE(pointer, type) pointer=(type*) omreallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type))
1405
1406#define ENLARGE_ALIGN(pointer, type) {if(pointer)\
1407 pointer=(type*)omReallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type));\
1408 else pointer=(type*)omAllocAligned(c->array_lengths*sizeof(type));}
1409// BOOLEAN corr=lenS_correct(c->strat);
1410 int sugar;
1411 int ecart = 0;
1412 ++(c->n);
1413 ++(c->S->ncols);
1414 int i, j;
1415 i = c->n - 1;
1416 sorted_pair_node **nodes =
1417 (sorted_pair_node **) omalloc (sizeof (sorted_pair_node *) * i);
1418 int spc = 0;
1419 int old=c->array_lengths;
1420 if(c->n > c->array_lengths)
1421 {
1422 c->array_lengths = c->array_lengths * 2;
1423 assume (c->array_lengths >= c->n);
1424 ENLARGE (c->T_deg, int);
1425 ENLARGE_ALIGN (c->tmp_pair_lm, poly);
1427
1428 ENLARGE_ALIGN (c->short_Exps, long);
1429 ENLARGE (c->lengths, int);
1430#ifndef HAVE_BOOST
1431#ifndef USE_STDVECBOOL
1432
1433 ENLARGE_ALIGN (c->states, char *);
1434#endif
1435#endif
1436 ENLARGE_ALIGN (c->gcd_of_terms, poly);
1437 //if (c->weighted_lengths!=NULL) {
1439 //}
1440 //ENLARGE_ALIGN(c->S->m,poly);
1441 }
1442 pEnlargeSet (&c->S->m, c->n - 1, 1);
1443 if(c->T_deg_full)
1444 ENLARGE (c->T_deg_full, int);
1445 sugar = c->T_deg[i] = c->pTotaldegree (h);
1446 if(c->T_deg_full)
1447 {
1448 sugar = c->T_deg_full[i] = c->pTotaldegree_full (h);
1449 ecart = sugar - c->T_deg[i];
1450 assume (ecart >= 0);
1451 }
1452 c->tmp_pair_lm[i] = pOne_Special (c->r);
1453
1454 c->tmp_spn[i] = (sorted_pair_node *) omAlloc (sizeof (sorted_pair_node));
1455
1456 c->lengths[i] = pLength (h);
1457
1458 //necessary for correct weighted length
1459
1461 {
1462 p_Cleardenom (h, c->r); //includes p_Content(h,c->r);
1463 }
1464 else
1465 pNorm (h);
1466 //pNormalize (h);
1467
1468 c->weighted_lengths[i] = pQuality (h, c, c->lengths[i]);
1469 c->gcd_of_terms[i] = got;
1470#ifdef HAVE_BOOST
1471 c->states.push_back (dynamic_bitset <> (i));
1472
1473#else
1474#ifdef USE_STDVECBOOL
1475
1476 c->states.push_back (vector < bool > (i));
1477
1478#else
1479 if(i > 0)
1480 c->states[i] = (char *) omAlloc (i * sizeof (char));
1481 else
1482 c->states[i] = NULL;
1483#endif
1484#endif
1485
1486 c->S->m[i] = h;
1487 c->short_Exps[i] = p_GetShortExpVector (h, c->r);
1488
1489#undef ENLARGE
1490#undef ENLARGE_ALIGN
1491 if(p_GetComp (h, currRing) <= c->syz_comp)
1492 {
1493 for(j = 0; j < i; j++)
1494 {
1495
1496
1497#ifndef HAVE_BOOST
1498 c->states[i][j] = UNCALCULATED;
1499#endif
1500 assume (p_LmDivisibleBy (c->S->m[i], c->S->m[j], c->r) ==
1501 p_LmShortDivisibleBy (c->S->m[i], c->short_Exps[i], c->S->m[j],
1502 ~(c->short_Exps[j]), c->r));
1503
1504 if(__p_GetComp (c->S->m[i], c->r) != __p_GetComp (c->S->m[j], c->r))
1505 {
1506 //c->states[i][j]=UNCALCULATED;
1507 //WARNUNG: be careful
1508 continue;
1509 }
1510 else if((!c->nc) && (c->lengths[i] == 1) && (c->lengths[j] == 1))
1511 {
1512 c->states[i][j] = HASTREP;
1513 }
1514 else if(((!c->nc) || (c->is_homog && rIsSCA (c->r)))
1515 && (pHasNotCF (c->S->m[i], c->S->m[j])))
1516// else if ((!(c->nc)) && (pHasNotCF(c->S->m[i],c->S->m[j])))
1517 {
1518 c->easy_product_crit++;
1519 c->states[i][j] = HASTREP;
1520 continue;
1521 }
1522 else
1524 (c->S->m[i], c->gcd_of_terms[i], c->S->m[j], c->gcd_of_terms[j],
1525 c))
1526 {
1527 c->states[i][j] = HASTREP;
1529 //PrintS("E");
1530 }
1531 // if (c->states[i][j]==UNCALCULATED)
1532 // {
1533
1534 if((TEST_V_FINDMONOM) && (!c->nc))
1535 {
1536 //PrintS("COMMU");
1537 // if (c->lengths[i]==c->lengths[j])
1538 // {
1539// poly short_s=ksCreateShortSpoly(c->S->m[i],c->S->m[j],c->r);
1540// if (short_s==NULL)
1541// {
1542// c->states[i][j]=HASTREP;
1543// }
1544// else
1545// {
1546// p_Delete(&short_s, currRing);
1547// }
1548// }
1549 if(c->lengths[i] + c->lengths[j] == 3)
1550 {
1551
1552
1553 poly short_s = ksCreateShortSpoly (c->S->m[i], c->S->m[j], c->r);
1554 if(short_s == NULL)
1555 {
1556 c->states[i][j] = HASTREP;
1557 }
1558 else
1559 {
1560 assume (pLength (short_s) == 1);
1562 monomial_root (short_s, c->r);
1563 int iS = kFindDivisibleByInS_easy (c->strat, short_s,
1564 p_GetShortExpVector (short_s,
1565 c->r));
1566 if(iS < 0)
1567 {
1568 //PrintS("N");
1569 if(TRUE)
1570 {
1571 c->states[i][j] = HASTREP;
1572 add_later (short_s, "N", c);
1573 }
1574 else
1575 p_Delete (&short_s, currRing);
1576 }
1577 else
1578 {
1579 if(c->strat->lenS[iS] > 1)
1580 {
1581 //PrintS("O");
1582 if(TRUE)
1583 {
1584 c->states[i][j] = HASTREP;
1585 add_later (short_s, "O", c);
1586 }
1587 else
1588 p_Delete (&short_s, currRing);
1589 }
1590 else
1591 p_Delete (&short_s, currRing);
1592 c->states[i][j] = HASTREP;
1593 }
1594
1595
1596 }
1597 }
1598 }
1599 // if (short_s)
1600 // {
1601 assume (spc <= j);
1602 sorted_pair_node *s = c->tmp_spn[spc]; //(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
1603 if (i>j) { s->i=i; s->j=j;}
1604 else { s->i=j; s->j=i;}
1605 s->expected_length = pair_weighted_length (i, j, c); //c->lengths[i]+c->lengths[j]-2;
1606
1607 poly lm = c->tmp_pair_lm[spc]; //=pOne_Special();
1608
1609 pLcm (c->S->m[i], c->S->m[j], lm);
1610 pSetm (lm);
1611 p_Test (lm, c->r);
1612 s->deg = c->pTotaldegree (lm);
1613
1614 if(c->T_deg_full) //Sugar
1615 {
1616 int t_i = c->T_deg_full[s->i] - c->T_deg[s->i];
1617 int t_j = c->T_deg_full[s->j] - c->T_deg[s->j];
1618 s->deg += si_max (t_i, t_j);
1619 //Print("\n max: %d\n",max(t_i,t_j));
1620 }
1621 p_Test (lm, c->r);
1622 s->lcm_of_lm = lm;
1623 // pDelete(&short_s);
1624 //assume(lm!=NULL);
1625 nodes[spc] = s;
1626 spc++;
1627
1628 // }
1629 //else
1630 //{
1631 //c->states[i][j]=HASTREP;
1632 //}
1633 }
1634 } //if syz_comp end
1635
1636 assume (spc <= i);
1637 //now ideal quotient crit
1638 qsort (nodes, spc, sizeof (sorted_pair_node *), iq_crit);
1639
1640 sorted_pair_node **nodes_final =
1641 (sorted_pair_node **) omalloc (sizeof (sorted_pair_node *) * (i+1));
1642 int spc_final = 0;
1643 j = 0;
1644 while(j < spc)
1645 {
1646 int lower = j;
1647 int upper;
1648 BOOLEAN has = FALSE;
1649 for(upper = lower + 1; upper < spc; upper++)
1650 {
1651 if(!pLmEqual (nodes[lower]->lcm_of_lm, nodes[upper]->lcm_of_lm))
1652 {
1653 break;
1654 }
1655 if(has_t_rep (nodes[upper]->i, nodes[upper]->j, c))
1656 has = TRUE;
1657 }
1658 upper = upper - 1;
1659 int z;
1660 assume (spc_final <= j);
1661 for(z = 0; z < spc_final; z++)
1662 {
1664 (nodes_final[z]->lcm_of_lm, nodes[lower]->lcm_of_lm, c->r))
1665 {
1666 has = TRUE;
1667 break;
1668 }
1669 }
1670
1671 if(has)
1672 {
1673 for(; lower <= upper; lower++)
1674 {
1675 //free_sorted_pair_node(nodes[lower],c->r);
1676 //omfree(nodes[lower]);
1677 nodes[lower] = NULL;
1678 }
1679 j = upper + 1;
1680 continue;
1681 }
1682 else
1683 {
1684 p_Test (nodes[lower]->lcm_of_lm, c->r);
1685 nodes[lower]->lcm_of_lm = pCopy (nodes[lower]->lcm_of_lm);
1686 assume (__p_GetComp (c->S->m[nodes[lower]->i], c->r) ==
1687 __p_GetComp (c->S->m[nodes[lower]->j], c->r));
1688 nodes_final[spc_final] =
1690
1691 *(nodes_final[spc_final++]) = *(nodes[lower]);
1692 //c->tmp_spn[nodes[lower]->j]=(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
1693 nodes[lower] = NULL;
1694 for(lower = lower + 1; lower <= upper; lower++)
1695 {
1696 // free_sorted_pair_node(nodes[lower],c->r);
1697 //omfree(nodes[lower]);
1698 nodes[lower] = NULL;
1699 }
1700 j = upper + 1;
1701 continue;
1702 }
1703 }
1704
1705 // Print("i:%d,spc_final:%d",i,spc_final);
1706
1707 assume (spc_final <= spc);
1708 omfree (nodes);
1709 nodes = NULL;
1710
1711 add_to_reductors (c, h, c->lengths[c->n - 1], ecart, TRUE);
1712 //i=posInS(c->strat,c->strat->sl,h,0 ecart);
1713 if(!(c->nc))
1714 {
1715 if(c->lengths[c->n - 1] == 1)
1716 shorten_tails (c, c->S->m[c->n - 1]);
1717 }
1718 //you should really update c->lengths, c->strat->lenS, and the order of polys in strat if you sort after lengths
1719
1720 //for(i=c->strat->sl; i>0;i--)
1721 // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i);
1722 if(c->Rcounter > 50)
1723 {
1724 c->Rcounter = 0;
1725 cleanS (c->strat, c);
1726 }
1727
1728#ifdef HAVE_PLURAL
1729 // for SCA:
1730 // here write at the end of nodes_final[spc_final,...,spc_final+lmdeg-1]
1731 if(rIsSCA (c->r))
1732 {
1733 const poly pNext = pNext (h);
1734
1735 if(pNext != NULL)
1736 {
1737 // for additional polynomials
1738 const unsigned int m_iFirstAltVar = scaFirstAltVar (c->r);
1739 const unsigned int m_iLastAltVar = scaLastAltVar (c->r);
1740
1741 int N = // c->r->N;
1742 m_iLastAltVar - m_iFirstAltVar + 1; // should be enough
1743 // TODO: but we may also use got = gcd({m}_{m\in f}))!
1744
1745 poly *array_arg = (poly *) omalloc (N * sizeof (poly)); // !
1746 int j = 0;
1747
1748
1749 for(unsigned short v = m_iFirstAltVar; v <= m_iLastAltVar; v++)
1750 // for all x_v | Ann(lm(h))
1751 if(p_GetExp (h, v, c->r)) // TODO: use 'got' here!
1752 {
1753 assume (p_GetExp (h, v, c->r) == 1);
1754
1755 poly p = sca_pp_Mult_xi_pp (v, pNext, c->r); // x_v * h;
1756
1757 if(p != NULL) // if (x_v * h != 0)
1758 array_arg[j++] = p;
1759 } // for all x_v | Ann(lm(h))
1760
1761 c->introduceDelayedPairs (array_arg, j);
1762
1763 omFree (array_arg); // !!!
1764 }
1765// PrintS("Saturation - done!!!\n");
1766 }
1767#endif // if SCAlgebra
1768
1769
1770 if(!ip)
1771 {
1772 qsort (nodes_final, spc_final, sizeof (sorted_pair_node *),
1774
1775
1776 c->apairs =
1777 spn_merge (c->apairs, c->pair_top + 1, nodes_final, spc_final, c);
1778 c->pair_top += spc_final;
1780 omFree (nodes_final);
1781 return NULL;
1782 }
1783 {
1784 *ip = spc_final;
1785 return nodes_final;
1786 }
1787}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
intset lenS
Definition kutil.h:320
unsigned long pTotaldegree(poly p)
sorted_pair_node ** apairs
kStrategy strat
int * T_deg_full
int easy_product_crit
int extended_product_crit
sorted_pair_node ** tmp_spn
void introduceDelayedPairs(poly *pa, int s)
Definition tgb.cc:3166
char ** states
poly * gcd_of_terms
poly * tmp_pair_lm
long * short_Exps
BOOLEAN is_homog
int syz_comp
array_lengths should be greater equal n;
int pTotaldegree_full(poly p)
wlen_type * weighted_lengths
CFFListIterator iter
const CanonicalForm int s
Definition facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
CFArray copy(const CFList &list)
write elements of list into an array
int j
Definition facHensel.cc:110
STATIC_VAR Poly * h
Definition janet.cc:971
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition kspoly.cc:1446
int64 wlen_type
Definition kutil.h:55
static bool rIsSCA(const ring r)
Definition nc.h:190
poly sca_pp_Mult_xi_pp(short i, const poly pPoly, const ring rRing)
Definition sca.cc:1201
#define p_GetComp(p, r)
Definition monomials.h:64
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define __p_GetComp(p, r)
Definition monomials.h:63
#define omfree(addr)
#define omAlloc(size)
#define omalloc(size)
#define omFree(addr)
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define TEST_V_FINDMONOM
Definition options.h:144
#define TEST_V_UPTORADICAL
Definition options.h:143
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4889
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3776
static int pLength(poly a)
Definition p_polys.h:190
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1926
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
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1907
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
#define p_Test(p, r)
Definition p_polys.h:161
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pSetm(p)
Definition polys.h:272
#define pHasNotCF(p1, p2)
Definition polys.h:264
#define pLmEqual(p1, p2)
Definition polys.h:112
void pNorm(poly p)
Definition polys.h:363
#define pExpVectorSub(p1, p2)
Definition polys.h:89
#define pMDivide(a, b)
Definition polys.h:294
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pLcm(a, b, m)
Definition polys.h:296
static short scaLastAltVar(ring r)
Definition sca.h:25
static short scaFirstAltVar(ring r)
Definition sca.h:18
static void shorten_tails(slimgb_alg *c, poly monom)
Definition tgb.cc:3725
static poly gcd_of_terms(poly p, ring r)
Definition tgb.cc:4031
int tgb_pair_better_gen2(const void *ap, const void *bp)
Definition tgb.cc:645
sorted_pair_node ** spn_merge(sorted_pair_node **p, int pn, sorted_pair_node **q, int qn, slimgb_alg *c)
Definition tgb.cc:716
static wlen_type pair_weighted_length(int i, int j, slimgb_alg *c)
Definition tgb.cc:1325
void clean_top_of_pair_list(slimgb_alg *c)
Definition tgb.cc:3931
#define ENLARGE(pointer, type)
static BOOLEAN monomial_root(poly m, ring r)
Definition tgb.cc:89
#define ENLARGE_ALIGN(pointer, type)
int kFindDivisibleByInS_easy(kStrategy strat, const red_object &obj)
Definition tgb.cc:650
static int iq_crit(const void *ap, const void *bp)
Definition tgb.cc:1292
static void add_later(poly p, const char *prot, slimgb_alg *c)
Definition tgb.cc:1244
static poly pOne_Special(const ring r=currRing)
Definition tgb.cc:142
static void cleanS(kStrategy strat, slimgb_alg *c)
Definition tgb.cc:883
static wlen_type pQuality(poly p, slimgb_alg *c, int l=-1)
Definition tgb.cc:521
static BOOLEAN has_t_rep(const int &arg_i, const int &arg_j, slimgb_alg *state)
Definition tgb.cc:3705
static void add_to_reductors(slimgb_alg *c, poly h, int len, int ecart, BOOLEAN simplified=FALSE)
Definition tgb.cc:929
static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg *c)
Definition tgb.cc:4090
@ UNCALCULATED
@ HASTREP

◆ add_to_reductors()

static void add_to_reductors ( slimgb_alg * c,
poly h,
int len,
int ecart,
BOOLEAN simplified = FALSE )
static

Definition at line 929 of file tgb.cc.

931{
932 //inDebug(h);
934 assume (len == pLength (h));
935 int i;
936// if (c->isDifficultField)
937// i=simple_posInS(c->strat,h,pSLength(h,len),c->isDifficultField);
938// else
939// i=simple_posInS(c->strat,h,len,c->isDifficultField);
940
941 if (TEST_OPT_IDLIFT &&(pGetComp(h) > c->syz_comp)) return;
942 LObject P;
943 P.Init();
944 P.tailRing = c->r;
945 P.p = h; /*p_Copy(h,c->r); */
946 P.ecart = ecart;
947 P.FDeg = c->r->pFDeg (P.p, c->r);
948 if(!(simplified))
949 {
951 {
952 p_Cleardenom (P.p, c->r); //includes p_Content(P.p,c->r );
953 }
954 else
955 pNorm (P.p);
956 //pNormalize (P.p);
957 }
958 wlen_type pq = pQuality (h, c, len);
959 i = simple_posInS (c->strat, h, len, pq);
960 c->strat->enterS (P, i, c->strat, -1);
961
962 c->strat->lenS[i] = len;
963 assume (pLength (c->strat->S[i]) == c->strat->lenS[i]);
964 if(c->strat->lenSw != NULL)
965 c->strat->lenSw[i] = pq;
966}
polyset S
Definition kutil.h:307
wlen_set lenSw
Definition kutil.h:321
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:287
class sLObject LObject
Definition kutil.h:59
#define TEST_OPT_IDLIFT
Definition options.h:131
#define pGetComp(p)
Component.
Definition polys.h:38
static int simple_posInS(kStrategy strat, poly p, int len, wlen_type wlen)
Definition tgb.cc:1260
BOOLEAN lenS_correct(kStrategy strat)
Definition tgb.cc:871

◆ ascending()

static BOOLEAN ascending ( int * i,
int top )
static

Definition at line 707 of file tgb.cc.

708{
709 if(top < 1)
710 return TRUE;
711 if(i[top] < i[top - 1])
712 return FALSE;
713 return ascending (i, top - 1);
714}
static BOOLEAN ascending(int *i, int top)
Definition tgb.cc:707

◆ bucket_guess()

static int bucket_guess ( kBucket * bucket)
static

Definition at line 916 of file tgb.cc.

917{
918 int sum = 0;
919 int i;
920 for(i = bucket->buckets_used; i >= 0; i--)
921 {
922 if(bucket->buckets[i])
923 sum += bucket->buckets_length[i];
924 }
925 return sum;
926}

◆ c_S_element_changed_hook()

static void c_S_element_changed_hook ( int pos,
slimgb_alg * c )
static

Definition at line 1923 of file tgb.cc.

1924{
1925 length_one_crit (c, pos, c->lengths[pos]);
1926 if(!c->nc)
1927 line_of_extended_prod (pos, c);
1928}
static void line_of_extended_prod(int fixpos, slimgb_alg *c)
Definition tgb.cc:1891
static void length_one_crit(slimgb_alg *c, int pos, int len)
Definition tgb.cc:968

◆ canonicalize_region()

static void canonicalize_region ( red_object * los,
int l,
int u,
slimgb_alg *  )
static

Definition at line 4493 of file tgb.cc.

4494{
4495 assume (l <= u + 1);
4496 int i;
4497 for(i = l; i <= u; i++)
4498 {
4499 kBucketCanonicalize (los[i].bucket);
4500 }
4501}
int l
Definition cfEzgcd.cc:100
int kBucketCanonicalize(kBucket_pt bucket)
Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in one bucket: Returns number of bu...

◆ clean_top_of_pair_list()

void clean_top_of_pair_list ( slimgb_alg * c)

Definition at line 3931 of file tgb.cc.

3932{
3933 while((c->pair_top >= 0) && (c->apairs[c->pair_top]->i >= 0)
3934 &&
3935 (!state_is
3936 (UNCALCULATED, c->apairs[c->pair_top]->j, c->apairs[c->pair_top]->i,
3937 c)))
3938 {
3940 c->pair_top--;
3941 }
3942}
void free_sorted_pair_node(sorted_pair_node *s, const ring r)
Definition tgb.cc:3964
static BOOLEAN state_is(calc_state state, const int &i, const int &j, slimgb_alg *c)
Definition tgb.cc:3945

◆ cleanS()

static void cleanS ( kStrategy strat,
slimgb_alg * c )
static

Definition at line 883 of file tgb.cc.

884{
885 int i = 0;
886 LObject P;
887 while(i <= strat->sl)
888 {
889 P.p = strat->S[i];
890 P.sev = strat->sevS[i];
891 //int dummy=strat->sl;
892 //if(kFindDivisibleByInS(strat,&dummy,&P)!=i)
893 if(kFindDivisibleByInS_easy (strat, P.p, P.sev) != i)
894 {
895 deleteInS (i, strat);
896 //remember destroying poly
898 int j;
899 for(j = 0; j < c->n; j++)
900 {
901 if(c->S->m[j] == P.p)
902 {
903 found = TRUE;
904 break;
905 }
906 }
907 if(!found)
908 pDelete (&P.p);
909 //remember additional reductors
910 }
911 else
912 i++;
913 }
914}
unsigned long * sevS
Definition kutil.h:323
bool found
void deleteInS(int i, kStrategy strat)
Definition kutil.cc:1139
#define pDelete(p_ptr)
Definition polys.h:187

◆ clearS()

static void clearS ( poly p,
unsigned long p_sev,
int l,
int * at,
int * k,
kStrategy strat )
inlinestatic

Definition at line 1275 of file tgb.cc.

1276{
1277 assume (p_sev == pGetShortExpVector (p));
1278 if(!pLmShortDivisibleBy (p, p_sev, strat->S[*at], ~strat->sevS[*at]))
1279 return;
1280 if(l >= strat->lenS[*at])
1281 return;
1282 if(TEST_OPT_PROT)
1283 PrintS ("!");
1284 mflush ();
1285 //pDelete(&strat->S[*at]);
1286 deleteInS ((*at), strat);
1287 (*at)--;
1288 (*k)--;
1289// assume(lenS_correct(strat));
1290}
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
Definition polys.h:147
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153
#define mflush()
Definition reporter.h:58

◆ coeff_mult_size_estimate()

static wlen_type coeff_mult_size_estimate ( int s1,
int s2,
ring r )
static

Definition at line 1317 of file tgb.cc.

1318{
1319 if(rField_is_Q (r))
1320 return s1 + s2;
1321 else
1322 return s1 * s2;
1323}
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512

◆ do_pELength()

static wlen_type do_pELength ( poly p,
slimgb_alg * c,
int dlm = -1 )
static

Definition at line 446 of file tgb.cc.

447{
448 if(p == NULL)
449 return 0;
450 wlen_type s = 0;
451 poly pi = p;
452 if(dlm < 0)
453 {
454 dlm = c->pTotaldegree (p);
455 s = 1;
456 pi = p->next;
457 }
458
459 while(pi)
460 {
461 int d = c->pTotaldegree (pi);
462 if(d > dlm)
463 s += 1 + d - dlm;
464 else
465 ++s;
466 pi = pi->next;
467 }
468 return s;
469}
#define pi
Definition libparse.cc:1145

◆ do_t_rep_gb()

ideal do_t_rep_gb ( ring r,
ideal arg_I,
int syz_comp,
BOOLEAN F4_mode,
int deg_pos )

Definition at line 3629 of file tgb.cc.

3630{
3631 // Print("QlogSize(0) %d, QlogSize(1) %d,QlogSize(-2) %d, QlogSize(5) %d\n", QlogSize(nlInit(0)),QlogSize(nlInit(1)),QlogSize(nlInit(-2)),QlogSize(nlInit(5)));
3632
3633 if(TEST_OPT_PROT)
3634 if(F4_mode)
3635 PrintS ("F4 Modus\n");
3636
3637 //debug_Ideal=arg_debug_Ideal;
3638 //if (debug_Ideal) PrintS("DebugIdeal received\n");
3639 // Print("Idelems %i \n----------\n",IDELEMS(arg_I));
3640 ideal I = arg_I;
3642 if(idIs0 (I))
3643 return I;
3644 int i;
3645 for(i = 0; i < IDELEMS (I); i++)
3646 {
3647 assume (I->m[i] != NULL);
3648 simplify_poly (I->m[i], currRing);
3649 }
3650
3651 qsort (I->m, IDELEMS (I), sizeof (poly), poly_crit);
3652 //Print("Idelems %i \n----------\n",IDELEMS(I));
3653 //slimgb_alg* c=(slimgb_alg*) omalloc(sizeof(slimgb_alg));
3654 //int syz_comp=arg_I->rank;
3655 slimgb_alg *c = new slimgb_alg (I, syz_comp, F4_mode, deg_pos);
3656
3657 while((c->pair_top >= 0)
3658 && ((!(TEST_OPT_DEGBOUND))
3659 || (c->apairs[c->pair_top]->deg <= Kstd1_deg)))
3660 {
3661#ifdef HAVE_F4
3662 if(F4_mode)
3663 go_on_F4 (c);
3664 else
3665#endif
3666 go_on (c);
3667 }
3668 if(c->pair_top < 0)
3669 c->completed = TRUE;
3670 I = c->S;
3671 delete c;
3672 if(TEST_OPT_REDSB)
3673 {
3674 ideal erg = kInterRed (I, NULL);
3675 assume (I != erg);
3676 id_Delete (&I, currRing);
3677 return erg;
3678 }
3679 //qsort(I->m, IDELEMS(I),sizeof(poly),pLmCmp_func);
3680 assume (I->rank >= id_RankFreeModule (I,currRing));
3681 return (I);
3682}
BOOLEAN completed
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3797
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
#define TEST_OPT_REDSB
Definition options.h:106
#define TEST_OPT_DEGBOUND
Definition options.h:115
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_Compactify(ideal id, const ring r)
#define IDELEMS(i)
static void go_on(slimgb_alg *c)
Definition tgb.cc:2712
static int poly_crit(const void *ap1, const void *ap2)
Definition tgb.cc:3148
static void simplify_poly(poly p, ring r)
Definition tgb.cc:59

◆ elength_is_normal_length()

static BOOLEAN elength_is_normal_length ( poly p,
slimgb_alg * c )
static

Definition at line 371 of file tgb.cc.

372{
373 ring r = c->r;
374 if(p_GetComp (p, r) != 0)
375 return FALSE;
376 if(c->lastDpBlockStart <= (currRing->N))
377 {
378 int i;
379 for(i = 1; i < c->lastDpBlockStart; i++)
380 {
381 if(p_GetExp (p, i, r) != 0)
382 {
383 break;
384 }
385 }
386 if(i >= c->lastDpBlockStart)
387 {
388 //wrp(p);
389 //PrintS("\n");
390 return TRUE;
391 }
392 else
393 return FALSE;
394 }
395 else
396 return FALSE;
397}
int lastDpBlockStart

◆ extended_product_criterion()

static BOOLEAN extended_product_criterion ( poly p1,
poly gcd1,
poly p2,
poly gcd2,
slimgb_alg * c )
inlinestatic

Definition at line 4090 of file tgb.cc.

4092{
4093 if(c->nc)
4094 return FALSE;
4095 if(gcd1 == NULL)
4096 return FALSE;
4097 if(gcd2 == NULL)
4098 return FALSE;
4099 gcd1->next = gcd2; //may ordered incorrect
4100 poly m = gcd_of_terms (gcd1, c->r);
4101 gcd1->next = NULL;
4102 if(m == NULL)
4103 return FALSE;
4104
4105 BOOLEAN erg = pHasNotCFExtended (p1, p2, m);
4106 pDelete (&m);
4107 return erg;
4108}
int m
Definition cfEzgcd.cc:128
static BOOLEAN pHasNotCFExtended(poly p1, poly p2, poly m)
Definition tgb.cc:4071

◆ find_best()

int find_best ( red_object * r,
int l,
int u,
wlen_type & w,
slimgb_alg * c )

returns position sets w as weight

Definition at line 818 of file tgb.cc.

819{
820 int best = l;
821 int i;
822 w = r[l].guess_quality (c);
823 for(i = l + 1; i <= u; i++)
824 {
825 wlen_type w2 = r[i].guess_quality (c);
826 if(w2 < w)
827 {
828 w = w2;
829 best = i;
830 }
831 }
832 return best;
833}
wlen_type guess_quality(slimgb_alg *c)
Definition tgb.cc:556
const CanonicalForm & w
Definition facAbsFact.cc:51

◆ free_row_to_poly()

poly free_row_to_poly ( tgb_sparse_matrix * mat,
int row,
poly * monoms,
int monom_index )

Definition at line 3128 of file tgb.cc.

3130{
3131 poly p = NULL;
3132 poly *set_this = &p;
3133 mac_poly r = mat->mp[row];
3134 mat->mp[row] = NULL;
3135 while(r)
3136 {
3137 (*set_this) = pLmInit (monoms[monom_index - 1 - r->exp]);
3138 pSetCoeff ((*set_this), r->coef);
3139 set_this = &((*set_this)->next);
3140 mac_poly old = r;
3141 r = r->next;
3142 delete old;
3143
3144 }
3145 return p;
3146}
mac_poly_r * next
Definition tgbgauss.h:51
number coef
Definition tgbgauss.h:50
mac_poly * mp
Definition tgbgauss.h:64
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65
mac_poly_r * mac_poly
Definition tgbgauss.h:58

◆ free_sorted_pair_node()

void free_sorted_pair_node ( sorted_pair_node * s,
const ring r )

Definition at line 3964 of file tgb.cc.

3965{
3966 if(s->i >= 0)
3967 p_Delete (&s->lcm_of_lm, r);
3968 omFree (s);
3969}

◆ fwbw()

static int fwbw ( red_object * los,
int i )
static

Definition at line 4435 of file tgb.cc.

4436{
4437 int i2 = i;
4438 int step = 1;
4439
4440 BOOLEAN bw = FALSE;
4441 BOOLEAN incr = TRUE;
4442
4443 while(1)
4444 {
4445 if(!bw)
4446 {
4447 if (i2 < step) step=i2;
4448 if(step == 0)
4449 break;
4450 i2 -= step;
4451
4452 if(!pLmEqual (los[i].p, los[i2].p))
4453 {
4454 bw = TRUE;
4455 incr = FALSE;
4456 }
4457 else
4458 {
4459 if((!incr) && (step == 1))
4460 break;
4461 }
4462 }
4463 else
4464 {
4465 step = si_min (i - i2, step);
4466 if(step == 0)
4467 break;
4468 i2 += step;
4469 if(pLmEqual (los[i].p, los[i2].p))
4470 {
4471 if(step == 1)
4472 break;
4473 else
4474 {
4475 bw = FALSE;
4476 }
4477 }
4478 }
4479 if(incr)
4480 step *= 2;
4481 else
4482 {
4483 if(step % 2 == 1)
4484 step = (step + 1) / 2;
4485 else
4486 step /= 2;
4487 }
4488 }
4489 return i2;
4490}
static int si_min(const int a, const int b)
Definition auxiliary.h:126

◆ gcd_of_terms()

static poly gcd_of_terms ( poly p,
ring r )
static

Definition at line 4031 of file tgb.cc.

4032{
4033 int max_g_0 = 0;
4034 assume (p != NULL);
4035 int i;
4036 poly m = pOne ();
4037 poly t;
4038 for(i = (currRing->N); i; i--)
4039 {
4040 pSetExp (m, i, pGetExp (p, i));
4041 if(max_g_0 == 0)
4042 if(pGetExp (m, i) > 0)
4043 max_g_0 = i;
4044 }
4045
4046 t = p->next;
4047 while(t != NULL)
4048 {
4049 if(max_g_0 == 0)
4050 break;
4051 for(i = max_g_0; i; i--)
4052 {
4053 pSetExp (m, i, si_min (pGetExp (t, i), pGetExp (m, i)));
4054 if(max_g_0 == i)
4055 if(pGetExp (m, i) == 0)
4056 max_g_0 = 0;
4057 if((max_g_0 == 0) && (pGetExp (m, i) > 0))
4058 {
4059 max_g_0 = i;
4060 }
4061 }
4062 t = t->next;
4063 }
4064 p_Setm (m, r);
4065 if(max_g_0 > 0)
4066 return m;
4067 pDelete (&m);
4068 return NULL;
4069}
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pSetExp(p, i, v)
Definition polys.h:43
#define pOne()
Definition polys.h:316

◆ get_last_dp_block_start()

static int get_last_dp_block_start ( ring r)
static

Definition at line 427 of file tgb.cc.

428{
429 //ring r=c->r;
430 int last_block;
431
433 {
434 last_block = rBlocks (r) - 3;
435 }
436 else
437 {
438 last_block = rBlocks (r) - 2;
439 }
440 assume (last_block >= 0);
441 if(r->order[last_block] == ringorder_dp)
442 return r->block0[last_block];
443 return (currRing->N) + 1;
444}
BOOLEAN rRing_has_CompLastBlock(const ring r)
Definition ring.cc:5329
static int rBlocks(const ring r)
Definition ring.h:574
@ ringorder_dp
Definition ring.h:79

◆ go_on()

static void go_on ( slimgb_alg * c)
static

Definition at line 2712 of file tgb.cc.

2713{
2714 //set limit of 1000 for multireductions, at the moment for
2715 //programming reasons
2716#ifdef USE_NORO
2717 //Print("module rank%d\n",c->S->rank);
2718 const BOOLEAN use_noro = c->use_noro;
2719#else
2720 const BOOLEAN use_noro = FALSE;
2721#endif
2722 int i = 0;
2723 c->average_length = 0;
2724 for(i = 0; i < c->n; i++)
2725 {
2726 c->average_length += c->lengths[i];
2727 }
2728 c->average_length = c->average_length / c->n;
2729 i = 0;
2730 int max_pairs = bundle_size;
2731
2732#ifdef USE_NORO
2733 if((use_noro) || (c->use_noro_last_block))
2734 max_pairs = bundle_size_noro;
2735#endif
2736 poly *p = (poly *) omAlloc ((max_pairs + 1) * sizeof (poly)); //nullterminated
2737
2738 int curr_deg = -1;
2739 while(i < max_pairs)
2740 {
2741 sorted_pair_node *s = top_pair (c); //here is actually chain criterium done
2742
2743 if(!s)
2744 break;
2745
2746 if(curr_deg >= 0)
2747 {
2748 if(s->deg > curr_deg)
2749 break;
2750 }
2751
2752 else
2753 curr_deg = s->deg;
2754 quick_pop_pair (c);
2755 if(s->i >= 0)
2756 {
2757 //be careful replace_pair use createShortSpoly which is not noncommutative
2758 now_t_rep (s->i, s->j, c);
2759 replace_pair (s->i, s->j, c);
2760
2761 if(s->i == s->j)
2762 {
2764 continue;
2765 }
2766 now_t_rep (s->i, s->j, c);
2767 }
2768 poly h;
2769 if(s->i >= 0)
2770 {
2771#ifdef HAVE_PLURAL
2772 if(c->nc)
2773 {
2774 h = nc_CreateSpoly (c->S->m[s->i], c->S->m[s->j] /*, NULL */ , c->r);
2775
2776 if(h != NULL)
2777 p_Cleardenom (h, c->r);
2778 }
2779 else
2780#endif
2781 h = ksOldCreateSpoly (c->S->m[s->i], c->S->m[s->j], NULL, c->r);
2782 p_Test (h, c->r);
2783 }
2784 else
2785 {
2786 h = s->lcm_of_lm;
2787 p_Test (h, c->r);
2788 }
2789
2790 if(!h)
2791 continue;
2792
2794 && p_GetComp(h, currRing) > c->syz_comp)
2795 {
2796 pDelete(&h);
2797 continue;
2798 }
2799 // if(s->i>=0)
2800// now_t_rep(s->j,s->i,c);
2801 number coef;
2802 int mlen = pLength (h);
2803 p_Test (h, c->r);
2804 if((!c->nc) & (!(use_noro)))
2805 {
2806 h = redNF2 (h, c, mlen, coef, 2);
2807 redTailShort (h, c->strat);
2808 nDelete (&coef);
2809 }
2810 p_Test (h, c->r);
2812 if(!h)
2813 continue;
2814
2816 && p_GetComp(h, currRing) > c->syz_comp)
2817 {
2818 pDelete(&h);
2819 continue;
2820 }
2821
2822 p[i] = h;
2823 i++;
2824 }
2825 p[i] = NULL;
2826// pre_comp(p,i,c);
2827 if(i == 0)
2828 {
2829 omFree (p);
2830 return;
2831 }
2832#ifdef TGB_RESORT_PAIRS
2833 c->replaced = new bool[c->n];
2834 c->used_b = FALSE;
2835#endif
2836
2837 c->normal_forms += i;
2838 int j;
2839#ifdef USE_NORO
2840 //if ((!(c->nc))&&(rField_is_Zp(c->r)))
2841 //{
2842 if(use_noro)
2843 {
2844 int pn = i;
2845 if(pn == 0)
2846 {
2847 omFree (p);
2848 return;
2849 }
2850 {
2851 if(n_GetChar(currRing->cf) < 255)
2852 {
2853 noro_step < tgb_uint8 > (p, pn, c);
2854 }
2855 else
2856 {
2857 if(n_GetChar(currRing->cf) < 65000)
2858 {
2859 noro_step < tgb_uint16 > (p, pn, c);
2860 }
2861 else
2862 {
2863 noro_step < tgb_uint32 > (p, pn, c);
2864 }
2865 }
2866 }
2867
2868 //if (TEST_OPT_PROT)
2869 //{
2870 // Print("reported rank:%i\n",pn);
2871 //}
2872 mass_add (p, pn, c);
2873 omFree (p);
2874 return;
2875 /*if (TEST_OPT_PROT)
2876 for(j=0;j<pn;j++)
2877 {
2878 p_wrp(p[j],c->r);
2879 } */
2880 }
2881#endif
2882 red_object *buf = (red_object *) omAlloc (i * sizeof (red_object)); /*i>0*/
2883 for(j = 0; j < i; j++)
2884 {
2885 p_Test (p[j], c->r);
2886 buf[j].p = p[j];
2887 buf[j].sev = pGetShortExpVector (p[j]);
2888 buf[j].bucket = kBucketCreate (currRing);
2889 p_Test (p[j], c->r);
2890 int len = pLength (p[j]);
2891 kBucketInit (buf[j].bucket, p[j], len);
2892 buf[j].initial_quality = buf[j].guess_quality (c);
2893 assume (buf[j].initial_quality >= 0);
2894 }
2895 omFree (p);
2896 qsort (buf, i, sizeof (red_object), red_object_better_gen);
2897// Print("\ncurr_deg:%i\n",curr_deg);
2898 if(TEST_OPT_PROT)
2899 {
2900 Print ("%dM[%d,", curr_deg, i);
2901 }
2902
2903 multi_reduction (buf, i, c);
2904#ifdef TGB_RESORT_PAIRS
2905 if(c->used_b)
2906 {
2907 if(TEST_OPT_PROT)
2908 PrintS ("B");
2909 int e;
2910 for(e = 0; e <= c->pair_top; e++)
2911 {
2912 if(c->apairs[e]->i < 0)
2913 continue;
2914 assume (c->apairs[e]->j >= 0);
2915 if((c->replaced[c->apairs[e]->i]) || (c->replaced[c->apairs[e]->j]))
2916 {
2917 sorted_pair_node *s = c->apairs[e];
2918 s->expected_length = pair_weighted_length (s->i, s->j, c);
2919 }
2920 }
2921 qsort (c->apairs, c->pair_top + 1, sizeof (sorted_pair_node *),
2923 }
2924#endif
2925#ifdef TGB_DEBUG
2926 {
2927 int k;
2928 for(k = 0; k < i; k++)
2929 {
2931 int k2;
2932 for(k2 = 0; k2 < i; k2++)
2933 {
2934 if(k == k2)
2935 continue;
2936 assume ((!(p_LmDivisibleBy (buf[k].p, buf[k2].p, c->r)))
2937 || (wrp (buf[k].p), Print (" k %d k2 %d ", k, k2),
2938 wrp (buf[k2].p), FALSE));
2939 }
2940 }
2941 }
2942#endif
2943 //resort S
2944
2945 if(TEST_OPT_PROT)
2946 Print ("%i]", i);
2947
2948 poly *add_those = (poly *) omalloc0 (i * sizeof (poly));
2949 int num_to_add=0;
2950 for(j = 0; j < i; j++)
2951 {
2952 int len;
2953 poly p;
2954 buf[j].flatten ();
2955 kBucketClear (buf[j].bucket, &p, &len);
2956 kBucketDestroy (&buf[j].bucket);
2957 p_Test (p, c->r);
2958 //if (!c->nc) {
2959 if((c->tailReductions) || (lies_in_last_dp_block (p, c)))
2960 {
2961 p = redNFTail (p, c->strat->sl, c->strat, 0);
2962 }
2963 else
2964 {
2965 p = redTailShort (p, c->strat);
2966 }
2967 //}
2968 p_Test (p, c->r);
2969
2970 if (p!=NULL)
2971 {
2973 {
2975 }
2976 else
2977 {
2978 add_those[num_to_add++] = p;
2979 }
2980 }
2981
2982 //sbuf[j]=add_to_basis(p,-1,-1,c,ibuf+j);
2983 }
2984 mass_add (add_those, num_to_add, c);
2985 omfree (add_those);
2986 omFree (buf);
2987
2988 if(TEST_OPT_PROT)
2989 Print ("(%d)", c->pair_top + 1);
2990 //TODO: implement that while(!(idIs0(c->add_later)))
2991#ifdef TGB_RESORT_PAIRS
2992 delete c->replaced;
2993 c->replaced = NULL;
2994 c->used_b = FALSE;
2995#endif
2996 return;
2997}
int k
Definition cfEzgcd.cc:99
template void noro_step< tgb_uint8 >(poly *p, int &pn, slimgb_alg *c)
template void noro_step< tgb_uint32 >(poly *p, int &pn, slimgb_alg *c)
template void noro_step< tgb_uint16 >(poly *p, int &pn, slimgb_alg *c)
int sl
Definition kutil.h:349
BOOLEAN use_noro_last_block
BOOLEAN tailReductions
BOOLEAN use_noro
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:448
#define Print
Definition emacs.cc:80
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
Definition kInline.h:1191
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition kbuckets.cc:521
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition kbuckets.cc:216
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition kbuckets.cc:493
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition kbuckets.cc:209
static poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
Definition nc.h:241
#define nDelete(n)
Definition numbers.h:16
#define omalloc0(size)
void wrp(poly p)
Definition polys.h:311
int status int void * buf
Definition si_signals.h:69
static poly redNFTail(poly h, const int sl, kStrategy strat, int len)
Definition tgb.cc:3001
static const int bundle_size
Definition tgb.cc:36
void now_t_rep(const int &arg_i, const int &arg_j, slimgb_alg *c)
Definition tgb.cc:3684
static void mass_add(poly *p, int pn, slimgb_alg *c)
Definition tgb.cc:2097
static BOOLEAN lies_in_last_dp_block(poly p, slimgb_alg *c)
Definition tgb.cc:399
sorted_pair_node * quick_pop_pair(slimgb_alg *c)
Definition tgb.cc:3910
sorted_pair_node * top_pair(slimgb_alg *c)
Definition tgb.cc:3886
static void replace_pair(int &i, int &j, slimgb_alg *c)
Definition tgb.cc:1167
static poly redNF2(poly h, slimgb_alg *c, int &len, number &m, int n=0)
Definition tgb.cc:1789
static void multi_reduction(red_object *los, int &losl, slimgb_alg *c)
Definition tgb.cc:4689
static poly redTailShort(poly h, kStrategy strat)
Definition tgb.cc:1872
static int red_object_better_gen(const void *ap, const void *bp)
Definition tgb.cc:630
static const int bundle_size_noro
Definition tgb.cc:37

◆ good_has_t_rep()

BOOLEAN good_has_t_rep ( int i,
int j,
slimgb_alg * c )

Definition at line 840 of file tgb.cc.

841{
842 assume (i >= 0);
843 assume (j >= 0);
844 if(has_t_rep (i, j, c))
845 return TRUE;
846 //poly lm=pOne();
847 assume (c->tmp_lm != NULL);
848 poly lm = c->tmp_lm;
849
850 pLcm (c->S->m[i], c->S->m[j], lm);
851 pSetm (lm);
852 assume (lm != NULL);
853 //int deciding_deg= pTotaldegree(lm);
854 int *i_con = make_connections (i, j, lm, c);
855 //p_Delete(&lm,c->r);
856
857 for(int n = 0; ((n < c->n) && (i_con[n] >= 0)); n++)
858 {
859 if(i_con[n] == j)
860 {
861 now_t_rep (i, j, c);
862 omFree (i_con);
863 return TRUE;
864 }
865 }
866 omFree (i_con);
867
868 return FALSE;
869}
static int * make_connections(int from, int to, poly bound, slimgb_alg *c)
Definition tgb.cc:1064

◆ has_t_rep()

static BOOLEAN has_t_rep ( const int & arg_i,
const int & arg_j,
slimgb_alg * state )
static

Definition at line 3705 of file tgb.cc.

3706{
3707 assume (0 <= arg_i);
3708 assume (0 <= arg_j);
3709 assume (arg_i < state->n);
3710 assume (arg_j < state->n);
3711 if(arg_i == arg_j)
3712 {
3713 return (TRUE);
3714 }
3715 if(arg_i > arg_j)
3716 {
3717 return (state->states[arg_i][arg_j] == HASTREP);
3718 }
3719 else
3720 {
3721 return (state->states[arg_j][arg_i] == HASTREP);
3722 }
3723}

◆ init_with_mac_poly()

void init_with_mac_poly ( tgb_sparse_matrix * mat,
int row,
mac_poly m )

Definition at line 3113 of file tgb.cc.

3114{
3115 assume (mat->mp[row] == NULL);
3116 mat->mp[row] = m;
3117#ifdef TGB_DEBUG
3118 mac_poly r = m;
3119 while(r)
3120 {
3121 assume (r->exp < mat->columns);
3122 r = r->next;
3123 }
3124#endif
3125}

◆ iq_crit()

static int iq_crit ( const void * ap,
const void * bp )
static

Definition at line 1292 of file tgb.cc.

1293{
1295 sorted_pair_node *b = *((sorted_pair_node **) bp);
1296 assume (a->i > a->j);
1297 assume (b->i > b->j);
1298
1299 if(a->deg < b->deg)
1300 return -1;
1301 if(a->deg > b->deg)
1302 return 1;
1303 int comp = pLmCmp (a->lcm_of_lm, b->lcm_of_lm);
1304 if(comp != 0)
1305 return comp;
1306 if(a->expected_length < b->expected_length)
1307 return -1;
1308 if(a->expected_length > b->expected_length)
1309 return 1;
1310 if(a->j > b->j)
1311 return 1;
1312 if(a->j < b->j)
1313 return -1;
1314 return 0;
1315}
CanonicalForm b
Definition cfModGcd.cc:4111
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
Definition ap.h:40
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
wlen_type expected_length

◆ is_valid_ro()

BOOLEAN is_valid_ro ( red_object & ro)

Definition at line 1973 of file tgb.cc.

1974{
1975 red_object r2 = ro;
1976 ro.validate ();
1977 if((r2.p != ro.p) || (r2.sev != ro.sev))
1978 return FALSE;
1979 return TRUE;
1980}
unsigned long sev
void validate()
Definition tgb.cc:4878

◆ kEBucketLength()

wlen_type kEBucketLength ( kBucket * b,
poly lm,
slimgb_alg * ca )

Definition at line 471 of file tgb.cc.

472{
473 wlen_type s = 0;
474 if(lm == NULL)
475 {
476 lm = kBucketGetLm (b);
477 }
478 if(lm == NULL)
479 return 0;
480 if(elength_is_normal_length (lm, ca))
481 {
482 return bucket_guess (b);
483 }
484 long unsigned d = ca->pTotaldegree (lm);
485#if 0
486 assume (sugar >= d);
487 s = 1 + (bucket_guess (b) - 1) * (sugar - d + 1);
488 return s;
489#else
490
491 //int d=pTotaldegree(lm,ca->r);
492 int i;
493 for(i = b->buckets_used; i >= 0; i--)
494 {
495 if(b->buckets[i] == NULL)
496 continue;
497
498 if((ca->pTotaldegree (b->buckets[i]) <= d)
499 && (elength_is_normal_length (b->buckets[i], ca)))
500 {
501 s += b->buckets_length[i];
502 }
503 else
504 {
505 s += do_pELength (b->buckets[i], ca, d);
506 }
507 }
508 return s;
509#endif
510}
const poly kBucketGetLm(kBucket_pt bucket)
Definition kbuckets.cc:506
static wlen_type do_pELength(poly p, slimgb_alg *c, int dlm=-1)
Definition tgb.cc:446
static int bucket_guess(kBucket *bucket)
Definition tgb.cc:916
static BOOLEAN elength_is_normal_length(poly p, slimgb_alg *c)
Definition tgb.cc:371

◆ kFindDivisibleByInS_easy() [1/2]

int kFindDivisibleByInS_easy ( kStrategy strat,
const red_object & obj )

Definition at line 650 of file tgb.cc.

651{
652 poly p = obj.p;
653 if ((strat->syzComp>0) && (pGetComp(p)>strat->syzComp)) return -1;
654 long not_sev = ~obj.sev;
655 for(int i = 0; i <= strat->sl; i++)
656 {
657 if(pLmShortDivisibleBy (strat->S[i], strat->sevS[i], p, not_sev))
658 return i;
659 }
660 return -1;
661}
int syzComp
Definition kutil.h:355

◆ kFindDivisibleByInS_easy() [2/2]

int kFindDivisibleByInS_easy ( kStrategy strat,
poly p,
long sev )

Definition at line 663 of file tgb.cc.

664{
665 if ((strat->syzComp>0) && (pGetComp(p)>strat->syzComp)) return -1;
666 long not_sev = ~sev;
667 for(int i = 0; i <= strat->sl; i++)
668 {
669 if(pLmShortDivisibleBy (strat->S[i], strat->sevS[i], p, not_sev))
670 return i;
671 }
672 return -1;
673}

◆ kSBucketLength()

wlen_type kSBucketLength ( kBucket * b,
poly lm = NULL )

TODO CoefBuckets bercksichtigen.

Definition at line 221 of file tgb.cc.

222{
223 int s = 0;
224 wlen_type c;
225 number coef;
226 if(lm == NULL)
227 coef = pGetCoeff (kBucketGetLm (b));
228 //c=nSize(pGetCoeff(kBucketGetLm(b)));
229 else
230 coef = pGetCoeff (lm);
231 //c=nSize(pGetCoeff(lm));
233 {
234 c = nlQlogSize (coef, currRing->cf);
235 }
236 else
237 c = nSize (coef);
238
239 int i;
240 for(i = b->buckets_used; i >= 0; i--)
241 {
242 assume ((b->buckets_length[i] == 0) || (b->buckets[i] != NULL));
243 s += b->buckets_length[i] /*pLength(b->buckets[i]) */ ;
244 }
245#ifdef HAVE_COEF_BUCKETS
246 assume (b->buckets[0] == kBucketGetLm (b));
247 if(b->coef[0] != NULL)
248 {
250 {
251 int modifier = nlQlogSize (pGetCoeff (b->coef[0]), currRing->cf);
252 c += modifier;
253 }
254 else
255 {
256 int modifier = nSize (pGetCoeff (b->coef[0]));
257 c *= modifier;
258 }
259 }
260#endif
261 if(!(TEST_V_COEFSTRAT))
262 {
263 return s * c;
264 }
265 else
266 {
267 wlen_type res = s;
268 res *= c;
269 res *= c;
270 return res;
271 }
272}
CanonicalForm res
Definition facAbsFact.cc:60
static FORCE_INLINE int nlQlogSize(number n, const coeffs r)
only used by slimgb (tgb.cc)
Definition longrat.h:76
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
#define nSize(n)
Definition numbers.h:39
#define TEST_V_COEFSTRAT
Definition options.h:142

◆ length_one_crit()

static void length_one_crit ( slimgb_alg * c,
int pos,
int len )
static

Definition at line 968 of file tgb.cc.

969{
970 if(c->nc)
971 return;
972 if(len == 1)
973 {
974 int i;
975 for(i = 0; i < pos; i++)
976 {
977 if(c->lengths[i] == 1)
978 c->states[pos][i] = HASTREP;
979 }
980 for(i = pos + 1; i < c->n; i++)
981 {
982 if(c->lengths[i] == 1)
983 c->states[i][pos] = HASTREP;
984 }
985 if(!c->nc)
986 shorten_tails (c, c->S->m[pos]);
987 }
988}

◆ lenS_correct()

BOOLEAN lenS_correct ( kStrategy strat)

Definition at line 871 of file tgb.cc.

872{
873 int i;
874 for(i = 0; i <= strat->sl; i++)
875 {
876 if(strat->lenS[i] != pLength (strat->S[i]))
877 return FALSE;
878 }
879 return TRUE;
880}

◆ lies_in_last_dp_block()

static BOOLEAN lies_in_last_dp_block ( poly p,
slimgb_alg * c )
static

Definition at line 399 of file tgb.cc.

400{
401 ring r = c->r;
402 if(p_GetComp (p, r) != 0)
403 return FALSE;
404 if(c->lastDpBlockStart <= (currRing->N))
405 {
406 int i;
407 for(i = 1; i < c->lastDpBlockStart; i++)
408 {
409 if(p_GetExp (p, i, r) != 0)
410 {
411 break;
412 }
413 }
414 if(i >= c->lastDpBlockStart)
415 {
416 //wrp(p);
417 //PrintS("\n");
418 return TRUE;
419 }
420 else
421 return FALSE;
422 }
423 else
424 return FALSE;
425}

◆ line_of_extended_prod()

static void line_of_extended_prod ( int fixpos,
slimgb_alg * c )
static

Definition at line 1891 of file tgb.cc.

1892{
1893 if(c->gcd_of_terms[fixpos] == NULL)
1894 {
1895 c->gcd_of_terms[fixpos] = gcd_of_terms (c->S->m[fixpos], c->r);
1896 if(c->gcd_of_terms[fixpos])
1897 {
1898 int i;
1899 for(i = 0; i < fixpos; i++)
1900 if((c->states[fixpos][i] != HASTREP)
1901 &&
1903 (c->S->m[fixpos], c->gcd_of_terms[fixpos], c->S->m[i],
1904 c->gcd_of_terms[i], c)))
1905 {
1906 c->states[fixpos][i] = HASTREP;
1908 }
1909 for(i = fixpos + 1; i < c->n; i++)
1910 if((c->states[i][fixpos] != HASTREP)
1911 &&
1913 (c->S->m[fixpos], c->gcd_of_terms[fixpos], c->S->m[i],
1914 c->gcd_of_terms[i], c)))
1915 {
1916 c->states[i][fixpos] = HASTREP;
1918 }
1919 }
1920 }
1921}

◆ make_connections()

static int * make_connections ( int from,
int to,
poly bound,
slimgb_alg * c )
static

Definition at line 1064 of file tgb.cc.

1065{
1066 ideal I = c->S;
1067 int *cans = (int *) omAlloc (c->n * sizeof (int));
1068 int *connected = (int *) omAlloc (c->n * sizeof (int));
1069 cans[0] = to;
1070 int cans_length = 1;
1071 connected[0] = from;
1072 int last_cans_pos = -1;
1073 int connected_length = 1;
1074 long neg_bounds_short = ~p_GetShortExpVector (bound, c->r);
1075
1076 int not_yet_found = cans_length;
1077 int con_checked = 0;
1078 int pos;
1079
1080 while(TRUE)
1081 {
1082 if((con_checked < connected_length) && (not_yet_found > 0))
1083 {
1084 pos = connected[con_checked];
1085 for(int i = 0; i < cans_length; i++)
1086 {
1087 if(cans[i] < 0)
1088 continue;
1089 //FIXME: triv. syz. does not hold on noncommutative, check it for modules
1090 if((has_t_rep (pos, cans[i], c))
1091 || ((!rIsPluralRing (c->r))
1092 && (trivial_syzygie (pos, cans[i], bound, c))))
1093 {
1094 connected[connected_length] = cans[i];
1095 connected_length++;
1096 cans[i] = -1;
1097 --not_yet_found;
1098
1099 if(connected[connected_length - 1] == to)
1100 {
1101 if(connected_length < c->n)
1102 {
1103 connected[connected_length] = -1;
1104 }
1105 omFree (cans);
1106 return connected;
1107 }
1108 }
1109 }
1110 con_checked++;
1111 }
1112 else
1113 {
1114 for(last_cans_pos++; last_cans_pos <= c->n; last_cans_pos++)
1115 {
1116 if(last_cans_pos == c->n)
1117 {
1118 if(connected_length < c->n)
1119 {
1120 connected[connected_length] = -1;
1121 }
1122 omFree (cans);
1123 return connected;
1124 }
1125 if((last_cans_pos == from) || (last_cans_pos == to))
1126 continue;
1128 (I->m[last_cans_pos], c->short_Exps[last_cans_pos], bound,
1129 neg_bounds_short, c->r))
1130 {
1131 cans[cans_length] = last_cans_pos;
1132 cans_length++;
1133 break;
1134 }
1135 }
1136 not_yet_found++;
1137 for(int i = 0; i < con_checked; i++)
1138 {
1139 if(has_t_rep (connected[i], last_cans_pos, c))
1140 {
1141 connected[connected_length] = last_cans_pos;
1142 connected_length++;
1143 cans[cans_length - 1] = -1;
1144 --not_yet_found;
1145 if(connected[connected_length - 1] == to)
1146 {
1147 if(connected_length < c->n)
1148 {
1149 connected[connected_length] = -1;
1150 }
1151 omFree (cans);
1152 return connected;
1153 }
1154 break;
1155 }
1156 }
1157 }
1158 }
1159 if(connected_length < c->n)
1160 {
1161 connected[connected_length] = -1;
1162 }
1163 omFree (cans);
1164 return connected;
1165}
static CanonicalForm bound(const CFMatrix &M)
Definition cf_linsys.cc:460
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
static BOOLEAN trivial_syzygie(int pos1, int pos2, poly bound, slimgb_alg *c)
Definition tgb.cc:764

◆ mass_add()

static void mass_add ( poly * p,
int pn,
slimgb_alg * c )
static

Definition at line 2097 of file tgb.cc.

2098{
2099 int j;
2100 int *ibuf = (int *) omalloc (pn * sizeof (int));
2101 sorted_pair_node ***sbuf =
2102 (sorted_pair_node ***) omalloc (pn * sizeof (sorted_pair_node **));
2103 for(j = 0; j < pn; j++)
2104 {
2105 p_Test (p[j], c->r);
2106 sbuf[j] = add_to_basis_ideal_quotient (p[j], c, ibuf + j);
2107 }
2108 int sum = 0;
2109 for(j = 0; j < pn; j++)
2110 {
2111 sum += ibuf[j];
2112 }
2113 sorted_pair_node **big_sbuf =
2114 (sorted_pair_node **) omalloc (sum * sizeof (sorted_pair_node *));
2115 int partsum = 0;
2116 for(j = 0; j < pn; j++)
2117 {
2118 memmove (big_sbuf + partsum, sbuf[j],
2119 ibuf[j] * sizeof (sorted_pair_node *));
2120 omFree (sbuf[j]);
2121 partsum += ibuf[j];
2122 }
2123
2124 qsort (big_sbuf, sum, sizeof (sorted_pair_node *), tgb_pair_better_gen2);
2125 c->apairs = spn_merge (c->apairs, c->pair_top + 1, big_sbuf, sum, c);
2126 c->pair_top += sum;
2128 omfree (big_sbuf);
2129 omfree (sbuf);
2130 omfree (ibuf);
2131 //omfree(buf);
2132#ifdef TGB_DEBUG
2133 int z;
2134 for(z = 1; z <= c->pair_top; z++)
2135 {
2136 assume (pair_better (c->apairs[z], c->apairs[z - 1], c));
2137 }
2138#endif
2139
2140}
sorted_pair_node ** add_to_basis_ideal_quotient(poly h, slimgb_alg *c, int *ip)
Definition tgb.cc:1378
static BOOLEAN pair_better(sorted_pair_node *a, sorted_pair_node *b, slimgb_alg *c=NULL)
Definition tgb.cc:3972

◆ monomial_root()

static BOOLEAN monomial_root ( poly m,
ring r )
static

Definition at line 89 of file tgb.cc.

90{
91 BOOLEAN changed = FALSE;
92 int i;
93 for(i = 1; i <= rVar (r); i++)
94 {
95 int e = p_GetExp (m, i, r);
96 if(e > 1)
97 {
98 p_SetExp (m, i, 1, r);
99 changed = TRUE;
100 }
101 }
102 if(changed)
103 {
104 p_Setm (m, r);
105 }
106 return changed;
107}
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 short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598

◆ move_backward_in_S()

static void move_backward_in_S ( int old_pos,
int new_pos,
kStrategy strat )
static

Definition at line 1027 of file tgb.cc.

1028{
1029 assume (old_pos <= new_pos);
1030 poly p = strat->S[old_pos];
1031 int ecart = strat->ecartS[old_pos];
1032 long sev = strat->sevS[old_pos];
1033 int s_2_r = strat->S_2_R[old_pos];
1034 int length = strat->lenS[old_pos];
1035 assume (length == (int)pLength (strat->S[old_pos]));
1036 wlen_type length_w;
1037 if(strat->lenSw != NULL)
1038 length_w = strat->lenSw[old_pos];
1039 int i;
1040 for(i = old_pos; i < new_pos; i++)
1041 {
1042 strat->S[i] = strat->S[i + 1];
1043 strat->ecartS[i] = strat->ecartS[i + 1];
1044 strat->sevS[i] = strat->sevS[i + 1];
1045 strat->S_2_R[i] = strat->S_2_R[i + 1];
1046 }
1047 if(strat->lenS != NULL)
1048 for(i = old_pos; i < new_pos; i++)
1049 strat->lenS[i] = strat->lenS[i + 1];
1050 if(strat->lenSw != NULL)
1051 for(i = old_pos; i < new_pos; i++)
1052 strat->lenSw[i] = strat->lenSw[i + 1];
1053
1054 strat->S[new_pos] = p;
1055 strat->ecartS[new_pos] = ecart;
1056 strat->sevS[new_pos] = sev;
1057 strat->S_2_R[new_pos] = s_2_r;
1058 strat->lenS[new_pos] = length;
1059 if(strat->lenSw != NULL)
1060 strat->lenSw[new_pos] = length_w;
1061 //assume(lenS_correct(strat));
1062}
int * S_2_R
Definition kutil.h:343
intset ecartS
Definition kutil.h:310
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257

◆ move_forward_in_S()

static void move_forward_in_S ( int old_pos,
int new_pos,
kStrategy strat )
static

Definition at line 990 of file tgb.cc.

991{
992 assume (old_pos >= new_pos);
993 poly p = strat->S[old_pos];
994 int ecart = strat->ecartS[old_pos];
995 long sev = strat->sevS[old_pos];
996 int s_2_r = strat->S_2_R[old_pos];
997 int length = strat->lenS[old_pos];
998 assume (length == (int)pLength (strat->S[old_pos]));
999 wlen_type length_w;
1000 if(strat->lenSw != NULL)
1001 length_w = strat->lenSw[old_pos];
1002 int i;
1003 for(i = old_pos; i > new_pos; i--)
1004 {
1005 strat->S[i] = strat->S[i - 1];
1006 strat->ecartS[i] = strat->ecartS[i - 1];
1007 strat->sevS[i] = strat->sevS[i - 1];
1008 strat->S_2_R[i] = strat->S_2_R[i - 1];
1009 }
1010 if(strat->lenS != NULL)
1011 for(i = old_pos; i > new_pos; i--)
1012 strat->lenS[i] = strat->lenS[i - 1];
1013 if(strat->lenSw != NULL)
1014 for(i = old_pos; i > new_pos; i--)
1015 strat->lenSw[i] = strat->lenSw[i - 1];
1016
1017 strat->S[new_pos] = p;
1018 strat->ecartS[new_pos] = ecart;
1019 strat->sevS[new_pos] = sev;
1020 strat->S_2_R[new_pos] = s_2_r;
1021 strat->lenS[new_pos] = length;
1022 if(strat->lenSw != NULL)
1023 strat->lenSw[new_pos] = length_w;
1024 //assume(lenS_correct(strat));
1025}

◆ multi_reduce_step()

void multi_reduce_step ( find_erg & erg,
red_object * r,
slimgb_alg * c )
static

Definition at line 4946 of file tgb.cc.

4947{
4948 STATIC_VAR int id = 0;
4949 id++;
4950 unsigned long sev;
4951 BOOLEAN lt_changed = FALSE;
4952 int rn = erg.reduce_by;
4953 poly red;
4954 int red_len;
4955 simple_reducer *pointer;
4956 BOOLEAN work_on_copy = FALSE;
4957 if(erg.fromS)
4958 {
4959 red = c->strat->S[rn];
4960 red_len = c->strat->lenS[rn];
4961 assume (red_len == (int)pLength (red));
4962 }
4963 else
4964 {
4965 r[rn].flatten ();
4966 kBucketClear (r[rn].bucket, &red, &red_len);
4967
4969 {
4970 p_Cleardenom (red, c->r); //should be unnecessary
4971 //includes p_Content(red, c->r);
4972 }
4973 //pNormalize (red);
4974
4975 if((!(erg.fromS)) && (TEST_V_UPTORADICAL))
4976 {
4977 if(polynomial_root (red, c->r))
4978 lt_changed = TRUE;
4979 sev = p_GetShortExpVector (red, c->r);
4980 }
4981 red_len = pLength (red);
4982 }
4983 if(((TEST_V_MODPSOLVSB) && (red_len > 1))
4984 || ((c->nc) || (erg.to_reduce_u - erg.to_reduce_l > 5)))
4985 {
4986 work_on_copy = TRUE;
4987 // poly m=pOne();
4988 poly m = c->tmp_lm;
4989 pSetCoeff (m, nInit (1));
4990 pSetComp (m, 0);
4991 for(int i = 1; i <= (currRing->N); i++)
4992 pSetExp (m, i, (pGetExp (r[erg.to_reduce_l].p, i) - pGetExp (red, i)));
4993 pSetm (m);
4994 poly red_cp;
4995#ifdef HAVE_PLURAL
4996 if(c->nc)
4997 red_cp = nc_mm_Mult_pp (m, red, c->r);
4998 else
4999#endif
5000 red_cp = ppMult_mm (red, m);
5001 if(!erg.fromS)
5002 {
5003 kBucketInit (r[rn].bucket, red, red_len);
5004 }
5005 //now reduce the copy
5006 //static poly redNF2 (poly h,slimgb_alg* c , int &len, number& m,int n)
5007
5008 if(!c->nc)
5009 redTailShort (red_cp, c->strat);
5010 //number mul;
5011 // red_len--;
5012// red_cp->next=redNF2(red_cp->next,c,red_len,mul,c->average_length);
5013// pSetCoeff(red_cp,nMult(red_cp->coef,mul));
5014// nDelete(&mul);
5015// red_len++;
5016 red = red_cp;
5017 red_len = pLength (red);
5018 // pDelete(&m);
5019 }
5020
5021 assume (red_len == (int)pLength (red));
5022
5023 int reducer_deg = 0;
5024 if(c->eliminationProblem)
5025 {
5026 int lm_deg = c->pTotaldegree (r[erg.to_reduce_l].p);
5027 int ecart;
5028 if(erg.fromS)
5029 {
5030 ecart = c->strat->ecartS[erg.reduce_by];
5031 }
5032 else
5033 {
5034 ecart = c->pTotaldegree_full (red) - lm_deg;
5035 }
5036 reducer_deg = lm_deg + ecart;
5037 }
5038 pointer = new simple_reducer (red, red_len, reducer_deg, c);
5039
5040 if((!work_on_copy) && (!erg.fromS))
5041 pointer->fill_back = r[rn].bucket;
5042 else
5043 pointer->fill_back = NULL;
5044 pointer->reduction_id = id;
5045 pointer->c = c;
5046
5047 pointer->reduce (r, erg.to_reduce_l, erg.to_reduce_u);
5048 if(work_on_copy)
5049 pDelete (&pointer->p);
5050 delete pointer;
5051 if(lt_changed)
5052 {
5053 assume (!erg.fromS);
5054 r[erg.reduce_by].sev = sev;
5055 }
5056}
void flatten()
Definition tgb.cc:4873
kBucket_pt bucket
slimgb_alg * c
kBucket_pt fill_back
virtual void reduce(red_object *r, int l, int u)
we assume that all occurring red_objects have same lm, and all occ. lm's in r[l......
Definition tgb.cc:4909
BOOLEAN eliminationProblem
#define STATIC_VAR
Definition globaldefs.h:7
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition nc.h:224
#define nInit(i)
Definition numbers.h:24
#define TEST_V_MODPSOLVSB
Definition options.h:141
#define ppMult_mm(p, m)
Definition polys.h:202
#define pSetComp(p, v)
Definition polys.h:39
static BOOLEAN polynomial_root(poly h, ring r)
Definition tgb.cc:109
BOOLEAN fromS
int to_reduce_u
int to_reduce_l

◆ multi_reduction()

static void multi_reduction ( red_object * los,
int & losl,
slimgb_alg * c )
static

Definition at line 4689 of file tgb.cc.

4690{
4691 poly *delay = (poly *) omAlloc (losl * sizeof (poly));
4692 int delay_s = 0;
4693 //initialize;
4694 assume (c->strat->sl >= 0);
4695 assume (losl > 0);
4696 int i;
4697 wlen_type max_initial_quality = 0;
4698
4699 for(i = 0; i < losl; i++)
4700 {
4701 //los[i].sev = pGetShortExpVector (los[i].p);
4702 los[i].p = kBucketGetLm (los[i].bucket);
4703 if(los[i].initial_quality > max_initial_quality)
4704 max_initial_quality = los[i].initial_quality;
4705 // else
4706// Print("init2_qal=%lld;", los[i].initial_quality);
4707// Print("initial_quality=%lld;",max_initial_quality);
4708 }
4709
4710 int curr_pos = losl - 1;
4711
4712// nicht reduzierbare eintrage in ergnisliste schreiben
4713 // nullen loeschen
4714 while(curr_pos >= 0)
4715 {
4716 if((c->use_noro_last_block)
4717 && (lies_in_last_dp_block (los[curr_pos].p, c)))
4718 {
4719 int pn_noro = curr_pos + 1;
4720 poly *p_noro = (poly *) omAlloc (pn_noro * sizeof (poly));
4721 for(i = 0; i < pn_noro; i++)
4722 {
4723 int dummy_len;
4724 poly p;
4725 los[i].p = NULL;
4726 kBucketClear (los[i].bucket, &p, &dummy_len);
4727 p_noro[i] = p;
4728 }
4729 if(n_GetChar(currRing->cf) < 255)
4730 {
4731 noro_step < tgb_uint8 > (p_noro, pn_noro, c);
4732 }
4733 else
4734 {
4735 if(n_GetChar(currRing->cf) < 65000)
4736 {
4737 noro_step < tgb_uint16 > (p_noro, pn_noro, c);
4738 }
4739 else
4740 {
4741 noro_step < tgb_uint32 > (p_noro, pn_noro, c);
4742 }
4743 }
4744 for(i = 0; i < pn_noro; i++)
4745 {
4746 los[i].p = p_noro[i];
4747 los[i].sev = pGetShortExpVector (los[i].p);
4748 //ignore quality
4749 kBucketInit (los[i].bucket, los[i].p, pLength (los[i].p));
4750 }
4751 qsort (los, pn_noro, sizeof (red_object), red_object_better_gen);
4752 int deleted =
4753 multi_reduction_clear_zeroes (los, losl, pn_noro, curr_pos, c->syz_comp);
4754 losl -= deleted;
4755 curr_pos -= deleted;
4756 break;
4757 }
4758 find_erg erg;
4759
4760 multi_reduction_find (los, losl, c, curr_pos, erg); //last argument should be curr_pos
4761 if(erg.reduce_by < 0)
4762 break;
4763
4764 erg.expand = NULL;
4765
4766 multi_reduction_lls_trick (los, losl, c, erg);
4767
4768 int i;
4769 // wrp(los[erg.to_reduce_u].p);
4770 //PrintLn();
4771 multi_reduce_step (erg, los, c);
4772
4773
4775 {
4776 for(i = erg.to_reduce_l; i <= erg.to_reduce_u; i++)
4777 {
4778 if(los[i].p != NULL) //the check (los[i].p!=NULL) might be invalid
4779 {
4780 //
4781 assume (los[i].initial_quality > 0);
4782 if(los[i].guess_quality (c)
4783 > 1.5 * delay_factor * max_initial_quality)
4784 {
4785 if(TEST_OPT_PROT)
4786 PrintS ("v");
4787 los[i].canonicalize ();
4788 if(los[i].guess_quality (c) > delay_factor * max_initial_quality)
4789 {
4790 if(TEST_OPT_PROT)
4791 PrintS (".");
4792 los[i].clear_to_poly ();
4793 //delay.push_back(los[i].p);
4794 delay[delay_s] = los[i].p;
4795 delay_s++;
4796 los[i].p = NULL;
4797 }
4798 }
4799 }
4800 }
4801 }
4802 int deleted = multi_reduction_clear_zeroes (los, losl, erg.to_reduce_l,
4803 erg.to_reduce_u, c->syz_comp);
4804 if(erg.fromS == FALSE)
4805 curr_pos = si_max (erg.to_reduce_u, erg.reduce_by);
4806 else
4807 curr_pos = erg.to_reduce_u;
4808 losl -= deleted;
4809 curr_pos -= deleted;
4810
4811 //Print("deleted %i \n",deleted);
4812 if((TEST_V_UPTORADICAL) && (!(erg.fromS)))
4814 (si_max (erg.to_reduce_u, erg.reduce_by)) - deleted,
4815 c);
4816 else
4817 sort_region_down (los, erg.to_reduce_l, erg.to_reduce_u - deleted, c);
4818
4819 if(erg.expand)
4820 {
4821#ifdef FIND_DETERMINISTIC
4822 int i;
4823 for(i = 0; c->expandS[i]; i++) ;
4824 c->expandS = (poly *) omreallocSize (c->expandS, (i+1)*sizeof(poly),
4825 (i+2)*sizeof(poly));
4826 c->expandS[i] = erg.expand;
4827 c->expandS[i + 1] = NULL;
4828#else
4829 int ecart = 0;
4830 if(c->eliminationProblem)
4831 {
4832 ecart =
4833 c->pTotaldegree_full (erg.expand) - c->pTotaldegree (erg.expand);
4834 }
4835 add_to_reductors (c, erg.expand, erg.expand_length, ecart);
4836#endif
4837 }
4838 }
4839
4840 c->introduceDelayedPairs (delay, delay_s);
4841 /*
4842 sorted_pair_node** pairs=(sorted_pair_node**)
4843 omalloc(delay_s*sizeof(sorted_pair_node*));
4844 for(i=0;i<delay_s;i++)
4845 {
4846 poly p=delay[i];
4847 //if (rPar(c->r)==0)
4848 simplify_poly(p,c->r);
4849 sorted_pair_node* si=(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
4850 si->i=-1;
4851 si->j=-1;
4852 if (!rField_is_Zp(c->r))
4853 {
4854 if (!c->nc)
4855 p=redTailShort(p, c->strat);
4856 p_Cleardenom(p, c->r);
4857 p_Content(p, c->r);
4858 }
4859 si->expected_length=pQuality(p,c,pLength(p));
4860 si->deg=pTotaldegree(p);
4861 si->lcm_of_lm=p;
4862 pairs[i]=si;
4863 }
4864 qsort(pairs,delay_s,sizeof(sorted_pair_node*),tgb_pair_better_gen2);
4865 c->apairs=spn_merge(c->apairs,c->pair_top+1,pairs,delay_s,c);
4866 c->pair_top+=delay_s;
4867 omfree(pairs);
4868 */
4869 omFree (delay);
4870 return;
4871}
wlen_type initial_quality
int clear_to_poly()
Definition tgb.cc:4885
void canonicalize()
Definition tgb.cc:835
poly * expandS
#define TEST_OPT_REDTHROUGH
Definition options.h:124
static int multi_reduction_clear_zeroes(red_object *los, int losl, int l, int u, int syzComp)
Definition tgb.cc:4579
static void sort_region_down(red_object *los, int l, int u, slimgb_alg *)
Definition tgb.cc:4633
static const int delay_factor
Definition tgb.cc:38
static void multi_reduction_find(red_object *los, int, slimgb_alg *c, int startf, find_erg &erg)
Definition tgb.cc:4505
static void multi_reduce_step(find_erg &erg, red_object *r, slimgb_alg *c)
Definition tgb.cc:4946
static void multi_reduction_lls_trick(red_object *los, int, slimgb_alg *c, find_erg &erg)
Definition tgb.cc:4175
int expand_length

◆ multi_reduction_clear_zeroes()

static int multi_reduction_clear_zeroes ( red_object * los,
int losl,
int l,
int u,
int syzComp )
static

Definition at line 4579 of file tgb.cc.

4580{
4581 int deleted = 0;
4582 int i = l;
4583 int last = -1;
4584 while(i <= u)
4585 {
4586 if((los[i].p == NULL)
4587 || (TEST_OPT_IDLIFT && (p_GetComp(los[i].p,currRing) > syzComp)))
4588 {
4589 kBucketDeleteAndDestroy (&los[i].bucket);
4590// delete los[i];//here we assume los are constructed with new
4591 //destroy resources, must be added here
4592 if(last >= 0)
4593 {
4594 memmove (los + (int) (last + 1 - deleted), los + (last + 1),
4595 sizeof (red_object) * (i - 1 - last));
4596 }
4597 last = i;
4598 deleted++;
4599 }
4600 i++;
4601 }
4602 if((last >= 0) && (last != losl - 1))
4603 memmove (los + (int) (last + 1 - deleted), los + last + 1,
4604 sizeof (red_object) * (losl - 1 - last));
4605 return deleted;
4606}
STATIC_VAR poly last
Definition hdegree.cc:1137
void kBucketDeleteAndDestroy(kBucket_pt *bucket_pt)
Definition kbuckets.cc:223

◆ multi_reduction_find()

static void multi_reduction_find ( red_object * los,
int ,
slimgb_alg * c,
int startf,
find_erg & erg )
static

Definition at line 4505 of file tgb.cc.

4512{
4513 kStrategy strat = c->strat;
4514
4515 #ifndef SING_NDEBUG
4516 assume (startf <= losl);
4517 assume ((startf == losl - 1)
4518 || (pLmCmp (los[startf].p, los[startf + 1].p) == -1));
4519 #endif
4520 int i = startf;
4521
4522 int j;
4523 while(i >= 0)
4524 {
4525 #ifndef SING_NDEBUG
4526 assume ((i == losl - 1) || (pLmCmp (los[i].p, los[i + 1].p) <= 0));
4527 #endif
4528 assume (is_valid_ro (los[i]));
4529 j = kFindDivisibleByInS_easy (strat, los[i]);
4530 if(j >= 0)
4531 {
4532 erg.to_reduce_u = i;
4533 erg.reduce_by = j;
4534 erg.fromS = TRUE;
4535 int i2 = fwbw (los, i);
4536 assume (pLmEqual (los[i].p, los[i2].p));
4537 assume ((i2 == 0) || (!pLmEqual (los[i2].p, los[i2 - 1].p)));
4538 assume (i >= i2);
4539
4540 erg.to_reduce_l = i2;
4541 #ifndef SING_NDEBUG
4542 assume ((i == losl - 1) || (pLmCmp (los[i].p, los[i + 1].p) == -1));
4543 #endif
4544 canonicalize_region (los, erg.to_reduce_u + 1, startf, c);
4545 return;
4546 }
4547 else /*if(j < 0)*/
4548 {
4549 //not reduceable, try to use this for reducing higher terms
4550 int i2 = fwbw (los, i);
4551 assume (pLmEqual (los[i].p, los[i2].p));
4552 assume ((i2 == 0) || (!pLmEqual (los[i2].p, los[i2 - 1].p)));
4553 assume (i >= i2);
4554 if(i2 != i)
4555 {
4556 erg.to_reduce_u = i - 1;
4557 erg.to_reduce_l = i2;
4558 erg.reduce_by = i;
4559 erg.fromS = FALSE;
4560 #ifndef SING_NDEBUG
4561 assume ((i == losl - 1) || (pLmCmp (los[i].p, los[i + 1].p) == -1));
4562 #endif
4563 canonicalize_region (los, erg.to_reduce_u + 1, startf, c);
4564 return;
4565 }
4566 i--;
4567 }
4568 }
4569 erg.reduce_by = -1; //error code
4570 return;
4571}
skStrategy * kStrategy
Definition structs.h:54
static int fwbw(red_object *los, int i)
Definition tgb.cc:4435
BOOLEAN is_valid_ro(red_object &ro)
Definition tgb.cc:1973
static void canonicalize_region(red_object *los, int l, int u, slimgb_alg *)
Definition tgb.cc:4493

◆ multi_reduction_lls_trick()

static void multi_reduction_lls_trick ( red_object * los,
int ,
slimgb_alg * c,
find_erg & erg )
static

Definition at line 4175 of file tgb.cc.

4177{
4178 erg.expand = NULL;
4179 BOOLEAN swap_roles; //from reduce_by, to_reduce_u if fromS
4180 if(erg.fromS)
4181 {
4182 if(pLmEqual (c->strat->S[erg.reduce_by], los[erg.to_reduce_u].p))
4183 {
4184 wlen_type quality_a = quality_of_pos_in_strat_S (erg.reduce_by, c);
4185 int best = erg.to_reduce_u + 1;
4186/*
4187 for (i=erg.to_reduce_u;i>=erg.to_reduce_l;i--)
4188 {
4189 int qc=los[i].guess_quality(c);
4190 if (qc<quality_a)
4191 {
4192 best=i;
4193 quality_a=qc;
4194 }
4195 }
4196 if(best!=erg.to_reduce_u+1)
4197 {*/
4198 wlen_type qc;
4199 best = find_best (los, erg.to_reduce_l, erg.to_reduce_u, qc, c);
4200 if(qc < quality_a)
4201 {
4202 los[best].flatten ();
4203 int b_pos = kBucketCanonicalize (los[best].bucket);
4204 los[best].p = los[best].bucket->buckets[b_pos];
4205 qc = pQuality (los[best].bucket->buckets[b_pos], c);
4206 if(qc < quality_a)
4207 {
4208 red_object h = los[erg.to_reduce_u];
4209 los[erg.to_reduce_u] = los[best];
4210 los[best] = h;
4211 swap_roles = TRUE;
4212 }
4213 else
4214 swap_roles = FALSE;
4215 }
4216 else
4217 {
4218 swap_roles = FALSE;
4219 }
4220 }
4221 else
4222 {
4223 if(erg.to_reduce_u > erg.to_reduce_l)
4224 {
4225 wlen_type quality_a = quality_of_pos_in_strat_S (erg.reduce_by, c);
4226#ifdef HAVE_PLURAL
4227 if((c->nc) && (!(rIsSCA (c->r))))
4228 quality_a =
4230 los[erg.to_reduce_u].p, c);
4231#endif
4232 int best = erg.to_reduce_u + 1;
4233 wlen_type qc;
4234 best = find_best (los, erg.to_reduce_l, erg.to_reduce_u, qc, c);
4235 assume (qc == los[best].guess_quality (c));
4236 if(qc < quality_a)
4237 {
4238 los[best].flatten ();
4239 int b_pos = kBucketCanonicalize (los[best].bucket);
4240 los[best].p = los[best].bucket->buckets[b_pos];
4241 qc = pQuality (los[best].bucket->buckets[b_pos], c);
4242 //(best!=erg.to_reduce_u+1)
4243 if(qc < quality_a)
4244 {
4245 red_object h = los[erg.to_reduce_u];
4246 los[erg.to_reduce_u] = los[best];
4247 los[best] = h;
4248 erg.reduce_by = erg.to_reduce_u;
4249 erg.fromS = FALSE;
4250 erg.to_reduce_u--;
4251 }
4252 }
4253 }
4254 else
4255 {
4256 assume (erg.to_reduce_u == erg.to_reduce_l);
4257 wlen_type quality_a = quality_of_pos_in_strat_S (erg.reduce_by, c);
4258 wlen_type qc = los[erg.to_reduce_u].guess_quality (c);
4259 if(qc < 0)
4260 PrintS ("Wrong wlen_type");
4261 if(qc < quality_a)
4262 {
4263 int best = erg.to_reduce_u;
4264 los[best].flatten ();
4265 int b_pos = kBucketCanonicalize (los[best].bucket);
4266 los[best].p = los[best].bucket->buckets[b_pos];
4267 qc = pQuality (los[best].bucket->buckets[b_pos], c);
4268 assume (qc >= 0);
4269 if(qc < quality_a)
4270 {
4271 BOOLEAN exp = FALSE;
4272 if(qc <= 2)
4273 {
4274 //Print("\n qc is %lld \n",qc);
4275 exp = TRUE;
4276 }
4277 else
4278 {
4279 if(qc < quality_a / 2)
4280 exp = TRUE;
4281 else if(erg.reduce_by < c->n / 4)
4282 exp = TRUE;
4283 }
4284 if(exp)
4285 {
4286 poly clear_into;
4287 los[erg.to_reduce_u].flatten ();
4288 kBucketClear (los[erg.to_reduce_u].bucket, &clear_into,
4289 &erg.expand_length);
4290 erg.expand = pCopy (clear_into);
4291 kBucketInit (los[erg.to_reduce_u].bucket, clear_into,
4292 erg.expand_length);
4293 if(TEST_OPT_PROT)
4294 PrintS ("e");
4295 }
4296 }
4297 }
4298 }
4299
4300 swap_roles = FALSE;
4301 return;
4302 }
4303 }
4304 else
4305 {
4306 if(erg.reduce_by > erg.to_reduce_u)
4307 {
4308 //then lm(rb)>= lm(tru) so =
4309 assume (erg.reduce_by == erg.to_reduce_u + 1);
4310 int best = erg.reduce_by;
4311 wlen_type quality_a = los[erg.reduce_by].guess_quality (c);
4312 wlen_type qc;
4313 best = find_best (los, erg.to_reduce_l, erg.to_reduce_u, qc, c);
4314
4315 if(qc < quality_a)
4316 {
4317 red_object h = los[erg.reduce_by];
4318 los[erg.reduce_by] = los[best];
4319 los[best] = h;
4320 }
4321 swap_roles = FALSE;
4322 return;
4323 }
4324 else
4325 {
4326 assume (!pLmEqual (los[erg.reduce_by].p, los[erg.to_reduce_l].p));
4327 assume (erg.to_reduce_u == erg.to_reduce_l);
4328 //further assume, that reduce_by is the above all other polys
4329 //with same leading term
4330 int il = erg.reduce_by;
4331 wlen_type quality_a = los[erg.reduce_by].guess_quality (c);
4332 wlen_type qc;
4333 while((il > 0) && pLmEqual (los[il - 1].p, los[il].p))
4334 {
4335 il--;
4336 qc = los[il].guess_quality (c);
4337 if(qc < quality_a)
4338 {
4339 quality_a = qc;
4340 erg.reduce_by = il;
4341 }
4342 }
4343 swap_roles = FALSE;
4344 }
4345 }
4346 if(swap_roles)
4347 {
4348 if(TEST_OPT_PROT)
4349 PrintS ("b");
4350 poly clear_into;
4351 int new_length;
4352 int bp = erg.to_reduce_u; //bucket_positon
4353 //kBucketClear(los[bp].bucket,&clear_into,&new_length);
4354 new_length = los[bp].clear_to_poly ();
4355 clear_into = los[bp].p;
4356 poly p = c->strat->S[erg.reduce_by];
4357 int j = erg.reduce_by;
4358 int old_length = c->strat->lenS[j]; // in view of S
4359 los[bp].p = p;
4360 kBucketInit (los[bp].bucket, p, old_length);
4361 wlen_type qal = pQuality (clear_into, c, new_length);
4362 int pos_in_c = -1;
4363 int z;
4364 int new_pos;
4365 new_pos = simple_posInS (c->strat, clear_into, new_length, qal);
4366 assume (new_pos <= j);
4367 for(z = c->n; z; z--)
4368 {
4369 if(p == c->S->m[z - 1])
4370 {
4371 pos_in_c = z - 1;
4372 break;
4373 }
4374 }
4375
4376 int tdeg_full = -1;
4377 int tdeg = -1;
4378 if(pos_in_c >= 0)
4379 {
4380#ifdef TGB_RESORT_PAIRS
4381 c->used_b = TRUE;
4382 c->replaced[pos_in_c] = TRUE;
4383#endif
4384 tdeg = c->T_deg[pos_in_c];
4385 c->S->m[pos_in_c] = clear_into;
4386 c->lengths[pos_in_c] = new_length;
4387 c->weighted_lengths[pos_in_c] = qal;
4388 if(c->gcd_of_terms[pos_in_c] == NULL)
4389 c->gcd_of_terms[pos_in_c] = gcd_of_terms (clear_into, c->r);
4390 if(c->T_deg_full)
4391 tdeg_full = c->T_deg_full[pos_in_c] =
4392 c->pTotaldegree_full (clear_into);
4393 else
4394 tdeg_full = tdeg;
4395 c_S_element_changed_hook (pos_in_c, c);
4396 }
4397 else
4398 {
4399 if(c->eliminationProblem)
4400 {
4401 tdeg_full = c->pTotaldegree_full (clear_into);
4402 tdeg = c->pTotaldegree (clear_into);
4403 }
4404 }
4405 c->strat->S[j] = clear_into;
4406 c->strat->lenS[j] = new_length;
4407
4408 assume ((int)pLength (clear_into) == new_length);
4409 if(c->strat->lenSw != NULL)
4410 c->strat->lenSw[j] = qal;
4412 {
4413 p_Cleardenom (clear_into, c->r); //should be unnecessary
4414 //includes p_Content(clear_into, c->r);
4415 }
4416 else
4417 pNorm (clear_into);
4418#ifdef FIND_DETERMINISTIC
4419 erg.reduce_by = j;
4420 //resort later see diploma thesis, find_in_S must be deterministic
4421 //during multireduction if spolys are only in the span of the
4422 //input polys
4423#else
4424 if(new_pos < j)
4425 {
4426 if(c->strat->honey)
4427 c->strat->ecartS[j] = tdeg_full - tdeg;
4428 move_forward_in_S (j, new_pos, c->strat);
4429 erg.reduce_by = new_pos;
4430 }
4431#endif
4432 }
4433}
char honey
Definition kutil.h:376
gmp_float exp(const gmp_float &a)
static void move_forward_in_S(int old_pos, int new_pos, kStrategy strat)
Definition tgb.cc:990
int find_best(red_object *r, int l, int u, wlen_type &w, slimgb_alg *c)
returns position sets w as weight
Definition tgb.cc:818
static wlen_type quality_of_pos_in_strat_S(int pos, slimgb_alg *c)
Definition tgb.cc:4152
static void c_S_element_changed_hook(int pos, slimgb_alg *c)
Definition tgb.cc:1923
static wlen_type quality_of_pos_in_strat_S_mult_high(int pos, poly high, slimgb_alg *c)
Definition tgb.cc:4161
int tdeg(poly p)

◆ now_t_rep()

void now_t_rep ( const int & arg_i,
const int & arg_j,
slimgb_alg * c )

Definition at line 3684 of file tgb.cc.

3685{
3686 int i, j;
3687 if(arg_i == arg_j)
3688 {
3689 return;
3690 }
3691 if(arg_i > arg_j)
3692 {
3693 i = arg_j;
3694 j = arg_i;
3695 }
3696 else
3697 {
3698 i = arg_i;
3699 j = arg_j;
3700 }
3701 c->states[j][i] = HASTREP;
3702}

◆ p_Init_Special()

static poly p_Init_Special ( const ring r)
inlinestatic

Definition at line 137 of file tgb.cc.

138{
139 return p_Init (r, lm_bin);
140}
STATIC_VAR omBin lm_bin
Definition fast_mult.cc:429
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1336

◆ pair_better()

static BOOLEAN pair_better ( sorted_pair_node * a,
sorted_pair_node * b,
slimgb_alg * c = NULL )
static

Definition at line 3972 of file tgb.cc.

3973{
3974 if(a->deg < b->deg)
3975 return TRUE;
3976 if(a->deg > b->deg)
3977 return FALSE;
3978
3979 int comp = pLmCmp (a->lcm_of_lm, b->lcm_of_lm);
3980 if(comp == 1)
3981 return FALSE;
3982 if(-1 == comp)
3983 return TRUE;
3984 if(a->expected_length < b->expected_length)
3985 return TRUE;
3986 if(a->expected_length > b->expected_length)
3987 return FALSE;
3988 if(a->i + a->j < b->i + b->j)
3989 return TRUE;
3990 if(a->i + a->j > b->i + b->j)
3991 return FALSE;
3992 if(a->i < b->i)
3993 return TRUE;
3994 if(a->i > b->i)
3995 return FALSE;
3996 return TRUE;
3997}

◆ pair_weighted_length()

static wlen_type pair_weighted_length ( int i,
int j,
slimgb_alg * c )
static

Definition at line 1325 of file tgb.cc.

1326{
1327 if((c->isDifficultField) && (c->eliminationProblem))
1328 {
1329 int c1 = slim_nsize (p_GetCoeff (c->S->m[i], c->r), c->r);
1330 int c2 = slim_nsize (p_GetCoeff (c->S->m[j], c->r), c->r);
1331 wlen_type el1 = c->weighted_lengths[i] / c1;
1332 assume (el1 != 0);
1333 assume (c->weighted_lengths[i] % c1 == 0);
1334 wlen_type el2 = c->weighted_lengths[j] / c2;
1335 assume (el2 != 0);
1336 //assume (c->weighted_lengths[j] % c2 == 0); // fails in Tst/Plural/dmod_lib.tst
1337 //should be * for function fields
1338 //return (c1+c2) * (el1+el2-2);
1339 wlen_type res = coeff_mult_size_estimate (c1, c2, c->r);
1340 res *= el1 + el2 - 2;
1341 return res;
1342
1343 }
1344 if(c->isDifficultField)
1345 {
1346 //int cs=slim_nsize(p_GetCoeff(c->S->m[i],c->r),c->r)+
1347 // slim_nsize(p_GetCoeff(c->S->m[j],c->r),c->r);
1348 if(!(TEST_V_COEFSTRAT))
1349 {
1350 wlen_type cs =
1352 (p_GetCoeff (c->S->m[i], c->r), c->r),
1353 slim_nsize (p_GetCoeff (c->S->m[j], c->r),
1354 c->r), c->r);
1355 return (wlen_type) (c->lengths[i] + c->lengths[j] - 2) * (wlen_type) cs;
1356 }
1357 else
1358 {
1359
1360 wlen_type cs =
1362 (p_GetCoeff (c->S->m[i], c->r), c->r),
1363 slim_nsize (p_GetCoeff (c->S->m[j], c->r),
1364 c->r), c->r);
1365 cs *= cs;
1366 return (wlen_type) (c->lengths[i] + c->lengths[j] - 2) * (wlen_type) cs;
1367 }
1368 }
1369 if(c->eliminationProblem)
1370 {
1371
1372 return (c->weighted_lengths[i] + c->weighted_lengths[j] - 2);
1373 }
1374 return c->lengths[i] + c->lengths[j] - 2;
1375
1376}
BOOLEAN isDifficultField
#define p_GetCoeff(p, r)
Definition monomials.h:50
static wlen_type coeff_mult_size_estimate(int s1, int s2, ring r)
Definition tgb.cc:1317
int slim_nsize(number n, ring r)
Definition tgb.cc:73

◆ pELength()

static int pELength ( poly p,
slimgb_alg * c,
int l )
inlinestatic

Definition at line 512 of file tgb.cc.

513{
514 if(p == NULL)
515 return 0;
516 if((l > 0) && (elength_is_normal_length (p, c)))
517 return l;
518 return do_pELength (p, c);
519}

◆ pHasNotCFExtended()

static BOOLEAN pHasNotCFExtended ( poly p1,
poly p2,
poly m )
inlinestatic

Definition at line 4071 of file tgb.cc.

4072{
4073
4074 if(pGetComp (p1) > 0 || pGetComp (p2) > 0)
4075 return FALSE;
4076 int i = 1;
4077 loop
4078 {
4079 if((pGetExp (p1, i) - pGetExp (m, i) > 0)
4080 && (pGetExp (p2, i) - pGetExp (m, i) > 0))
4081 return FALSE;
4082 if(i == (currRing->N))
4083 return TRUE;
4084 i++;
4085 }
4086}
#define loop
Definition structs.h:71

◆ poly_crit()

static int poly_crit ( const void * ap1,
const void * ap2 )
static

Definition at line 3148 of file tgb.cc.

3149{
3150 poly p1, p2;
3151 p1 = *((poly *) ap1);
3152 p2 = *((poly *) ap2);
3153
3154 int c = pLmCmp (p1, p2);
3155 if(c != 0)
3156 return c;
3157 int l1 = pLength (p1);
3158 int l2 = pLength (p2);
3159 if(l1 < l2)
3160 return -1;
3161 if(l1 > l2)
3162 return 1;
3163 return 0;
3164}

◆ polynomial_root()

static BOOLEAN polynomial_root ( poly h,
ring r )
static

Definition at line 109 of file tgb.cc.

110{
111 poly got = gcd_of_terms (h, r);
112 BOOLEAN changed = FALSE;
113 if((got != NULL) && (TEST_V_UPTORADICAL))
114 {
115 poly copy = p_Copy (got, r);
116 //p_wrp(got,c->r);
117 changed = monomial_root (got, r);
118 if(changed)
119 {
120 poly div_by = pMDivide (copy, got);
121 poly iter = h;
122 while(iter)
123 {
124 pExpVectorSub (iter, div_by);
125 pIter (iter);
126 }
127 p_Delete (&div_by, r);
128 if(TEST_OPT_PROT)
129 PrintS ("U");
130 }
131 p_Delete (&copy, r);
132 }
133 p_Delete (&got, r);
134 return changed;
135}

◆ pOne_Special()

static poly pOne_Special ( const ring r = currRing)
inlinestatic

Definition at line 142 of file tgb.cc.

143{
144 poly rc = p_Init_Special (r);
145 pSetCoeff0 (rc, n_Init (1, r->cf));
146 return rc;
147}
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
#define pSetCoeff0(p, n)
Definition monomials.h:59
static poly p_Init_Special(const ring r)
Definition tgb.cc:137

◆ posInPairs()

static int posInPairs ( sorted_pair_node ** p,
int pn,
sorted_pair_node * qe,
slimgb_alg * c,
int an = 0 )
static

Definition at line 676 of file tgb.cc.

678{
679 if(pn == 0)
680 return 0;
681
682 int length = pn - 1;
683 int i;
684 //int an = 0;
685 int en = length;
686
687 if(pair_better (qe, p[en], c))
688 return length + 1;
689
690 while(1)
691 {
692 //if (an >= en-1)
693 if(en - 1 <= an)
694 {
695 if(pair_better (p[an], qe, c))
696 return an;
697 return en;
698 }
699 i = (an + en) / 2;
700 if(pair_better (p[i], qe, c))
701 en = i;
702 else
703 an = i;
704 }
705}

◆ pQuality()

static wlen_type pQuality ( poly p,
slimgb_alg * c,
int l = -1 )
inlinestatic

Definition at line 521 of file tgb.cc.

522{
523 if(l < 0)
524 l = pLength (p);
525 if(c->isDifficultField)
526 {
527 if(c->eliminationProblem)
528 {
529 wlen_type cs;
530 number coef = pGetCoeff (p);
532 {
533 cs = nlQlogSize (coef, currRing->cf);
534 }
535 else
536 cs = nSize (coef);
537 wlen_type erg = cs;
539 erg *= cs;
540 //erg*=cs;//for quadratic
541 erg *= pELength (p, c, l);
542 //FIXME: not quadratic coeff size
543 //return cs*pELength(p,c,l);
544 return erg;
545 }
546 //PrintS("I am here");
547 wlen_type r = pSLength (p, l);
548 assume (r >= 0);
549 return r;
550 }
551 if(c->eliminationProblem)
552 return pELength (p, c, l);
553 return l;
554}
static int pELength(poly p, slimgb_alg *c, int l)
Definition tgb.cc:512
static wlen_type pSLength(poly p, int l)
Definition tgb.cc:197

◆ pSLength()

static wlen_type pSLength ( poly p,
int l )
inlinestatic

Definition at line 197 of file tgb.cc.

198{
199 wlen_type c;
200 number coef = pGetCoeff (p);
202 {
203 c = nlQlogSize (coef, currRing->cf);
204 }
205 else
206 c = nSize (coef);
207 if(!(TEST_V_COEFSTRAT))
208 {
209 return (wlen_type) c *(wlen_type) l /*pLength(p) */ ;
210 }
211 else
212 {
213 wlen_type res = l;
214 res *= c;
215 res *= c;
216 return res;
217 }
218}

◆ quality_of_pos_in_strat_S()

static wlen_type quality_of_pos_in_strat_S ( int pos,
slimgb_alg * c )
inlinestatic

Definition at line 4152 of file tgb.cc.

4153{
4154 if(c->strat->lenSw != NULL)
4155 return c->strat->lenSw[pos];
4156 return c->strat->lenS[pos];
4157}

◆ quality_of_pos_in_strat_S_mult_high()

static wlen_type quality_of_pos_in_strat_S_mult_high ( int pos,
poly high,
slimgb_alg * c )
inlinestatic

Definition at line 4161 of file tgb.cc.

4163{
4164 poly m = pOne ();
4165 pExpVectorDiff (m, high, c->strat->S[pos]);
4166 poly product = nc_mm_Mult_pp (m, c->strat->S[pos], c->r);
4167 wlen_type erg = pQuality (product, c);
4168 pDelete (&m);
4169 pDelete (&product);
4170 return erg;
4171}
#define pExpVectorDiff(pr, p1, p2)
Definition polys.h:92

◆ quick_pop_pair()

sorted_pair_node * quick_pop_pair ( slimgb_alg * c)

Definition at line 3910 of file tgb.cc.

3911{
3912 if(c->pair_top < 0)
3913 return NULL;
3914 else
3915 return (c->apairs[c->pair_top--]);
3916}

◆ red_object_better_gen()

static int red_object_better_gen ( const void * ap,
const void * bp )
static

Definition at line 630 of file tgb.cc.

631{
632 return (pLmCmp (((red_object *) ap)->p, ((red_object *) bp)->p));
633}

◆ redNF2()

static poly redNF2 ( poly h,
slimgb_alg * c,
int & len,
number & m,
int n = 0 )
static

Definition at line 1789 of file tgb.cc.

1790{
1791 m = nInit (1);
1792 if(h == NULL)
1793 return NULL;
1794
1795 assume (len == (int)pLength (h));
1796 kStrategy strat = c->strat;
1797 if(0 > strat->sl)
1798 {
1799 return h;
1800 }
1801 int j;
1802
1803 LObject P (h);
1804 P.SetShortExpVector ();
1805 P.bucket = kBucketCreate (currRing);
1806 // BOOLEAN corr=lenS_correct(strat);
1807 kBucketInit (P.bucket, P.p, len /*pLength(P.p) */ );
1808 //wlen_set lenSw=(wlen_set) c->strat->lenS;
1809 //FIXME: plainly wrong
1810 //strat->lenS;
1811 //if (strat->lenSw!=NULL)
1812 // lenSw=strat->lenSw;
1813 //int max_pos=simple_posInS(strat,P.p);
1814 loop
1815 {
1816 //int dummy=strat->sl;
1817 j = kFindDivisibleByInS_easy (strat, P.p, P.sev);
1818 //j=kFindDivisibleByInS(strat,&dummy,&P);
1819 if((j >= 0) && ((!n) ||
1820 ((strat->lenS[j] <= n) &&
1821 ((strat->lenSw == NULL) || (strat->lenSw[j] <= n)))))
1822 {
1823 nNormalize (pGetCoeff (P.p));
1824#ifdef KDEBUG
1825 if(TEST_OPT_DEBUG)
1826 {
1827 PrintS ("red:");
1828 wrp (h);
1829 PrintS (" with ");
1830 wrp (strat->S[j]);
1831 }
1832#endif
1833
1834 number coef = kBucketPolyRed (P.bucket, strat->S[j],
1835 strat->lenS[j] /*pLength(strat->S[j]) */ ,
1836 strat->kNoether);
1837 number m2 = nMult (m, coef);
1838 nDelete (&m);
1839 m = m2;
1840 nDelete (&coef);
1841 h = kBucketGetLm (P.bucket);
1842
1843 if(h == NULL)
1844 {
1845 len = 0;
1846 kBucketDestroy (&P.bucket);
1847 return NULL;
1848 }
1849 P.p = h;
1850 P.t_p = NULL;
1851 P.SetShortExpVector ();
1852#ifdef KDEBUG
1853 if(TEST_OPT_DEBUG)
1854 {
1855 PrintS ("\nto:");
1856 wrp (h);
1857 PrintLn ();
1858 }
1859#endif
1860 }
1861 else
1862 {
1863 kBucketClear (P.bucket, &(P.p), &len);
1864 kBucketDestroy (&P.bucket);
1865 pNormalize (P.p);
1866 assume (len == (int)pLength (P.p));
1867 return P.p;
1868 }
1869 }
1870}
poly kNoether
Definition kutil.h:330
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition kbuckets.cc:1071
#define nNormalize(n)
Definition numbers.h:30
#define nMult(n1, n2)
Definition numbers.h:17
#define TEST_OPT_DEBUG
Definition options.h:110
#define pNormalize(p)
Definition polys.h:318
void PrintLn()
Definition reporter.cc:310

◆ redNFTail()

static poly redNFTail ( poly h,
const int sl,
kStrategy strat,
int len )
static

Definition at line 3001 of file tgb.cc.

3002{
3003 if(h == NULL)
3004 return NULL;
3005 pTest (h);
3006 if(0 > sl)
3007 return h;
3008 if(pNext (h) == NULL)
3009 return h;
3011
3012 int j;
3013 poly res = h;
3014 poly act = res;
3015 LObject P (pNext (h));
3016 pNext (res) = NULL;
3017 P.bucket = kBucketCreate (currRing);
3018 len--;
3019 h = P.p;
3020 if(len <= 0)
3021 len = pLength (h);
3022 kBucketInit (P.bucket, h /*P.p */ , len /*pLength(P.p) */ );
3023 pTest (h);
3024 loop
3025 {
3026 P.p = h;
3027 P.t_p = NULL;
3028 P.SetShortExpVector ();
3029 loop
3030 {
3031 //int dummy=strat->sl;
3032 j = kFindDivisibleByInS_easy (strat, P.p, P.sev); //kFindDivisibleByInS(strat,&dummy,&P);
3033 if(j >= 0)
3034 {
3035#ifdef REDTAIL_PROT
3036 PrintS ("r");
3037#endif
3038 nNormalize (pGetCoeff (P.p));
3039#ifdef KDEBUG
3040 if(TEST_OPT_DEBUG)
3041 {
3042 PrintS ("red tail:");
3043 wrp (h);
3044 PrintS (" with ");
3045 wrp (strat->S[j]);
3046 }
3047#endif
3048 number coef;
3049 pTest (strat->S[j]);
3050#ifdef HAVE_PLURAL
3051 if(nc)
3052 {
3053 nc_kBucketPolyRed_Z (P.bucket, strat->S[j], &coef, FALSE);
3054 }
3055 else
3056#endif
3057 coef = kBucketPolyRed (P.bucket, strat->S[j],
3058 strat->lenS[j] /*pLength(strat->S[j]) */ ,
3059 strat->kNoether);
3060 res=__p_Mult_nn (res, coef, currRing);
3061 nDelete (&coef);
3062 h = kBucketGetLm (P.bucket);
3063 if(h == NULL)
3064 {
3065#ifdef REDTAIL_PROT
3066 PrintS (" ");
3067#endif
3068 kBucketDestroy (&P.bucket);
3069 return res;
3070 }
3071 P.p = h;
3072 P.t_p = NULL;
3073 P.SetShortExpVector ();
3074#ifdef KDEBUG
3075 if(TEST_OPT_DEBUG)
3076 {
3077 PrintS ("\nto tail:");
3078 wrp (h);
3079 PrintLn ();
3080 }
3081#endif
3082 }
3083 else
3084 {
3085#ifdef REDTAIL_PROT
3086 PrintS ("n");
3087#endif
3088 break;
3089 }
3090 } /* end loop current mon */
3091 // poly tmp=pHead(h /*kBucketGetLm(P.bucket)*/);
3092 //act->next=tmp;pIter(act);
3093 act->next = kBucketExtractLm (P.bucket);
3094 pIter (act);
3095 h = kBucketGetLm (P.bucket);
3096 if(h == NULL)
3097 {
3098#ifdef REDTAIL_PROT
3099 PrintS (" ");
3100#endif
3101 kBucketDestroy (&P.bucket);
3102 return res;
3103 }
3104 pTest (h);
3105 }
3106}
STATIC_VAR scmon act
Definition hdegree.cc:1138
poly kBucketExtractLm(kBucket_pt bucket)
Definition kbuckets.cc:511
static void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition nc.h:284
#define __p_Mult_nn(p, n, r)
Definition p_polys.h:973
#define pTest(p)
Definition polys.h:415

◆ redTailShort()

static poly redTailShort ( poly h,
kStrategy strat )
static

Definition at line 1872 of file tgb.cc.

1873{
1874 if(h == NULL)
1875 return NULL; //n_Init(1,currRing);
1877 {
1878 bit_reduce (pNext (h), strat->tailRing);
1879 }
1880 int i;
1881 int len = pLength (h);
1882 for(i = 0; i <= strat->sl; i++)
1883 {
1884 if((strat->lenS[i] > 2)
1885 || ((strat->lenSw != NULL) && (strat->lenSw[i] > 2)))
1886 break;
1887 }
1888 return (redNFTail (h, i - 1, strat, len));
1889}
ring tailRing
Definition kutil.h:344
void bit_reduce(poly &f, ring r)
Definition digitech.cc:15
poly redNFTail(poly h, const int sl, kStrategy strat)

◆ replace_pair()

static void replace_pair ( int & i,
int & j,
slimgb_alg * c )
static

Definition at line 1167 of file tgb.cc.

1168{
1169 if(i < 0)
1170 return;
1171 c->soon_free = NULL;
1172 int syz_deg;
1173 poly lm = pOne ();
1174
1175 pLcm (c->S->m[i], c->S->m[j], lm);
1176 pSetm (lm);
1177
1178 int *i_con = make_connections (i, j, lm, c);
1179
1180 for(int n = 0; ((n < c->n) && (i_con[n] >= 0)); n++)
1181 {
1182 if(i_con[n] == j)
1183 {
1184 now_t_rep (i, j, c);
1185 omFree (i_con);
1186 p_Delete (&lm, c->r);
1187 return;
1188 }
1189 }
1190
1191 int *j_con = make_connections (j, i, lm, c);
1192
1193// if(c->n>1)
1194// {
1195// if (i_con[1]>=0)
1196// i=i_con[1];
1197// else
1198// {
1199// if (j_con[1]>=0)
1200// j=j_con[1];
1201// }
1202 // }
1203
1204 int sugar = syz_deg = c->pTotaldegree (lm);
1205
1206 p_Delete (&lm, c->r);
1207 if(c->T_deg_full) //Sugar
1208 {
1209 int t_i = c->T_deg_full[i] - c->T_deg[i];
1210 int t_j = c->T_deg_full[j] - c->T_deg[j];
1211 sugar += si_max (t_i, t_j);
1212 //Print("\n max: %d\n",max(t_i,t_j));
1213 }
1214
1215 for(int m = 0; ((m < c->n) && (i_con[m] >= 0)); m++)
1216 {
1217 if(c->T_deg_full != NULL)
1218 {
1219 int s1 = c->T_deg_full[i_con[m]] + syz_deg - c->T_deg[i_con[m]];
1220 if(s1 > sugar)
1221 continue;
1222 }
1223 if(c->weighted_lengths[i_con[m]] < c->weighted_lengths[i])
1224 i = i_con[m];
1225 }
1226 for(int m = 0; ((m < c->n) && (j_con[m] >= 0)); m++)
1227 {
1228 if(c->T_deg_full != NULL)
1229 {
1230 int s1 = c->T_deg_full[j_con[m]] + syz_deg - c->T_deg[j_con[m]];
1231 if(s1 > sugar)
1232 continue;
1233 }
1234 if(c->weighted_lengths[j_con[m]] < c->weighted_lengths[j])
1235 j = j_con[m];
1236 }
1237
1238 //can also try dependent search
1239 omFree (i_con);
1240 omFree (j_con);
1241 return;
1242}
int_pair_node * soon_free

◆ search_red_object_pos()

int search_red_object_pos ( red_object * a,
int top,
red_object * key )

Definition at line 4608 of file tgb.cc.

4609{
4610 int an = 0;
4611 int en = top;
4612 if(top == -1)
4613 return 0;
4614 if(pLmCmp (key->p, a[top].p) == 1)
4615 return top + 1;
4616 int i;
4617 loop
4618 {
4619 if(an >= en - 1)
4620 {
4621 if(pLmCmp (key->p, a[an].p) == -1)
4622 return an;
4623 return en;
4624 }
4625 i = (an + en) / 2;
4626 if(pLmCmp (key->p, a[i].p) == -1)
4627 en = i;
4628 else
4629 an = i;
4630 }
4631}

◆ shorten_tails()

static void shorten_tails ( slimgb_alg * c,
poly monom )
static

Definition at line 3725 of file tgb.cc.

3726{
3727 return;
3728// BOOLEAN corr=lenS_correct(c->strat);
3729 for(int i = 0; i < c->n; i++)
3730 {
3731 //enter tail
3732
3733 if(c->S->m[i] == NULL)
3734 continue;
3735 poly tail = c->S->m[i]->next;
3736 poly prev = c->S->m[i];
3737 BOOLEAN did_something = FALSE;
3738 while((tail != NULL) && (pLmCmp (tail, monom) >= 0))
3739 {
3740 if(p_LmDivisibleBy (monom, tail, c->r))
3741 {
3742 did_something = TRUE;
3743 prev->next = tail->next;
3744 tail->next = NULL;
3745 p_Delete (&tail, c->r);
3746 tail = prev;
3747 //PrintS("Shortened");
3748 c->lengths[i]--;
3749 }
3750 prev = tail;
3751 tail = tail->next;
3752 }
3753 if(did_something)
3754 {
3755 int new_pos;
3756 wlen_type q;
3757 q = pQuality (c->S->m[i], c, c->lengths[i]);
3758 new_pos = simple_posInS (c->strat, c->S->m[i], c->lengths[i], q);
3759
3760 int old_pos = -1;
3761 //assume new_pos<old_pos
3762 for(int z = 0; z <= c->strat->sl; z++)
3763 {
3764 if(c->strat->S[z] == c->S->m[i])
3765 {
3766 old_pos = z;
3767 break;
3768 }
3769 }
3770 if(old_pos == -1)
3771 for(int z = new_pos - 1; z >= 0; z--)
3772 {
3773 if(c->strat->S[z] == c->S->m[i])
3774 {
3775 old_pos = z;
3776 break;
3777 }
3778 }
3779 assume (old_pos >= 0);
3780 assume (new_pos <= old_pos);
3781 assume ((int)pLength (c->strat->S[old_pos]) == c->lengths[i]);
3782 c->strat->lenS[old_pos] = c->lengths[i];
3783 if(c->strat->lenSw)
3784 c->strat->lenSw[old_pos] = q;
3785 if(new_pos < old_pos)
3786 move_forward_in_S (old_pos, new_pos, c->strat);
3787 length_one_crit (c, i, c->lengths[i]);
3788 }
3789 }
3790}

◆ simple_posInS()

static int simple_posInS ( kStrategy strat,
poly p,
int len,
wlen_type wlen )
static

Definition at line 1260 of file tgb.cc.

1261{
1262 if(strat->sl == -1)
1263 return 0;
1264 if(strat->lenSw)
1265 return pos_helper (strat, p, (wlen_type) wlen, (wlen_set) strat->lenSw,
1266 strat->S);
1267 return pos_helper (strat, p, len, strat->lenS, strat->S);
1268}
wlen_type * wlen_set
Definition kutil.h:56
int pos_helper(kStrategy strat, poly p, len_type len, set_type setL, polyset set)

◆ simplify_poly()

static void simplify_poly ( poly p,
ring r )
static

Definition at line 59 of file tgb.cc.

60{
61 assume (r == currRing);
63 {
64 p_Cleardenom (p, r);
65 //includes p_Content(p,r);
66 }
67 else
68 pNorm (p);
69}

◆ slim_nsize()

int slim_nsize ( number n,
ring r )

Definition at line 73 of file tgb.cc.

74{
75 if(rField_is_Zp (r))
76 {
77 return 1;
78 }
79 if(rField_is_Q (r))
80 {
81 return nlQlogSize (n, r->cf);
82 }
83 else
84 {
85 return n_Size (n, r->cf);
86 }
87}
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:571
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506

◆ sort_region_down()

static void sort_region_down ( red_object * los,
int l,
int u,
slimgb_alg *  )
static

Definition at line 4633 of file tgb.cc.

4634{
4635 int r_size = u - l + 1;
4636 qsort (los + l, r_size, sizeof (red_object), red_object_better_gen);
4637 int i;
4638 int *new_indices = (int *) omalloc ((r_size) * sizeof (int));
4639 int bound = 0;
4640 BOOLEAN at_end = FALSE;
4641 for(i = l; i <= u; i++)
4642 {
4643 if(!(at_end))
4644 {
4645 bound = new_indices[i - l] =
4646 bound + search_red_object_pos (los + bound, l - bound - 1, los + i);
4647 if(bound == l)
4648 at_end = TRUE;
4649 }
4650 else
4651 {
4652 new_indices[i - l] = l;
4653 }
4654 }
4655 red_object *los_region =
4656 (red_object *) omalloc (sizeof (red_object) * (u - l + 1));
4657 for(int i = 0; i < r_size; i++)
4658 {
4659 new_indices[i] += i;
4660 los_region[i] = los[l + i];
4661 assume ((i == 0) || (new_indices[i] > new_indices[i - 1]));
4662 }
4663
4664 i = r_size - 1;
4665 int j = u;
4666 int j2 = l - 1;
4667 while(i >= 0)
4668 {
4669 if(new_indices[i] == j)
4670 {
4671 los[j] = los_region[i];
4672 i--;
4673 j--;
4674 }
4675 else
4676 {
4677 assume (new_indices[i] < j);
4678 los[j] = los[j2];
4679 assume (j2 >= 0);
4680 j2--;
4681 j--;
4682 }
4683 }
4684 omfree (los_region);
4685 omfree (new_indices);
4686}
int search_red_object_pos(red_object *a, int top, red_object *key)
Definition tgb.cc:4608

◆ spn_merge()

sorted_pair_node ** spn_merge ( sorted_pair_node ** p,
int pn,
sorted_pair_node ** q,
int qn,
slimgb_alg * c )

Definition at line 716 of file tgb.cc.

718{
719 int i;
720 int *a = (int *) omalloc (qn * sizeof (int));
721// int mc;
722// PrintS("Debug\n");
723// for(mc=0;mc<qn;mc++)
724// {
725// wrp(q[mc]->lcm_of_lm);
726// PrintS("\n");
727// }
728// PrintS("Debug they are in\n");
729// for(mc=0;mc<pn;mc++)
730// {
731// wrp(p[mc]->lcm_of_lm);
732// PrintS("\n");
733// }
734 int lastpos = 0;
735 for(i = 0; i < qn; i++)
736 {
737 lastpos = posInPairs (p, pn, q[i], c, si_max (lastpos - 1, 0));
738 // cout<<lastpos<<"\n";
739 a[i] = lastpos;
740 }
741 if((pn + qn) > c->max_pairs)
742 {
743 p =
745 c->max_pairs *sizeof (sorted_pair_node *),
746 2 * (pn + qn) * sizeof (sorted_pair_node *));
747 c->max_pairs = 2 * (pn + qn);
748 }
749 for(i = qn - 1; i >= 0; i--)
750 {
751 size_t size;
752 if(qn - 1 > i)
753 size = (a[i + 1] - a[i]) * sizeof (sorted_pair_node *);
754 else
755 size = (pn - a[i]) * sizeof (sorted_pair_node *); //as indices begin with 0
756 memmove (p + a[i] + (1 + i), p + a[i], size);
757 p[a[i] + i] = q[i];
758 }
759 omfree (a);
760 return p;
761}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
static int posInPairs(sorted_pair_node **p, int pn, sorted_pair_node *qe, slimgb_alg *c, int an=0)
Definition tgb.cc:676

◆ state_is()

static BOOLEAN state_is ( calc_state state,
const int & i,
const int & j,
slimgb_alg * c )
static

Definition at line 3945 of file tgb.cc.

3947{
3948 assume (0 <= arg_i);
3949 assume (0 <= arg_j);
3950 assume (arg_i < c->n);
3951 assume (arg_j < c->n);
3952 if(arg_i == arg_j)
3953 {
3954 return (TRUE);
3955 }
3956 if(arg_i > arg_j)
3957 {
3958 return (c->states[arg_i][arg_j] == state);
3959 }
3960 else
3961 return (c->states[arg_j][arg_i] == state);
3962}

◆ super_clean_top_of_pair_list()

static void super_clean_top_of_pair_list ( slimgb_alg * c)
static

Definition at line 3918 of file tgb.cc.

3919{
3920 while((c->pair_top >= 0)
3921 && (c->apairs[c->pair_top]->i >= 0)
3922 &&
3924 (c->apairs[c->pair_top]->j, c->apairs[c->pair_top]->i, c)))
3925 {
3927 c->pair_top--;
3928 }
3929}
BOOLEAN good_has_t_rep(int i, int j, slimgb_alg *c)
Definition tgb.cc:840

◆ t_rep_gb()

ideal t_rep_gb ( const ring r,
ideal arg_I,
int syz_comp,
BOOLEAN F4_mode )

Definition at line 3581 of file tgb.cc.

3582{
3583 assume (r == currRing);
3584 ring orig_ring = r;
3585 int pos;
3586 ring new_ring = rAssure_TDeg (orig_ring, pos);
3587 ideal s_h;
3588 if(orig_ring != new_ring)
3589 {
3590 rChangeCurrRing (new_ring);
3591 s_h = idrCopyR_NoSort (arg_I, orig_ring, new_ring);
3592 /*int i;
3593 for(i=0;i<IDELEMS(s_h);i++)
3594 {
3595 poly p=s_h->m[i];
3596 while(p)
3597 {
3598 p_Setm(p,new_ring);
3599 pIter(p);
3600 }
3601 } */
3602 }
3603 else
3604 {
3605 s_h = id_Copy (arg_I, orig_ring);
3606 }
3607 idTest (s_h);
3608
3609 ideal s_result = do_t_rep_gb (new_ring, s_h, syz_comp, F4_mode, pos);
3610 ideal result;
3611 if(orig_ring != new_ring)
3612 {
3613 idTest (s_result);
3614 rChangeCurrRing (orig_ring);
3615 result = idrMoveR_NoSort (s_result, new_ring, orig_ring);
3616
3617 idTest (result);
3618 //rChangeCurrRing(new_ring);
3619 rDelete(new_ring);
3620 //rChangeCurrRing(orig_ring);
3621 }
3622 else
3623 result = s_result;
3624 idTest (result);
3625 return result;
3626}
return result
ideal id_Copy(ideal h1, const ring r)
copy an ideal
#define idTest(id)
Definition ideals.h:47
void rChangeCurrRing(ring r)
Definition polys.cc:16
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:261
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:205
ring rAssure_TDeg(ring r, int &pos)
Definition ring.cc:4619
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
ideal do_t_rep_gb(ring, ideal arg_I, int syz_comp, BOOLEAN F4_mode, int deg_pos)
Definition tgb.cc:3629

◆ terms_sort_crit()

int terms_sort_crit ( const void * a,
const void * b )

Definition at line 1982 of file tgb.cc.

1983{
1984 return -pLmCmp (*((poly *) a), *((poly *) b));
1985}

◆ tgb_pair_better_gen()

static int tgb_pair_better_gen ( const void * ap,
const void * bp )
static

Definition at line 3999 of file tgb.cc.

4000{
4002 sorted_pair_node *b = *((sorted_pair_node **) bp);
4003 assume ((a->i > a->j) || (a->i < 0));
4004 assume ((b->i > b->j) || (b->i < 0));
4005 if(a->deg < b->deg)
4006 return -1;
4007 if(a->deg > b->deg)
4008 return 1;
4009
4010 int comp = pLmCmp (a->lcm_of_lm, b->lcm_of_lm);
4011
4012 if(comp == 1)
4013 return 1;
4014 if(-1 == comp)
4015 return -1;
4016 if(a->expected_length < b->expected_length)
4017 return -1;
4018 if(a->expected_length > b->expected_length)
4019 return 1;
4020 if(a->i + a->j < b->i + b->j)
4021 return -1;
4022 if(a->i + a->j > b->i + b->j)
4023 return 1;
4024 if(a->i < b->i)
4025 return -1;
4026 if(a->i > b->i)
4027 return 1;
4028 return 0;
4029}

◆ tgb_pair_better_gen2()

int tgb_pair_better_gen2 ( const void * ap,
const void * bp )

Definition at line 645 of file tgb.cc.

646{
647 return (-tgb_pair_better_gen (ap, bp));
648}
static int tgb_pair_better_gen(const void *ap, const void *bp)
Definition tgb.cc:3999

◆ top_pair()

sorted_pair_node * top_pair ( slimgb_alg * c)

Definition at line 3886 of file tgb.cc.

3887{
3888 while(c->pair_top >= 0)
3889 {
3890 super_clean_top_of_pair_list (c); //yeah, I know, it's odd that I use a different proc here
3891 if((c->is_homog) && (c->pair_top >= 0)
3892 && (c->apairs[c->pair_top]->deg >= c->lastCleanedDeg + 2))
3893 {
3894 int upper = c->apairs[c->pair_top]->deg - 1;
3895 c->cleanDegs (c->lastCleanedDeg + 1, upper);
3896 c->lastCleanedDeg = upper;
3897 }
3898 else
3899 {
3900 break;
3901 }
3902 }
3903
3904 if(c->pair_top < 0)
3905 return NULL;
3906 else
3907 return (c->apairs[c->pair_top]);
3908}
void cleanDegs(int lower, int upper)
Definition tgb.cc:3804
static void super_clean_top_of_pair_list(slimgb_alg *c)
Definition tgb.cc:3918

◆ trivial_syzygie()

static BOOLEAN trivial_syzygie ( int pos1,
int pos2,
poly bound,
slimgb_alg * c )
static

Definition at line 764 of file tgb.cc.

765{
766 poly p1 = c->S->m[pos1];
767 poly p2 = c->S->m[pos2];
768
769 if(pGetComp (p1) > 0 || pGetComp (p2) > 0)
770 return FALSE;
771 int i = 1;
772 poly m = NULL;
773 poly gcd1 = c->gcd_of_terms[pos1];
774 poly gcd2 = c->gcd_of_terms[pos2];
775
776 if((gcd1 != NULL) && (gcd2 != NULL))
777 {
778 gcd1->next = gcd2; //may ordered incorrect
779 m = gcd_of_terms (gcd1, c->r);
780 gcd1->next = NULL;
781 }
782 if(m == NULL)
783 {
784 loop
785 {
786 if(pGetExp (p1, i) + pGetExp (p2, i) > pGetExp (bound, i))
787 return FALSE;
788 if(i == (currRing->N))
789 {
790 //PrintS("trivial");
791 return TRUE;
792 }
793 i++;
794 }
795 }
796 else
797 {
798 loop
799 {
800 if(pGetExp (p1, i) - pGetExp (m, i) + pGetExp (p2, i) >
801 pGetExp (bound, i))
802 {
803 pDelete (&m);
804 return FALSE;
805 }
806 if(i == (currRing->N))
807 {
808 pDelete (&m);
809 //PrintS("trivial");
810 return TRUE;
811 }
812 i++;
813 }
814 }
815}

Variable Documentation

◆ bundle_size

const int bundle_size = 100
static

Definition at line 36 of file tgb.cc.

◆ bundle_size_noro

const int bundle_size_noro = 10000
static

Definition at line 37 of file tgb.cc.

◆ delay_factor

const int delay_factor = 3
static

Definition at line 38 of file tgb.cc.

◆ lm_bin

STATIC_VAR omBin lm_bin = NULL

Definition at line 41 of file tgb.cc.