My Project
Data Structures | Macros | Functions | Variables
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 More...
 
#define SR_HDL(A)   ((long)(A))
 
#define ADD_LATER_SIZE   500
 
#define LEN_VAR3
 
#define degbound(p)   assume(pTotaldegree(p)<10)
 
#define ENLARGE(pointer, type)   pointer=(type*) omreallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(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. More...
 
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 More...
 
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)    assume(pTotaldegree(p)<10)

Definition at line 153 of file tgb.cc.

◆ ENLARGE

#define ENLARGE (   pointer,
  type 
)    pointer=(type*) omreallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type))

◆ 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)
Definition: omAllocDecl.h:220
#define omAllocAligned
Definition: omAllocDecl.h:273

◆ LEN_VAR3

#define LEN_VAR3

Definition at line 152 of file tgb.cc.

◆ SR_HDL

#define SR_HDL (   A)    ((long)(A))

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
int p
Definition: cfModGcd.cc:4078
ideal add_later
Definition: tgb_internal.h:214
#define NULL
Definition: omList.c:12
#define TEST_OPT_PROT
Definition: options.h:103
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1725
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;
1528  c->extended_product_crit++;
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);
1561  if(TEST_V_UPTORADICAL)
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  {
1663  if(p_LmDivisibleBy
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] =
1689  (sorted_pair_node *) omAlloc (sizeof (sorted_pair_node));
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 oder 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:124
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
intset lenS
Definition: kutil.h:319
unsigned long pTotaldegree(poly p)
Definition: tgb_internal.h:271
sorted_pair_node ** apairs
Definition: tgb_internal.h:229
BOOLEAN nc
Definition: tgb_internal.h:267
kStrategy strat
Definition: tgb_internal.h:220
int * T_deg_full
Definition: tgb_internal.h:222
int array_lengths
Definition: tgb_internal.h:246
int easy_product_crit
Definition: tgb_internal.h:253
int * lengths
Definition: tgb_internal.h:217
int extended_product_crit
Definition: tgb_internal.h:254
sorted_pair_node ** tmp_spn
Definition: tgb_internal.h:225
void introduceDelayedPairs(poly *pa, int s)
Definition: tgb.cc:3156
char ** states
Definition: tgb_internal.h:209
poly * gcd_of_terms
Definition: tgb_internal.h:227
poly * tmp_pair_lm
Definition: tgb_internal.h:224
long * short_Exps
Definition: tgb_internal.h:219
BOOLEAN is_homog
Definition: tgb_internal.h:263
int syz_comp
array_lengths should be greater equal n;
Definition: tgb_internal.h:245
int pTotaldegree_full(poly p)
Definition: tgb_internal.h:279
wlen_type * weighted_lengths
Definition: tgb_internal.h:218
CFFListIterator iter
Definition: facAbsBiFact.cc:53
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:1430
int64 wlen_type
Definition: kutil.h:54
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:1203
#define assume(x)
Definition: mod2.h:389
#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)
Definition: omAllocDecl.h:237
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omalloc(size)
Definition: omAllocDecl.h:228
#define omFree(addr)
Definition: omAllocDecl.h:261
#define TEST_OPT_INTSTRATEGY
Definition: options.h:110
#define TEST_V_FINDMONOM
Definition: options.h:142
#define TEST_V_UPTORADICAL
Definition: options.h:141
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4897
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2910
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3812
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1931
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:1897
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:903
static unsigned pLength(poly a)
Definition: p_polys.h:191
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:162
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:271
#define pHasNotCF(p1, p2)
Definition: polys.h:263
#define pLmEqual(p1, p2)
Definition: polys.h:111
void pNorm(poly p)
Definition: polys.h:363
#define pExpVectorSub(p1, p2)
Definition: polys.h:88
#define pMDivide(a, b)
Definition: polys.h:293
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
#define pLcm(a, b, m)
Definition: polys.h:295
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:3715
static poly gcd_of_terms(poly p, ring r)
Definition: tgb.cc:4021
int tgb_pair_better_gen2(const void *ap, const void *bp)
Definition: tgb.cc:645
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:3921
#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
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 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:3695
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:4080
@ UNCALCULATED
Definition: tgb_internal.h:309
@ HASTREP
Definition: tgb_internal.h:310

◆ 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);
933  assume (lenS_correct (c->strat));
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  memset (&P, 0, sizeof (P));
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:306
wlen_set lenSw
Definition: kutil.h:320
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition: kutil.h:286
class sLObject LObject
Definition: kutil.h:58
#define TEST_OPT_IDLIFT
Definition: options.h:129
#define pGetComp(p)
Component.
Definition: polys.h:37
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 4483 of file tgb.cc.

4484 {
4485  assume (l <= u + 1);
4486  int i;
4487  for(i = l; i <= u; i++)
4488  {
4489  kBucketCanonicalize (los[i].bucket);
4490  }
4491 }
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 3921 of file tgb.cc.

3922 {
3923  while((c->pair_top >= 0) && (c->apairs[c->pair_top]->i >= 0)
3924  &&
3925  (!state_is
3926  (UNCALCULATED, c->apairs[c->pair_top]->j, c->apairs[c->pair_top]->i,
3927  c)))
3928  {
3929  free_sorted_pair_node (c->apairs[c->pair_top], c->r);
3930  c->pair_top--;
3931  }
3932 }
void free_sorted_pair_node(sorted_pair_node *s, const ring r)
Definition: tgb.cc:3954
static BOOLEAN state_is(calc_state state, const int &i, const int &j, slimgb_alg *c)
Definition: tgb.cc:3935

◆ 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
897  BOOLEAN found = FALSE;
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:322
bool found
Definition: facFactorize.cc:55
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:1163
#define pDelete(p_ptr)
Definition: polys.h:186

◆ 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:146
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition: polys.h:152
#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:507

◆ 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 3619 of file tgb.cc.

3620 {
3621  // 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)));
3622 
3623  if(TEST_OPT_PROT)
3624  if(F4_mode)
3625  PrintS ("F4 Modus\n");
3626 
3627  //debug_Ideal=arg_debug_Ideal;
3628  //if (debug_Ideal) PrintS("DebugIdeal received\n");
3629  // Print("Idelems %i \n----------\n",IDELEMS(arg_I));
3630  ideal I = arg_I;
3631  id_Compactify (I,currRing);
3632  if(idIs0 (I))
3633  return I;
3634  int i;
3635  for(i = 0; i < IDELEMS (I); i++)
3636  {
3637  assume (I->m[i] != NULL);
3638  simplify_poly (I->m[i], currRing);
3639  }
3640 
3641  qsort (I->m, IDELEMS (I), sizeof (poly), poly_crit);
3642  //Print("Idelems %i \n----------\n",IDELEMS(I));
3643  //slimgb_alg* c=(slimgb_alg*) omalloc(sizeof(slimgb_alg));
3644  //int syz_comp=arg_I->rank;
3645  slimgb_alg *c = new slimgb_alg (I, syz_comp, F4_mode, deg_pos);
3646 
3647  while((c->pair_top >= 0)
3648  && ((!(TEST_OPT_DEGBOUND))
3649  || (c->apairs[c->pair_top]->deg <= Kstd1_deg)))
3650  {
3651 #ifdef HAVE_F4
3652  if(F4_mode)
3653  go_on_F4 (c);
3654  else
3655 #endif
3656  go_on (c);
3657  }
3658  if(c->pair_top < 0)
3659  c->completed = TRUE;
3660  I = c->S;
3661  delete c;
3662  if(TEST_OPT_REDSB)
3663  {
3664  ideal erg = kInterRed (I, NULL);
3665  assume (I != erg);
3666  id_Delete (&I, currRing);
3667  return erg;
3668  }
3669  //qsort(I->m, IDELEMS(I),sizeof(poly),pLmCmp_func);
3670  assume (I->rank >= id_RankFreeModule (I,currRing));
3671  return (I);
3672 }
BOOLEAN completed
Definition: tgb_internal.h:262
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3743
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:49
#define TEST_OPT_REDSB
Definition: options.h:104
#define TEST_OPT_DEGBOUND
Definition: options.h:113
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)
Definition: simpleideals.h:23
static void go_on(slimgb_alg *c)
Definition: tgb.cc:2712
static int poly_crit(const void *ap1, const void *ap2)
Definition: tgb.cc:3138
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
Definition: tgb_internal.h:256

◆ extended_product_criterion()

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

Definition at line 4080 of file tgb.cc.

4082 {
4083  if(c->nc)
4084  return FALSE;
4085  if(gcd1 == NULL)
4086  return FALSE;
4087  if(gcd2 == NULL)
4088  return FALSE;
4089  gcd1->next = gcd2; //may ordered incorrect
4090  poly m = gcd_of_terms (gcd1, c->r);
4091  gcd1->next = NULL;
4092  if(m == NULL)
4093  return FALSE;
4094 
4095  BOOLEAN erg = pHasNotCFExtended (p1, p2, m);
4096  pDelete (&m);
4097  return erg;
4098 }
int m
Definition: cfEzgcd.cc:128
static BOOLEAN pHasNotCFExtended(poly p1, poly p2, poly m)
Definition: tgb.cc:4061

◆ 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 3118 of file tgb.cc.

3120 {
3121  poly p = NULL;
3122  poly *set_this = &p;
3123  mac_poly r = mat->mp[row];
3124  mat->mp[row] = NULL;
3125  while(r)
3126  {
3127  (*set_this) = pLmInit (monoms[monom_index - 1 - r->exp]);
3128  pSetCoeff ((*set_this), r->coef);
3129  set_this = &((*set_this)->next);
3130  mac_poly old = r;
3131  r = r->next;
3132  delete old;
3133 
3134  }
3135  return p;
3136 }
mac_poly_r * next
Definition: tgbgauss.h:51
number coef
Definition: tgbgauss.h:50
int exp
Definition: tgbgauss.h:52
mac_poly * mp
Definition: tgbgauss.h:64
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64

◆ free_sorted_pair_node()

void free_sorted_pair_node ( sorted_pair_node s,
const ring  r 
)

Definition at line 3954 of file tgb.cc.

3955 {
3956  if(s->i >= 0)
3957  p_Delete (&s->lcm_of_lm, r);
3958  omFree (s);
3959 }

◆ fwbw()

static int fwbw ( red_object los,
int  i 
)
static

Definition at line 4425 of file tgb.cc.

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

◆ gcd_of_terms()

static poly gcd_of_terms ( poly  p,
ring  r 
)
static

Definition at line 4021 of file tgb.cc.

4022 {
4023  int max_g_0 = 0;
4024  assume (p != NULL);
4025  int i;
4026  poly m = pOne ();
4027  poly t;
4028  for(i = (currRing->N); i; i--)
4029  {
4030  pSetExp (m, i, pGetExp (p, i));
4031  if(max_g_0 == 0)
4032  if(pGetExp (m, i) > 0)
4033  max_g_0 = i;
4034  }
4035 
4036  t = p->next;
4037  while(t != NULL)
4038  {
4039  if(max_g_0 == 0)
4040  break;
4041  for(i = max_g_0; i; i--)
4042  {
4043  pSetExp (m, i, si_min (pGetExp (t, i), pGetExp (m, i)));
4044  if(max_g_0 == i)
4045  if(pGetExp (m, i) == 0)
4046  max_g_0 = 0;
4047  if((max_g_0 == 0) && (pGetExp (m, i) > 0))
4048  {
4049  max_g_0 = i;
4050  }
4051  }
4052  t = t->next;
4053  }
4054  p_Setm (m, r);
4055  if(max_g_0 > 0)
4056  return m;
4057  pDelete (&m);
4058  return NULL;
4059 }
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:235
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pSetExp(p, i, v)
Definition: polys.h:42
#define pOne()
Definition: polys.h:315

◆ 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:5286
static int rBlocks(const ring r)
Definition: ring.h:569
@ ringorder_dp
Definition: ring.h:78

◆ 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  {
2763  free_sorted_pair_node (s, c->r);
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  // if(s->i>=0)
2790 // now_t_rep(s->j,s->i,c);
2791  number coef;
2792  int mlen = pLength (h);
2793  p_Test (h, c->r);
2794  if((!c->nc) & (!(use_noro)))
2795  {
2796  h = redNF2 (h, c, mlen, coef, 2);
2797  redTailShort (h, c->strat);
2798  nDelete (&coef);
2799  }
2800  p_Test (h, c->r);
2801  free_sorted_pair_node (s, c->r);
2802  if(!h)
2803  continue;
2804 
2805  if(TEST_OPT_IDLIFT
2806  && p_GetComp(h, currRing) > c->syz_comp)
2807  {
2808  pDelete(&h);
2809  continue;
2810  }
2811 
2812  p[i] = h;
2813  i++;
2814  }
2815  p[i] = NULL;
2816 // pre_comp(p,i,c);
2817  if(i == 0)
2818  {
2819  omFree (p);
2820  return;
2821  }
2822 #ifdef TGB_RESORT_PAIRS
2823  c->replaced = new bool[c->n];
2824  c->used_b = FALSE;
2825 #endif
2826 
2827  c->normal_forms += i;
2828  int j;
2829 #ifdef USE_NORO
2830  //if ((!(c->nc))&&(rField_is_Zp(c->r)))
2831  //{
2832  if(use_noro)
2833  {
2834  int pn = i;
2835  if(pn == 0)
2836  {
2837  omFree (p);
2838  return;
2839  }
2840  {
2841  if(n_GetChar(currRing->cf) < 255)
2842  {
2843  noro_step < tgb_uint8 > (p, pn, c);
2844  }
2845  else
2846  {
2847  if(n_GetChar(currRing->cf) < 65000)
2848  {
2849  noro_step < tgb_uint16 > (p, pn, c);
2850  }
2851  else
2852  {
2853  noro_step < tgb_uint32 > (p, pn, c);
2854  }
2855  }
2856  }
2857 
2858  //if (TEST_OPT_PROT)
2859  //{
2860  // Print("reported rank:%i\n",pn);
2861  //}
2862  mass_add (p, pn, c);
2863  omFree (p);
2864  return;
2865  /*if (TEST_OPT_PROT)
2866  for(j=0;j<pn;j++)
2867  {
2868  p_wrp(p[j],c->r);
2869  } */
2870  }
2871 #endif
2872  red_object *buf = (red_object *) omAlloc (i * sizeof (red_object)); /*i>0*/
2873  for(j = 0; j < i; j++)
2874  {
2875  p_Test (p[j], c->r);
2876  buf[j].p = p[j];
2877  buf[j].sev = pGetShortExpVector (p[j]);
2878  buf[j].bucket = kBucketCreate (currRing);
2879  p_Test (p[j], c->r);
2880  int len = pLength (p[j]);
2881  kBucketInit (buf[j].bucket, p[j], len);
2882  buf[j].initial_quality = buf[j].guess_quality (c);
2883  assume (buf[j].initial_quality >= 0);
2884  }
2885  omFree (p);
2886  qsort (buf, i, sizeof (red_object), red_object_better_gen);
2887 // Print("\ncurr_deg:%i\n",curr_deg);
2888  if(TEST_OPT_PROT)
2889  {
2890  Print ("%dM[%d,", curr_deg, i);
2891  }
2892 
2893  multi_reduction (buf, i, c);
2894 #ifdef TGB_RESORT_PAIRS
2895  if(c->used_b)
2896  {
2897  if(TEST_OPT_PROT)
2898  PrintS ("B");
2899  int e;
2900  for(e = 0; e <= c->pair_top; e++)
2901  {
2902  if(c->apairs[e]->i < 0)
2903  continue;
2904  assume (c->apairs[e]->j >= 0);
2905  if((c->replaced[c->apairs[e]->i]) || (c->replaced[c->apairs[e]->j]))
2906  {
2907  sorted_pair_node *s = c->apairs[e];
2908  s->expected_length = pair_weighted_length (s->i, s->j, c);
2909  }
2910  }
2911  qsort (c->apairs, c->pair_top + 1, sizeof (sorted_pair_node *),
2913  }
2914 #endif
2915 #ifdef TGB_DEBUG
2916  {
2917  int k;
2918  for(k = 0; k < i; k++)
2919  {
2920  assume (kFindDivisibleByInS_easy (c->strat, buf[k]) < 0);
2921  int k2;
2922  for(k2 = 0; k2 < i; k2++)
2923  {
2924  if(k == k2)
2925  continue;
2926  assume ((!(p_LmDivisibleBy (buf[k].p, buf[k2].p, c->r)))
2927  || (wrp (buf[k].p), Print (" k %d k2 %d ", k, k2),
2928  wrp (buf[k2].p), FALSE));
2929  }
2930  }
2931  }
2932 #endif
2933  //resort S
2934 
2935  if(TEST_OPT_PROT)
2936  Print ("%i]", i);
2937 
2938  poly *add_those = (poly *) omalloc0 (i * sizeof (poly));
2939  int num_to_add=0;
2940  for(j = 0; j < i; j++)
2941  {
2942  int len;
2943  poly p;
2944  buf[j].flatten ();
2945  kBucketClear (buf[j].bucket, &p, &len);
2946  kBucketDestroy (&buf[j].bucket);
2947  p_Test (p, c->r);
2948  //if (!c->nc) {
2949  if((c->tailReductions) || (lies_in_last_dp_block (p, c)))
2950  {
2951  p = redNFTail (p, c->strat->sl, c->strat, 0);
2952  }
2953  else
2954  {
2955  p = redTailShort (p, c->strat);
2956  }
2957  //}
2958  p_Test (p, c->r);
2959 
2960  if (p!=NULL)
2961  {
2962  if (TEST_OPT_IDLIFT && (p_GetComp(p,currRing) > c->syz_comp))
2963  {
2964  p_Delete(&p,currRing);
2965  }
2966  else
2967  {
2968  add_those[num_to_add++] = p;
2969  }
2970  }
2971 
2972  //sbuf[j]=add_to_basis(p,-1,-1,c,ibuf+j);
2973  }
2974  mass_add (add_those, num_to_add, c);
2975  omfree (add_those);
2976  omFree (buf);
2977 
2978  if(TEST_OPT_PROT)
2979  Print ("(%d)", c->pair_top + 1);
2980  //TODO: implement that while(!(idIs0(c->add_later)))
2981 #ifdef TGB_RESORT_PAIRS
2982  delete c->replaced;
2983  c->replaced = NULL;
2984  c->used_b = FALSE;
2985 #endif
2986  return;
2987 }
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:348
BOOLEAN use_noro_last_block
Definition: tgb_internal.h:260
int average_length
Definition: tgb_internal.h:255
BOOLEAN tailReductions
Definition: tgb_internal.h:264
BOOLEAN use_noro
Definition: tgb_internal.h:259
int normal_forms
Definition: tgb_internal.h:247
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
#define Print
Definition: emacs.cc:80
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
Definition: kInline.h:1205
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)
Definition: omAllocDecl.h:229
void wrp(poly p)
Definition: polys.h:310
int status int void * buf
Definition: si_signals.h:59
static poly redNFTail(poly h, const int sl, kStrategy strat, int len)
Definition: tgb.cc:2991
sorted_pair_node * quick_pop_pair(slimgb_alg *c)
Definition: tgb.cc:3900
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:3674
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
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:4679
static poly redTailShort(poly h, kStrategy strat)
Definition: tgb.cc:1872
sorted_pair_node * top_pair(slimgb_alg *c)
Definition: tgb.cc:3876
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 3695 of file tgb.cc.

3696 {
3697  assume (0 <= arg_i);
3698  assume (0 <= arg_j);
3699  assume (arg_i < state->n);
3700  assume (arg_j < state->n);
3701  if(arg_i == arg_j)
3702  {
3703  return (TRUE);
3704  }
3705  if(arg_i > arg_j)
3706  {
3707  return (state->states[arg_i][arg_j] == HASTREP);
3708  }
3709  else
3710  {
3711  return (state->states[arg_j][arg_i] == HASTREP);
3712  }
3713 }

◆ init_with_mac_poly()

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

Definition at line 3103 of file tgb.cc.

3104 {
3105  assume (mat->mp[row] == NULL);
3106  mat->mp[row] = m;
3107 #ifdef TGB_DEBUG
3108  mac_poly r = m;
3109  while(r)
3110  {
3111  assume (r->exp < mat->columns);
3112  r = r->next;
3113  }
3114 #endif
3115 }

◆ iq_crit()

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

Definition at line 1292 of file tgb.cc.

1293 {
1294  sorted_pair_node *a = *((sorted_pair_node **) ap);
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:4103
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:105
wlen_type expected_length
Definition: tgb_internal.h:146

◆ 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
Definition: tgb_internal.h:296
void validate()
Definition: tgb.cc:4868

◆ 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  int 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:354

◆ 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));
232  if(rField_is_Q (currRing))
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  {
249  if(rField_is_Q (currRing))
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:140

◆ 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;
1907  c->extended_product_crit++;
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;
1917  c->extended_product_crit++;
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:400
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 }
static BOOLEAN pair_better(sorted_pair_node *a, sorted_pair_node *b, slimgb_alg *c=NULL)
Definition: tgb.cc:3962
sorted_pair_node ** add_to_basis_ideal_quotient(poly h, slimgb_alg *c, int *ip)
Definition: tgb.cc:1378

◆ 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:593

◆ 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:342
intset ecartS
Definition: kutil.h:309
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 4936 of file tgb.cc.

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

◆ multi_reduction()

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

Definition at line 4679 of file tgb.cc.

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

◆ 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 4569 of file tgb.cc.

4570 {
4571  int deleted = 0;
4572  int i = l;
4573  int last = -1;
4574  while(i <= u)
4575  {
4576  if((los[i].p == NULL)
4577  || (TEST_OPT_IDLIFT && (p_GetComp(los[i].p,currRing) > syzComp)))
4578  {
4579  kBucketDeleteAndDestroy (&los[i].bucket);
4580 // delete los[i];//here we assume los are constructed with new
4581  //destroy resources, must be added here
4582  if(last >= 0)
4583  {
4584  memmove (los + (int) (last + 1 - deleted), los + (last + 1),
4585  sizeof (red_object) * (i - 1 - last));
4586  }
4587  last = i;
4588  deleted++;
4589  }
4590  i++;
4591  }
4592  if((last >= 0) && (last != losl - 1))
4593  memmove (los + (int) (last + 1 - deleted), los + last + 1,
4594  sizeof (red_object) * (losl - 1 - last));
4595  return deleted;
4596 }
STATIC_VAR poly last
Definition: hdegree.cc:1173
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 4495 of file tgb.cc.

4502 {
4503  kStrategy strat = c->strat;
4504 
4505  #ifndef SING_NDEBUG
4506  assume (startf <= losl);
4507  assume ((startf == losl - 1)
4508  || (pLmCmp (los[startf].p, los[startf + 1].p) == -1));
4509  #endif
4510  int i = startf;
4511 
4512  int j;
4513  while(i >= 0)
4514  {
4515  #ifndef SING_NDEBUG
4516  assume ((i == losl - 1) || (pLmCmp (los[i].p, los[i + 1].p) <= 0));
4517  #endif
4518  assume (is_valid_ro (los[i]));
4519  j = kFindDivisibleByInS_easy (strat, los[i]);
4520  if(j >= 0)
4521  {
4522  erg.to_reduce_u = i;
4523  erg.reduce_by = j;
4524  erg.fromS = TRUE;
4525  int i2 = fwbw (los, i);
4526  assume (pLmEqual (los[i].p, los[i2].p));
4527  assume ((i2 == 0) || (!pLmEqual (los[i2].p, los[i2 - 1].p)));
4528  assume (i >= i2);
4529 
4530  erg.to_reduce_l = i2;
4531  #ifndef SING_NDEBUG
4532  assume ((i == losl - 1) || (pLmCmp (los[i].p, los[i + 1].p) == -1));
4533  #endif
4534  canonicalize_region (los, erg.to_reduce_u + 1, startf, c);
4535  return;
4536  }
4537  else /*if(j < 0)*/
4538  {
4539  //not reduceable, try to use this for reducing higher terms
4540  int i2 = fwbw (los, i);
4541  assume (pLmEqual (los[i].p, los[i2].p));
4542  assume ((i2 == 0) || (!pLmEqual (los[i2].p, los[i2 - 1].p)));
4543  assume (i >= i2);
4544  if(i2 != i)
4545  {
4546  erg.to_reduce_u = i - 1;
4547  erg.to_reduce_l = i2;
4548  erg.reduce_by = i;
4549  erg.fromS = FALSE;
4550  #ifndef SING_NDEBUG
4551  assume ((i == losl - 1) || (pLmCmp (los[i].p, los[i + 1].p) == -1));
4552  #endif
4553  canonicalize_region (los, erg.to_reduce_u + 1, startf, c);
4554  return;
4555  }
4556  i--;
4557  }
4558  }
4559  erg.reduce_by = -1; //error code
4560  return;
4561 }
static int fwbw(red_object *los, int i)
Definition: tgb.cc:4425
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:4483

◆ multi_reduction_lls_trick()

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

Definition at line 4165 of file tgb.cc.

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

◆ now_t_rep()

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

Definition at line 3674 of file tgb.cc.

3675 {
3676  int i, j;
3677  if(arg_i == arg_j)
3678  {
3679  return;
3680  }
3681  if(arg_i > arg_j)
3682  {
3683  i = arg_j;
3684  j = arg_i;
3685  }
3686  else
3687  {
3688  i = arg_i;
3689  j = arg_j;
3690  }
3691  c->states[j][i] = HASTREP;
3692 }

◆ 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 poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1322
STATIC_VAR omBin lm_bin
Definition: tgb.cc:41

◆ pair_better()

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

Definition at line 3962 of file tgb.cc.

3963 {
3964  if(a->deg < b->deg)
3965  return TRUE;
3966  if(a->deg > b->deg)
3967  return FALSE;
3968 
3969  int comp = pLmCmp (a->lcm_of_lm, b->lcm_of_lm);
3970  if(comp == 1)
3971  return FALSE;
3972  if(-1 == comp)
3973  return TRUE;
3974  if(a->expected_length < b->expected_length)
3975  return TRUE;
3976  if(a->expected_length > b->expected_length)
3977  return FALSE;
3978  if(a->i + a->j < b->i + b->j)
3979  return TRUE;
3980  if(a->i + a->j > b->i + b->j)
3981  return FALSE;
3982  if(a->i < b->i)
3983  return TRUE;
3984  if(a->i > b->i)
3985  return FALSE;
3986  return TRUE;
3987 }

◆ 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
Definition: tgb_internal.h:261
#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 4061 of file tgb.cc.

4062 {
4063 
4064  if(pGetComp (p1) > 0 || pGetComp (p2) > 0)
4065  return FALSE;
4066  int i = 1;
4067  loop
4068  {
4069  if((pGetExp (p1, i) - pGetExp (m, i) > 0)
4070  && (pGetExp (p2, i) - pGetExp (m, i) > 0))
4071  return FALSE;
4072  if(i == (currRing->N))
4073  return TRUE;
4074  i++;
4075  }
4076 }
#define loop
Definition: structs.h:75

◆ poly_crit()

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

Definition at line 3138 of file tgb.cc.

3139 {
3140  poly p1, p2;
3141  p1 = *((poly *) ap1);
3142  p2 = *((poly *) ap2);
3143 
3144  int c = pLmCmp (p1, p2);
3145  if(c != 0)
3146  return c;
3147  int l1 = pLength (p1);
3148  int l2 = pLength (p2);
3149  if(l1 < l2)
3150  return -1;
3151  if(l1 > l2)
3152  return 1;
3153  return 0;
3154 }

◆ 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:538
#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);
531  if(rField_is_Q (currRing))
532  {
533  cs = nlQlogSize (coef, currRing->cf);
534  }
535  else
536  cs = nSize (coef);
537  wlen_type erg = cs;
538  if(TEST_V_COEFSTRAT)
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);
201  if(rField_is_Q (currRing))
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 4142 of file tgb.cc.

4143 {
4144  if(c->strat->lenSw != NULL)
4145  return c->strat->lenSw[pos];
4146  return c->strat->lenS[pos];
4147 }

◆ 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 4151 of file tgb.cc.

4153 {
4154  poly m = pOne ();
4155  pExpVectorDiff (m, high, c->strat->S[pos]);
4156  poly product = nc_mm_Mult_pp (m, c->strat->S[pos], c->r);
4157  wlen_type erg = pQuality (product, c);
4158  pDelete (&m);
4159  pDelete (&product);
4160  return erg;
4161 }
#define pExpVectorDiff(pr, p1, p2)
Definition: polys.h:91

◆ quick_pop_pair()

sorted_pair_node* quick_pop_pair ( slimgb_alg c)

Definition at line 3900 of file tgb.cc.

3901 {
3902  if(c->pair_top < 0)
3903  return NULL;
3904  else
3905  return (c->apairs[c->pair_top--]);
3906 }

◆ 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:329
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition: kbuckets.cc:1085
#define nNormalize(n)
Definition: numbers.h:30
#define nMult(n1, n2)
Definition: numbers.h:17
#define TEST_OPT_DEBUG
Definition: options.h:108
#define pNormalize(p)
Definition: polys.h:317
void PrintLn()
Definition: reporter.cc:310

◆ redNFTail()

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

Definition at line 2991 of file tgb.cc.

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

◆ 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 dependend search
1239  omFree (i_con);
1240  omFree (j_con);
1241  return;
1242 }
int_pair_node * soon_free
Definition: tgb_internal.h:228

◆ search_red_object_pos()

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

Definition at line 4598 of file tgb.cc.

4599 {
4600  int an = 0;
4601  int en = top;
4602  if(top == -1)
4603  return 0;
4604  if(pLmCmp (key->p, a[top].p) == 1)
4605  return top + 1;
4606  int i;
4607  loop
4608  {
4609  if(an >= en - 1)
4610  {
4611  if(pLmCmp (key->p, a[an].p) == -1)
4612  return an;
4613  return en;
4614  }
4615  i = (an + en) / 2;
4616  if(pLmCmp (key->p, a[i].p) == -1)
4617  en = i;
4618  else
4619  an = i;
4620  }
4621 }

◆ shorten_tails()

static void shorten_tails ( slimgb_alg c,
poly  monom 
)
static

Definition at line 3715 of file tgb.cc.

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

◆ 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:55
int pos_helper(kStrategy strat, poly p, len_type len, set_type setL, polyset set)
Definition: tgb_internal.h:379

◆ 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:570
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:501

◆ sort_region_down()

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

Definition at line 4623 of file tgb.cc.

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

◆ 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 3935 of file tgb.cc.

3937 {
3938  assume (0 <= arg_i);
3939  assume (0 <= arg_j);
3940  assume (arg_i < c->n);
3941  assume (arg_j < c->n);
3942  if(arg_i == arg_j)
3943  {
3944  return (TRUE);
3945  }
3946  if(arg_i > arg_j)
3947  {
3948  return (c->states[arg_i][arg_j] == state);
3949  }
3950  else
3951  return (c->states[arg_j][arg_i] == state);
3952 }

◆ super_clean_top_of_pair_list()

static void super_clean_top_of_pair_list ( slimgb_alg c)
static

Definition at line 3908 of file tgb.cc.

3909 {
3910  while((c->pair_top >= 0)
3911  && (c->apairs[c->pair_top]->i >= 0)
3912  &&
3914  (c->apairs[c->pair_top]->j, c->apairs[c->pair_top]->i, c)))
3915  {
3916  free_sorted_pair_node (c->apairs[c->pair_top], c->r);
3917  c->pair_top--;
3918  }
3919 }
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 3571 of file tgb.cc.

3572 {
3573  assume (r == currRing);
3574  ring orig_ring = r;
3575  int pos;
3576  ring new_ring = rAssure_TDeg (orig_ring, pos);
3577  ideal s_h;
3578  if(orig_ring != new_ring)
3579  {
3580  rChangeCurrRing (new_ring);
3581  s_h = idrCopyR_NoSort (arg_I, orig_ring, new_ring);
3582  /*int i;
3583  for(i=0;i<IDELEMS(s_h);i++)
3584  {
3585  poly p=s_h->m[i];
3586  while(p)
3587  {
3588  p_Setm(p,new_ring);
3589  pIter(p);
3590  }
3591  } */
3592  }
3593  else
3594  {
3595  s_h = id_Copy (arg_I, orig_ring);
3596  }
3597  idTest (s_h);
3598 
3599  ideal s_result = do_t_rep_gb (new_ring, s_h, syz_comp, F4_mode, pos);
3600  ideal result;
3601  if(orig_ring != new_ring)
3602  {
3603  idTest (s_result);
3604  rChangeCurrRing (orig_ring);
3605  result = idrMoveR_NoSort (s_result, new_ring, orig_ring);
3606 
3607  idTest (result);
3608  //rChangeCurrRing(new_ring);
3609  rDelete(new_ring);
3610  //rChangeCurrRing(orig_ring);
3611  }
3612  else
3613  result = s_result;
3614  idTest (result);
3615  return result;
3616 }
return result
Definition: facAbsBiFact.cc:75
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:15
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:4607
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
ideal do_t_rep_gb(ring, ideal arg_I, int syz_comp, BOOLEAN F4_mode, int deg_pos)
Definition: tgb.cc:3619

◆ 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 3989 of file tgb.cc.

3990 {
3991  sorted_pair_node *a = *((sorted_pair_node **) ap);
3992  sorted_pair_node *b = *((sorted_pair_node **) bp);
3993  assume ((a->i > a->j) || (a->i < 0));
3994  assume ((b->i > b->j) || (b->i < 0));
3995  if(a->deg < b->deg)
3996  return -1;
3997  if(a->deg > b->deg)
3998  return 1;
3999 
4000  int comp = pLmCmp (a->lcm_of_lm, b->lcm_of_lm);
4001 
4002  if(comp == 1)
4003  return 1;
4004  if(-1 == comp)
4005  return -1;
4006  if(a->expected_length < b->expected_length)
4007  return -1;
4008  if(a->expected_length > b->expected_length)
4009  return 1;
4010  if(a->i + a->j < b->i + b->j)
4011  return -1;
4012  if(a->i + a->j > b->i + b->j)
4013  return 1;
4014  if(a->i < b->i)
4015  return -1;
4016  if(a->i > b->i)
4017  return 1;
4018  return 0;
4019 }

◆ 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:3989

◆ top_pair()

sorted_pair_node* top_pair ( slimgb_alg c)

Definition at line 3876 of file tgb.cc.

3877 {
3878  while(c->pair_top >= 0)
3879  {
3880  super_clean_top_of_pair_list (c); //yeah, I know, it's odd that I use a different proc here
3881  if((c->is_homog) && (c->pair_top >= 0)
3882  && (c->apairs[c->pair_top]->deg >= c->lastCleanedDeg + 2))
3883  {
3884  int upper = c->apairs[c->pair_top]->deg - 1;
3885  c->cleanDegs (c->lastCleanedDeg + 1, upper);
3886  c->lastCleanedDeg = upper;
3887  }
3888  else
3889  {
3890  break;
3891  }
3892  }
3893 
3894  if(c->pair_top < 0)
3895  return NULL;
3896  else
3897  return (c->apairs[c->pair_top]);
3898 }
int lastCleanedDeg
Definition: tgb_internal.h:257
void cleanDegs(int lower, int upper)
Definition: tgb.cc:3794
static void super_clean_top_of_pair_list(slimgb_alg *c)
Definition: tgb.cc:3908

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