My Project
Data Structures | Macros | Typedefs | Enumerations | Functions
tgb_internal.h File Reference
#include "omalloc/omalloc.h"
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include "misc/options.h"
#include "coeffs/modulop.h"
#include "polys/monomials/p_polys.h"
#include "polys/monomials/ring.h"
#include "polys/kbuckets.h"
#include "kernel/ideals.h"
#include "kernel/polys.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/kInline.h"
#include "kernel/GBEngine/kstd1.h"
#include "coeffs/modulop_inl.h"

Go to the source code of this file.

Data Structures

class  PolySimple
 
class  MonRedResNP< number_type >
 
struct  sorted_pair_node
 
struct  poly_list_node
 
struct  int_pair_node
 
struct  monom_poly
 
struct  mp_array_list
 
struct  poly_array_list
 
class  slimgb_alg
 
class  red_object
 
class  reduction_step
 makes on each red_object in a region a single_step More...
 
class  simple_reducer
 
struct  find_erg
 
class  NoroCacheNode
 
class  DenseRow
 
class  SparseRow< number_type >
 
class  DataNoroCacheNode< number_type >
 
class  TermNoroDataNode< number_type >
 
class  NoroCache< number_type >
 
class  CoefIdx< number_type >
 
class  ModPMatrixProxyOnArray< number_type >
 
class  ModPMatrixBackSubstProxyOnArray< number_type >
 

Macros

#define USE_NORO   1
 
#define FULLREDUCTIONS
 
#define REDTAIL_S
 
#define PAR_N   100
 
#define PAR_N_F4   5000
 
#define AC_NEW_MIN   2
 
#define AC_FLATTEN   1
 
#define NORO_CACHE   1
 
#define NORO_SPARSE_ROWS_PRE   1
 
#define NORO_NON_POLY   1
 
#define slim_prec_cast(a)   (unsigned int) (unsigned long) (a)
 
#define F4mat_to_number_type(a)   (number_type) slim_prec_cast(a)
 

Typedefs

typedef unsigned short tgb_uint16
 
typedef unsigned char tgb_uint8
 
typedef unsigned int tgb_uint32
 

Enumerations

enum  calc_state { UNCALCULATED , HASTREP }
 

Functions

template<class len_type , class set_type >
int pos_helper (kStrategy strat, poly p, len_type len, set_type setL, polyset set)
 
void free_sorted_pair_node (sorted_pair_node *s, const ring r)
 
ideal do_t_rep_gb (ring r, 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)
 
void clean_top_of_pair_list (slimgb_alg *c)
 
int slim_nsize (number n, ring r)
 
sorted_pair_nodequick_pop_pair (slimgb_alg *c)
 
sorted_pair_nodetop_pair (slimgb_alg *c)
 
sorted_pair_node ** add_to_basis_ideal_quotient (poly h, slimgb_alg *c, int *ip)
 
sorted_pair_node ** spn_merge (sorted_pair_node **p, int pn, sorted_pair_node **q, int qn, slimgb_alg *c)
 
int kFindDivisibleByInS_easy (kStrategy strat, const red_object &obj)
 
int tgb_pair_better_gen2 (const void *ap, const void *bp)
 
int kFindDivisibleByInS_easy (kStrategy strat, poly p, long sev)
 
template<class number_type >
SparseRow< number_type > * noro_red_to_non_poly_t (poly p, int &len, NoroCache< number_type > *cache, slimgb_alg *c)
 
template<class number_type >
MonRedResNP< number_type > noro_red_mon_to_non_poly (poly t, NoroCache< number_type > *cache, slimgb_alg *c)
 
template<class number_type >
SparseRow< number_type > * convert_to_sparse_row (number_type *temp_array, int temp_size, int non_zeros)
 
template<class number_type >
void add_coef_times_sparse (number_type *const temp_array, int, SparseRow< number_type > *row, number coef)
 
template<class number_type >
void add_coef_times_dense (number_type *const temp_array, int, const number_type *row, int len, number coef)
 
template<class number_type >
void add_dense (number_type *const temp_array, int, const number_type *row, int len)
 
template<class number_type >
void sub_dense (number_type *const temp_array, int, const number_type *row, int len)
 
template<class number_type >
void add_sparse (number_type *const temp_array, int, SparseRow< number_type > *row)
 
template<class number_type >
void sub_sparse (number_type *const temp_array, int, SparseRow< number_type > *row)
 
template<class number_type >
SparseRow< number_type > * noro_red_to_non_poly_dense (MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)
 
template<class number_type >
void write_coef_times_xx_idx_to_buffer (CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen, const number coef)
 
template<class number_type >
void write_coef_times_xx_idx_to_buffer_dense (CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen, const number coef)
 
template<class number_type >
void write_coef_idx_to_buffer_dense (CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)
 
template<class number_type >
void write_minus_coef_idx_to_buffer_dense (CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)
 
template<class number_type >
void write_coef_idx_to_buffer (CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen)
 
template<class number_type >
void write_minus_coef_idx_to_buffer (CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen)
 
template<class number_type >
SparseRow< number_type > * noro_red_to_non_poly_sparse (MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)
 
int terms_sort_crit (const void *a, const void *b)
 
template<class number_type >
void write_poly_to_row (number_type *row, poly h, poly *terms, int tn)
 
template<class number_type >
poly row_to_poly (number_type *row, poly *terms, int tn, ring r)
 
template<class number_type >
int modP_lastIndexRow (number_type *row, int ncols)
 
template<class number_type >
int term_nodes_sort_crit (const void *a, const void *b)
 
template<class number_type >
void simplest_gauss_modp (number_type *a, int nrows, int ncols)
 
template<class number_type >
void noro_step (poly *p, int &pn, slimgb_alg *c)
 

Data Structure Documentation

◆ sorted_pair_node

struct sorted_pair_node

Definition at line 144 of file tgb_internal.h.

Data Fields
int deg
wlen_type expected_length
int i
int j
poly lcm_of_lm

◆ poly_list_node

struct poly_list_node

Definition at line 168 of file tgb_internal.h.

Data Fields
poly_list_node * next
poly p

◆ int_pair_node

struct int_pair_node

Definition at line 174 of file tgb_internal.h.

Data Fields
int a
int b
int_pair_node * next

◆ monom_poly

struct monom_poly

Definition at line 180 of file tgb_internal.h.

Data Fields
poly f
poly m

◆ mp_array_list

struct mp_array_list

Definition at line 185 of file tgb_internal.h.

Data Fields
monom_poly * mp
mp_array_list * next
int size

◆ poly_array_list

struct poly_array_list

Definition at line 193 of file tgb_internal.h.

Data Fields
poly_array_list * next
poly * p
int size

◆ find_erg

struct find_erg

Definition at line 372 of file tgb_internal.h.

Data Fields
poly expand
int expand_length
BOOLEAN fromS
int reduce_by
int to_reduce_l
int to_reduce_u

◆ TermNoroDataNode

class TermNoroDataNode

template<class number_type>
class TermNoroDataNode< number_type >

Definition at line 569 of file tgb_internal.h.

Data Fields
DataNoroCacheNode< number_type > * node
poly t

Macro Definition Documentation

◆ AC_FLATTEN

#define AC_FLATTEN   1

Definition at line 23 of file tgb_internal.h.

◆ AC_NEW_MIN

#define AC_NEW_MIN   2

Definition at line 22 of file tgb_internal.h.

◆ F4mat_to_number_type

#define F4mat_to_number_type (   a)    (number_type) slim_prec_cast(a)

Definition at line 414 of file tgb_internal.h.

◆ FULLREDUCTIONS

#define FULLREDUCTIONS

Definition at line 15 of file tgb_internal.h.

◆ NORO_CACHE

#define NORO_CACHE   1

Definition at line 29 of file tgb_internal.h.

◆ NORO_NON_POLY

#define NORO_NON_POLY   1

Definition at line 31 of file tgb_internal.h.

◆ NORO_SPARSE_ROWS_PRE

#define NORO_SPARSE_ROWS_PRE   1

Definition at line 30 of file tgb_internal.h.

◆ PAR_N

#define PAR_N   100

Definition at line 20 of file tgb_internal.h.

◆ PAR_N_F4

#define PAR_N_F4   5000

Definition at line 21 of file tgb_internal.h.

◆ REDTAIL_S

#define REDTAIL_S

Definition at line 19 of file tgb_internal.h.

◆ slim_prec_cast

#define slim_prec_cast (   a)    (unsigned int) (unsigned long) (a)

Definition at line 413 of file tgb_internal.h.

◆ USE_NORO

#define USE_NORO   1

Definition at line 10 of file tgb_internal.h.

Typedef Documentation

◆ tgb_uint16

typedef unsigned short tgb_uint16

Definition at line 415 of file tgb_internal.h.

◆ tgb_uint32

typedef unsigned int tgb_uint32

Definition at line 417 of file tgb_internal.h.

◆ tgb_uint8

typedef unsigned char tgb_uint8

Definition at line 416 of file tgb_internal.h.

Enumeration Type Documentation

◆ calc_state

enum calc_state
Enumerator
UNCALCULATED 
HASTREP 

Definition at line 311 of file tgb_internal.h.

312  {
313  UNCALCULATED,
314  HASTREP//,
315  //UNIMPORTANT,
316  //SOONTREP
317  };
@ UNCALCULATED
Definition: tgb_internal.h:313
@ HASTREP
Definition: tgb_internal.h:314

Function Documentation

◆ add_coef_times_dense()

template<class number_type >
void add_coef_times_dense ( number_type *const  temp_array,
int  ,
const number_type *  row,
int  len,
number  coef 
)

Definition at line 939 of file tgb_internal.h.

945 {
946  int j;
947  const number_type* const coef_array=row;
948  //int* const idx_array=row->idx_array;
949  //const int len=temp_size;
950  tgb_uint32 buffer[256];
951  const tgb_uint32 prime=n_GetChar(currRing->cf);
952  const tgb_uint32 c=F4mat_to_number_type(coef);
953  assume(!(npIsZero(coef,currRing->cf)));
954  for(j=0;j<len;j=j+256)
955  {
956  const int bound=std::min(j+256,len);
957  int i;
958  int bpos=0;
959  for(i=j;i<bound;i++)
960  {
961  buffer[bpos++]=coef_array[i];
962  }
963  int bpos_bound=bound-j;
964  for(i=0;i<bpos_bound;i++)
965  {
966  buffer[i]*=c;
967  }
968  for(i=0;i<bpos_bound;i++)
969  {
970  buffer[i]=buffer[i]%prime;
971  }
972  bpos=0;
973  for(i=j;i<bound;i++)
974  {
975  //int idx=idx_array[i];
976  assume(bpos<256);
977  //assume(!(npIsZero((number) buffer[bpos])));
978  temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) buffer[bpos++],currRing->cf));
979  #ifndef SING_NDEBUG
980  assume(i<temp_size);
981  #endif
982  }
983 
984  }
985 }
int i
Definition: cfEzgcd.cc:132
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
int j
Definition: facHensel.cc:110
static int min(int a, int b)
Definition: fast_mult.cc:268
#define assume(x)
Definition: mod2.h:387
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:124
static BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop_inl.h:38
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
unsigned int tgb_uint32
Definition: tgb_internal.h:417
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:414

◆ add_coef_times_sparse()

template<class number_type >
void add_coef_times_sparse ( number_type *const  temp_array,
int  ,
SparseRow< number_type > *  row,
number  coef 
)

Definition at line 891 of file tgb_internal.h.

897 {
898  int j;
899  number_type* const coef_array=row->coef_array;
900  int* const idx_array=row->idx_array;
901  const int len=row->len;
902  tgb_uint32 buffer[256];
903  const tgb_uint32 prime=n_GetChar(currRing->cf);
904  const tgb_uint32 c=F4mat_to_number_type(coef);
905  assume(!(npIsZero(coef,currRing->cf)));
906  for(j=0;j<len;j=j+256)
907  {
908  const int bound=std::min(j+256,len);
909  int i;
910  int bpos=0;
911  for(i=j;i<bound;i++)
912  {
913  buffer[bpos++]=coef_array[i];
914  }
915  int bpos_bound=bound-j;
916  for(i=0;i<bpos_bound;i++)
917  {
918  buffer[i]*=c;
919  }
920  for(i=0;i<bpos_bound;i++)
921  {
922  buffer[i]=buffer[i]%prime;
923  }
924  bpos=0;
925  for(i=j;i<bound;i++)
926  {
927  int idx=idx_array[i];
928  assume(bpos<256);
929  assume(!(npIsZero((number)(long) buffer[bpos],currRing->cf)));
930  temp_array[idx]=F4mat_to_number_type(npAddM((number)(long) temp_array[idx], (number)(long) buffer[bpos++],currRing->cf));
931  #ifndef SING_NDEBUG
932  assume(idx<temp_size);
933  #endif
934  }
935 
936  }
937 }
number_type * coef_array
Definition: tgb_internal.h:504
int * idx_array
Definition: tgb_internal.h:503

◆ add_dense()

template<class number_type >
void add_dense ( number_type *const  temp_array,
int  ,
const number_type *  row,
int  len 
)

Definition at line 987 of file tgb_internal.h.

993 {
994  //int j;
995  //const number_type* const coef_array=row;
996  //int* const idx_array=row->idx_array;
997  //const int len=temp_size;
998  //tgb_uint32 buffer[256];
999  //const tgb_uint32 prime=npPrimeM;
1000  //const tgb_uint32 c=F4mat_to_number_type(coef);
1001 
1002  int i;
1003  for(i=0;i<len;i++)
1004  {
1005  temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
1006  #ifndef SING_NDEBUG
1007  assume(i<temp_size);
1008  #endif
1009  }
1010 
1011 }

◆ add_sparse()

template<class number_type >
void add_sparse ( number_type *const  temp_array,
int  ,
SparseRow< number_type > *  row 
)

Definition at line 1039 of file tgb_internal.h.

1043 {
1044  int j;
1045 
1046  number_type* const coef_array=row->coef_array;
1047  int* const idx_array=row->idx_array;
1048  const int len=row->len;
1049  for(j=0;j<len;j++)
1050  {
1051  int idx=idx_array[j];
1052  temp_array[idx]=F4mat_to_number_type( (number_type)(long)npAddM((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
1053  #ifndef SING_NDEBUG
1054  assume(idx<temp_size);
1055  #endif
1056  }
1057 }

◆ add_to_basis_ideal_quotient()

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

Definition at line 1389 of file tgb.cc.

1391 {
1392  p_Test (h, c->r);
1393  assume (h != NULL);
1394  poly got = gcd_of_terms (h, c->r);
1395  if((got != NULL) && (TEST_V_UPTORADICAL))
1396  {
1397  poly copy = p_Copy (got, c->r);
1398  //p_wrp(got,c->r);
1399  BOOLEAN changed = monomial_root (got, c->r);
1400  if(changed)
1401  {
1402  poly div_by = pMDivide (copy, got);
1403  poly iter = h;
1404  while(iter)
1405  {
1406  pExpVectorSub (iter, div_by);
1407  pIter (iter);
1408  }
1409  p_Delete (&div_by, c->r);
1410  PrintS ("U");
1411  }
1412  p_Delete (&copy, c->r);
1413  }
1414 
1415 #define ENLARGE(pointer, type) pointer=(type*) omreallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type))
1416 
1417 #define ENLARGE_ALIGN(pointer, type) {if(pointer)\
1418  pointer=(type*)omReallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type));\
1419  else pointer=(type*)omAllocAligned(c->array_lengths*sizeof(type));}
1420 // BOOLEAN corr=lenS_correct(c->strat);
1421  int sugar;
1422  int ecart = 0;
1423  ++(c->n);
1424  ++(c->S->ncols);
1425  int i, j;
1426  i = c->n - 1;
1427  sorted_pair_node **nodes =
1428  (sorted_pair_node **) omalloc (sizeof (sorted_pair_node *) * i);
1429  int spc = 0;
1430  int old=c->array_lengths;
1431  if(c->n > c->array_lengths)
1432  {
1433  c->array_lengths = c->array_lengths * 2;
1434  assume (c->array_lengths >= c->n);
1435  ENLARGE (c->T_deg, int);
1436  ENLARGE_ALIGN (c->tmp_pair_lm, poly);
1438 
1439  ENLARGE_ALIGN (c->short_Exps, long);
1440  ENLARGE (c->lengths, int);
1441 #ifndef HAVE_BOOST
1442 #ifndef USE_STDVECBOOL
1443 
1444  ENLARGE_ALIGN (c->states, char *);
1445 #endif
1446 #endif
1447  ENLARGE_ALIGN (c->gcd_of_terms, poly);
1448  //if (c->weighted_lengths!=NULL) {
1450  //}
1451  //ENLARGE_ALIGN(c->S->m,poly);
1452  }
1453  pEnlargeSet (&c->S->m, c->n - 1, 1);
1454  if(c->T_deg_full)
1455  ENLARGE (c->T_deg_full, int);
1456  sugar = c->T_deg[i] = c->pTotaldegree (h);
1457  if(c->T_deg_full)
1458  {
1459  sugar = c->T_deg_full[i] = c->pTotaldegree_full (h);
1460  ecart = sugar - c->T_deg[i];
1461  assume (ecart >= 0);
1462  }
1463  c->tmp_pair_lm[i] = pOne_Special (c->r);
1464 
1465  c->tmp_spn[i] = (sorted_pair_node *) omAlloc (sizeof (sorted_pair_node));
1466 
1467  c->lengths[i] = pLength (h);
1468 
1469  //necessary for correct weighted length
1470 
1472  {
1473  p_Cleardenom (h, c->r); //includes p_Content(h,c->r);
1474  }
1475  else
1476  pNorm (h);
1477  //pNormalize (h);
1478 
1479  c->weighted_lengths[i] = pQuality (h, c, c->lengths[i]);
1480  c->gcd_of_terms[i] = got;
1481 #ifdef HAVE_BOOST
1482  c->states.push_back (dynamic_bitset <> (i));
1483 
1484 #else
1485 #ifdef USE_STDVECBOOL
1486 
1487  c->states.push_back (vector < bool > (i));
1488 
1489 #else
1490  if(i > 0)
1491  c->states[i] = (char *) omAlloc (i * sizeof (char));
1492  else
1493  c->states[i] = NULL;
1494 #endif
1495 #endif
1496 
1497  c->S->m[i] = h;
1498  c->short_Exps[i] = p_GetShortExpVector (h, c->r);
1499 
1500 #undef ENLARGE
1501 #undef ENLARGE_ALIGN
1502  if(p_GetComp (h, currRing) <= c->syz_comp)
1503  {
1504  for(j = 0; j < i; j++)
1505  {
1506 
1507 
1508 #ifndef HAVE_BOOST
1509  c->states[i][j] = UNCALCULATED;
1510 #endif
1511  assume (p_LmDivisibleBy (c->S->m[i], c->S->m[j], c->r) ==
1512  p_LmShortDivisibleBy (c->S->m[i], c->short_Exps[i], c->S->m[j],
1513  ~(c->short_Exps[j]), c->r));
1514 
1515  if(__p_GetComp (c->S->m[i], c->r) != __p_GetComp (c->S->m[j], c->r))
1516  {
1517  //c->states[i][j]=UNCALCULATED;
1518  //WARNUNG: be careful
1519  continue;
1520  }
1521  else if((!c->nc) && (c->lengths[i] == 1) && (c->lengths[j] == 1))
1522  {
1523  c->states[i][j] = HASTREP;
1524  }
1525  else if(((!c->nc) || (c->is_homog && rIsSCA (c->r)))
1526  && (pHasNotCF (c->S->m[i], c->S->m[j])))
1527 // else if ((!(c->nc)) && (pHasNotCF(c->S->m[i],c->S->m[j])))
1528  {
1529  c->easy_product_crit++;
1530  c->states[i][j] = HASTREP;
1531  continue;
1532  }
1533  else
1535  (c->S->m[i], c->gcd_of_terms[i], c->S->m[j], c->gcd_of_terms[j],
1536  c))
1537  {
1538  c->states[i][j] = HASTREP;
1539  c->extended_product_crit++;
1540  //PrintS("E");
1541  }
1542  // if (c->states[i][j]==UNCALCULATED)
1543  // {
1544 
1545  if((TEST_V_FINDMONOM) && (!c->nc))
1546  {
1547  //PrintS("COMMU");
1548  // if (c->lengths[i]==c->lengths[j])
1549  // {
1550 // poly short_s=ksCreateShortSpoly(c->S->m[i],c->S->m[j],c->r);
1551 // if (short_s==NULL)
1552 // {
1553 // c->states[i][j]=HASTREP;
1554 // }
1555 // else
1556 // {
1557 // p_Delete(&short_s, currRing);
1558 // }
1559 // }
1560  if(c->lengths[i] + c->lengths[j] == 3)
1561  {
1562 
1563 
1564  poly short_s = ksCreateShortSpoly (c->S->m[i], c->S->m[j], c->r);
1565  if(short_s == NULL)
1566  {
1567  c->states[i][j] = HASTREP;
1568  }
1569  else
1570  {
1571  assume (pLength (short_s) == 1);
1572  if(TEST_V_UPTORADICAL)
1573  monomial_root (short_s, c->r);
1574  int iS = kFindDivisibleByInS_easy (c->strat, short_s,
1575  p_GetShortExpVector (short_s,
1576  c->r));
1577  if(iS < 0)
1578  {
1579  //PrintS("N");
1580  if(TRUE)
1581  {
1582  c->states[i][j] = HASTREP;
1583  add_later (short_s, "N", c);
1584  }
1585  else
1586  p_Delete (&short_s, currRing);
1587  }
1588  else
1589  {
1590  if(c->strat->lenS[iS] > 1)
1591  {
1592  //PrintS("O");
1593  if(TRUE)
1594  {
1595  c->states[i][j] = HASTREP;
1596  add_later (short_s, "O", c);
1597  }
1598  else
1599  p_Delete (&short_s, currRing);
1600  }
1601  else
1602  p_Delete (&short_s, currRing);
1603  c->states[i][j] = HASTREP;
1604  }
1605 
1606 
1607  }
1608  }
1609  }
1610  // if (short_s)
1611  // {
1612  assume (spc <= j);
1613  sorted_pair_node *s = c->tmp_spn[spc]; //(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
1614  if (i>j) { s->i=i; s->j=j;}
1615  else { s->i=j; s->j=i;}
1616  s->expected_length = pair_weighted_length (i, j, c); //c->lengths[i]+c->lengths[j]-2;
1617 
1618  poly lm = c->tmp_pair_lm[spc]; //=pOne_Special();
1619 
1620  pLcm (c->S->m[i], c->S->m[j], lm);
1621  pSetm (lm);
1622  p_Test (lm, c->r);
1623  s->deg = c->pTotaldegree (lm);
1624 
1625  if(c->T_deg_full) //Sugar
1626  {
1627  int t_i = c->T_deg_full[s->i] - c->T_deg[s->i];
1628  int t_j = c->T_deg_full[s->j] - c->T_deg[s->j];
1629  s->deg += si_max (t_i, t_j);
1630  //Print("\n max: %d\n",max(t_i,t_j));
1631  }
1632  p_Test (lm, c->r);
1633  s->lcm_of_lm = lm;
1634  // pDelete(&short_s);
1635  //assume(lm!=NULL);
1636  nodes[spc] = s;
1637  spc++;
1638 
1639  // }
1640  //else
1641  //{
1642  //c->states[i][j]=HASTREP;
1643  //}
1644  }
1645  } //if syz_comp end
1646 
1647  assume (spc <= i);
1648  //now ideal quotient crit
1649  qsort (nodes, spc, sizeof (sorted_pair_node *), iq_crit);
1650 
1651  sorted_pair_node **nodes_final =
1652  (sorted_pair_node **) omalloc (sizeof (sorted_pair_node *) * (i+1));
1653  int spc_final = 0;
1654  j = 0;
1655  while(j < spc)
1656  {
1657  int lower = j;
1658  int upper;
1659  BOOLEAN has = FALSE;
1660  for(upper = lower + 1; upper < spc; upper++)
1661  {
1662  if(!pLmEqual (nodes[lower]->lcm_of_lm, nodes[upper]->lcm_of_lm))
1663  {
1664  break;
1665  }
1666  if(has_t_rep (nodes[upper]->i, nodes[upper]->j, c))
1667  has = TRUE;
1668  }
1669  upper = upper - 1;
1670  int z;
1671  assume (spc_final <= j);
1672  for(z = 0; z < spc_final; z++)
1673  {
1674  if(p_LmDivisibleBy
1675  (nodes_final[z]->lcm_of_lm, nodes[lower]->lcm_of_lm, c->r))
1676  {
1677  has = TRUE;
1678  break;
1679  }
1680  }
1681 
1682  if(has)
1683  {
1684  for(; lower <= upper; lower++)
1685  {
1686  //free_sorted_pair_node(nodes[lower],c->r);
1687  //omfree(nodes[lower]);
1688  nodes[lower] = NULL;
1689  }
1690  j = upper + 1;
1691  continue;
1692  }
1693  else
1694  {
1695  p_Test (nodes[lower]->lcm_of_lm, c->r);
1696  nodes[lower]->lcm_of_lm = pCopy (nodes[lower]->lcm_of_lm);
1697  assume (__p_GetComp (c->S->m[nodes[lower]->i], c->r) ==
1698  __p_GetComp (c->S->m[nodes[lower]->j], c->r));
1699  nodes_final[spc_final] =
1700  (sorted_pair_node *) omAlloc (sizeof (sorted_pair_node));
1701 
1702  *(nodes_final[spc_final++]) = *(nodes[lower]);
1703  //c->tmp_spn[nodes[lower]->j]=(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
1704  nodes[lower] = NULL;
1705  for(lower = lower + 1; lower <= upper; lower++)
1706  {
1707  // free_sorted_pair_node(nodes[lower],c->r);
1708  //omfree(nodes[lower]);
1709  nodes[lower] = NULL;
1710  }
1711  j = upper + 1;
1712  continue;
1713  }
1714  }
1715 
1716  // Print("i:%d,spc_final:%d",i,spc_final);
1717 
1718  assume (spc_final <= spc);
1719  omfree (nodes);
1720  nodes = NULL;
1721 
1722  add_to_reductors (c, h, c->lengths[c->n - 1], ecart, TRUE);
1723  //i=posInS(c->strat,c->strat->sl,h,0 ecart);
1724  if(!(c->nc))
1725  {
1726  if(c->lengths[c->n - 1] == 1)
1727  shorten_tails (c, c->S->m[c->n - 1]);
1728  }
1729  //you should really update c->lengths, c->strat->lenS, and the oder of polys in strat if you sort after lengths
1730 
1731  //for(i=c->strat->sl; i>0;i--)
1732  // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i);
1733  if(c->Rcounter > 50)
1734  {
1735  c->Rcounter = 0;
1736  cleanS (c->strat, c);
1737  }
1738 
1739 #ifdef HAVE_PLURAL
1740  // for SCA:
1741  // here write at the end of nodes_final[spc_final,...,spc_final+lmdeg-1]
1742  if(rIsSCA (c->r))
1743  {
1744  const poly pNext = pNext (h);
1745 
1746  if(pNext != NULL)
1747  {
1748  // for additional polynomials
1749  const unsigned int m_iFirstAltVar = scaFirstAltVar (c->r);
1750  const unsigned int m_iLastAltVar = scaLastAltVar (c->r);
1751 
1752  int N = // c->r->N;
1753  m_iLastAltVar - m_iFirstAltVar + 1; // should be enough
1754  // TODO: but we may also use got = gcd({m}_{m\in f}))!
1755 
1756  poly *array_arg = (poly *) omalloc (N * sizeof (poly)); // !
1757  int j = 0;
1758 
1759 
1760  for(unsigned short v = m_iFirstAltVar; v <= m_iLastAltVar; v++)
1761  // for all x_v | Ann(lm(h))
1762  if(p_GetExp (h, v, c->r)) // TODO: use 'got' here!
1763  {
1764  assume (p_GetExp (h, v, c->r) == 1);
1765 
1766  poly p = sca_pp_Mult_xi_pp (v, pNext, c->r); // x_v * h;
1767 
1768  if(p != NULL) // if (x_v * h != 0)
1769  array_arg[j++] = p;
1770  } // for all x_v | Ann(lm(h))
1771 
1772  c->introduceDelayedPairs (array_arg, j);
1773 
1774  omFree (array_arg); // !!!
1775  }
1776 // PrintS("Saturation - done!!!\n");
1777  }
1778 #endif // if SCAlgebra
1779 
1780 
1781  if(!ip)
1782  {
1783  qsort (nodes_final, spc_final, sizeof (sorted_pair_node *),
1785 
1786 
1787  c->apairs =
1788  spn_merge (c->apairs, c->pair_top + 1, nodes_final, spc_final, c);
1789  c->pair_top += spc_final;
1791  omFree (nodes_final);
1792  return NULL;
1793  }
1794  {
1795  *ip = spc_final;
1796  return nodes_final;
1797  }
1798 }
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
int p
Definition: cfModGcd.cc:4078
intset lenS
Definition: kutil.h:319
unsigned long pTotaldegree(poly p)
Definition: tgb_internal.h:275
sorted_pair_node ** apairs
Definition: tgb_internal.h:230
BOOLEAN nc
Definition: tgb_internal.h:271
kStrategy strat
Definition: tgb_internal.h:221
int * T_deg_full
Definition: tgb_internal.h:223
int array_lengths
Definition: tgb_internal.h:250
int easy_product_crit
Definition: tgb_internal.h:257
int * lengths
Definition: tgb_internal.h:218
int extended_product_crit
Definition: tgb_internal.h:258
sorted_pair_node ** tmp_spn
Definition: tgb_internal.h:226
void introduceDelayedPairs(poly *pa, int s)
Definition: tgb.cc:3167
char ** states
Definition: tgb_internal.h:210
poly * gcd_of_terms
Definition: tgb_internal.h:228
poly * tmp_pair_lm
Definition: tgb_internal.h:225
long * short_Exps
Definition: tgb_internal.h:220
BOOLEAN is_homog
Definition: tgb_internal.h:267
int syz_comp
array_lengths should be greater equal n;
Definition: tgb_internal.h:249
int pTotaldegree_full(poly p)
Definition: tgb_internal.h:283
wlen_type * weighted_lengths
Definition: tgb_internal.h:219
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
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 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 NULL
Definition: omList.c:12
#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:4814
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2906
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3770
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1909
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:469
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1875
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:873
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:818
#define p_Test(p, r)
Definition: p_polys.h:162
#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
void PrintS(const char *s)
Definition: reporter.cc:284
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:3729
static poly gcd_of_terms(poly p, ring r)
Definition: tgb.cc:4035
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:1336
void clean_top_of_pair_list(slimgb_alg *c)
Definition: tgb.cc:3935
#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:1303
static void add_later(poly p, const char *prot, slimgb_alg *c)
Definition: tgb.cc:1255
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:3709
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:4094

◆ clean_top_of_pair_list()

void clean_top_of_pair_list ( slimgb_alg c)

Definition at line 3935 of file tgb.cc.

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

◆ convert_to_sparse_row()

template<class number_type >
SparseRow<number_type>* convert_to_sparse_row ( number_type *  temp_array,
int  temp_size,
int  non_zeros 
)

Definition at line 823 of file tgb_internal.h.

824 {
826 //int pos=0;
827 //Print("denseness:%f\n",((double) non_zeros/(double) temp_size));
828 number_type* it_coef=res->coef_array;
829 int* it_idx=res->idx_array;
830 #if 0
831 for(i=0;i<cache->nIrreducibleMonomials;i++)
832 {
833  if (!(0==temp_array[i]))
834  {
835 
836  res->idx_array[pos]=i;
837  res->coef_array[pos]=temp_array[i];
838 
839  pos++;
840  non_zeros--;
841  if (non_zeros==0) break;
842  }
843 
844 }
845 #else
846 int64* start=(int64*) ((void*)temp_array);
847 int64* end;
848 const int multiple=sizeof(int64)/sizeof(number_type);
849 if (temp_size==0) end=start;
850 
851 else
852 {
853  int temp_size_rounded=temp_size+(multiple-(temp_size%multiple));
854  assume(temp_size_rounded>=temp_size);
855  assume(temp_size_rounded%multiple==0);
856  assume(temp_size_rounded<temp_size+multiple);
857  number_type* nt_end=temp_array+temp_size_rounded;
858  end=(int64*)((void*)nt_end);
859 }
860 int64* it=start;
861 while(it!=end)
862 {
863  if UNLIKELY((*it)!=0)
864  {
865  int small_i;
866  const int temp_index=((number_type*)((void*) it))-temp_array;
867  const int bound=temp_index+multiple;
868  number_type c;
869  for(small_i=temp_index;small_i<bound;small_i++)
870  {
871  if((c=temp_array[small_i])!=0)
872  {
873  //res->idx_array[pos]=small_i;
874  //res->coef_array[pos]=temp_array[small_i];
875  (*(it_idx++))=small_i;
876  (*(it_coef++))=c;
877  //pos++;
878  non_zeros--;
879 
880  }
881  if UNLIKELY(non_zeros==0) break;
882  }
883 
884  }
885  ++it;
886 }
887 #endif
888 return res;
889 }
long int64
Definition: auxiliary.h:68
#define UNLIKELY(X)
Definition: auxiliary.h:404
CanonicalForm res
Definition: facAbsFact.cc:60

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

3634 {
3635  // 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)));
3636 
3637  if(TEST_OPT_PROT)
3638  if(F4_mode)
3639  PrintS ("F4 Modus\n");
3640 
3641  //debug_Ideal=arg_debug_Ideal;
3642  //if (debug_Ideal) PrintS("DebugIdeal received\n");
3643  // Print("Idelems %i \n----------\n",IDELEMS(arg_I));
3644  ideal I = arg_I;
3645  id_Compactify (I,currRing);
3646  if(idIs0 (I))
3647  return I;
3648  int i;
3649  for(i = 0; i < IDELEMS (I); i++)
3650  {
3651  assume (I->m[i] != NULL);
3652  simplify_poly (I->m[i], currRing);
3653  }
3654 
3655  qsort (I->m, IDELEMS (I), sizeof (poly), poly_crit);
3656  //Print("Idelems %i \n----------\n",IDELEMS(I));
3657  //slimgb_alg* c=(slimgb_alg*) omalloc(sizeof(slimgb_alg));
3658  //int syz_comp=arg_I->rank;
3659  slimgb_alg *c = new slimgb_alg (I, syz_comp, F4_mode, deg_pos);
3660 
3661  while((c->pair_top >= 0)
3662  && ((!(TEST_OPT_DEGBOUND))
3663  || (c->apairs[c->pair_top]->deg <= Kstd1_deg)))
3664  {
3665 #ifdef HAVE_F4
3666  if(F4_mode)
3667  go_on_F4 (c);
3668  else
3669 #endif
3670  go_on (c);
3671  }
3672  if(c->pair_top < 0)
3673  c->completed = TRUE;
3674  I = c->S;
3675  delete c;
3676  if(TEST_OPT_REDSB)
3677  {
3678  ideal erg = kInterRed (I, NULL);
3679  assume (I != erg);
3680  id_Delete (&I, currRing);
3681  return erg;
3682  }
3683  //qsort(I->m, IDELEMS(I),sizeof(poly),pLmCmp_func);
3684  assume (I->rank >= id_RankFreeModule (I,currRing));
3685  return (I);
3686 }
BOOLEAN completed
Definition: tgb_internal.h:266
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
#define TEST_OPT_PROT
Definition: options.h:103
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:2723
static int poly_crit(const void *ap1, const void *ap2)
Definition: tgb.cc:3149
static void simplify_poly(poly p, ring r)
Definition: tgb.cc:59

◆ free_sorted_pair_node()

void free_sorted_pair_node ( sorted_pair_node s,
const ring  r 
)

Definition at line 3968 of file tgb.cc.

3969 {
3970  if(s->i >= 0)
3971  p_Delete (&s->lcm_of_lm, r);
3972  omFree (s);
3973 }

◆ 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 }
unsigned long sev
Definition: tgb_internal.h:300
int syzComp
Definition: kutil.h:354
polyset S
Definition: kutil.h:306
int sl
Definition: kutil.h:348
unsigned long * sevS
Definition: kutil.h:322
#define pGetComp(p)
Component.
Definition: polys.h:37
#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

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

◆ modP_lastIndexRow()

template<class number_type >
int modP_lastIndexRow ( number_type *  row,
int  ncols 
)

Definition at line 1486 of file tgb_internal.h.

1487 {
1488  int lastIndex;
1489  const number_type zero=0;//npInit(0);
1490  for(lastIndex=ncols-1;lastIndex>=0;lastIndex--)
1491  {
1492  if (!(row[lastIndex]==zero))
1493  {
1494  return lastIndex;
1495  }
1496  }
1497  return -1;
1498 }
int int ncols
Definition: cf_linsys.cc:32

◆ noro_red_mon_to_non_poly()

template<class number_type >
MonRedResNP<number_type> noro_red_mon_to_non_poly ( poly  t,
NoroCache< number_type > *  cache,
slimgb_alg c 
)

Definition at line 744 of file tgb_internal.h.

745 {
746  MonRedResNP<number_type> res_holder;
747 
748 
750  if (ref!=NULL)
751  {
752  res_holder.coef=p_GetCoeff(t,c->r);
753 
754  res_holder.ref=ref;
755  p_Delete(&t,c->r);
756  return res_holder;
757  }
758 
759  unsigned long sev=p_GetShortExpVector(t,currRing);
760  int i=kFindDivisibleByInS_easy(c->strat,t,sev);
761  if (i>=0)
762  {
763  number coef_bak=p_GetCoeff(t,c->r);
764 
765  p_SetCoeff(t,npInit(1,c->r->cf),c->r);
766  assume(npIsOne(p_GetCoeff(c->strat->S[i],c->r),c->r->cf));
767  number coefstrat=p_GetCoeff(c->strat->S[i],c->r);
768 
769 
770  poly exp_diff=cache->temp_term;
771  p_ExpVectorDiff(exp_diff,t,c->strat->S[i],c->r);
772  p_SetCoeff(exp_diff,npNegM(npInversM(coefstrat,c->r->cf),c->r->cf),c->r);
773  p_Setm(exp_diff,c->r);
774  assume(c->strat->S[i]!=NULL);
775 
776  poly res;
777  res=pp_Mult_mm(pNext(c->strat->S[i]),exp_diff,c->r);
778 
779  int len=c->strat->lenS[i]-1;
781  srow=noro_red_to_non_poly_t<number_type>(res,len,cache,c);
782  ref=cache->insert(t,srow);
783  p_Delete(&t,c->r);
784 
785 
786  res_holder.coef=coef_bak;
787  res_holder.ref=ref;
788  return res_holder;
789 
790  } else {
791  number coef_bak=p_GetCoeff(t,c->r);
792  number one=npInit(1, c->r->cf);
793  p_SetCoeff(t,one,c->r);
794 
795  res_holder.ref=cache->insertAndTransferOwnerShip(t,c->r);
796  assume(res_holder.ref!=NULL);
797  res_holder.coef=coef_bak;
798 
799  return res_holder;
800 
801  }
802 
803 }
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:138
poly temp_term
Definition: tgb_internal.h:579
DataNoroCacheNode< number_type > * insertAndTransferOwnerShip(poly t, ring)
Definition: tgb_internal.h:633
DataNoroCacheNode< number_type > * getCacheReference(poly term)
DataNoroCacheNode< number_type > * insert(poly term, poly nf, int len)
Definition: tgb_internal.h:593
static BOOLEAN npIsOne(number a, const coeffs)
Definition: modulop.h:179
static number npNegM(number a, const coeffs r)
Definition: modulop.h:174
static number npInversM(number c, const coeffs r)
Definition: modulop.h:223
static number npInit(long i, const coeffs r)
Definition: modulop_inl.h:27
#define p_GetCoeff(p, r)
Definition: monomials.h:50
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1003
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1446
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
int kFindDivisibleByInS_easy(kStrategy strat, const red_object &obj)
Definition: tgb.cc:650

◆ noro_red_to_non_poly_dense()

template<class number_type >
SparseRow<number_type>* noro_red_to_non_poly_dense ( MonRedResNP< number_type > *  mon,
int  len,
NoroCache< number_type > *  cache 
)

Definition at line 1078 of file tgb_internal.h.

1079 {
1080  size_t temp_size_bytes=cache->nIrreducibleMonomials*sizeof(number_type)+8;//use 8bit int for testing
1081  assume(sizeof(int64)==8);
1082  cache->ensureTempBufferSize(temp_size_bytes);
1083  number_type* temp_array=(number_type*) cache->tempBuffer;//omalloc(cache->nIrreducibleMonomials*sizeof(number_type));
1084  int temp_size=cache->nIrreducibleMonomials;
1085  memset(temp_array,0,temp_size_bytes);
1086  number minus_one=npInit(-1,currRing->cf);
1087  int i;
1088  for(i=0;i<len;i++)
1089  {
1090  MonRedResNP<number_type> red=mon[i];
1091  if ( /*(*/ red.ref /*)*/ )
1092  {
1093  if (red.ref->row)
1094  {
1095  SparseRow<number_type>* row=red.ref->row;
1096  number coef=red.coef;
1097  if (row->idx_array)
1098  {
1099  if (!((coef==(number)1L)||(coef==minus_one)))
1100  {
1101  add_coef_times_sparse(temp_array,temp_size,row,coef);
1102  }
1103  else
1104  {
1105  if (coef==(number)1L)
1106  {
1107  add_sparse(temp_array,temp_size,row);
1108  }
1109  else
1110  {
1111  sub_sparse(temp_array,temp_size,row);
1112  }
1113  }
1114  }
1115  else
1116  //TODO: treat, 1,-1
1117  if (!((coef==(number)1L)||(coef==minus_one)))
1118  {
1119  add_coef_times_dense(temp_array,temp_size,row->coef_array,row->len,coef);
1120  }
1121  else
1122  {
1123  if (coef==(number)1L)
1124  add_dense(temp_array,temp_size,row->coef_array,row->len);
1125  else
1126  {
1127  assume(coef==minus_one);
1128  sub_dense(temp_array,temp_size,row->coef_array,row->len);
1129  //add_coef_times_dense(temp_array,temp_size,row->coef_array,row->len,coef);
1130  }
1131  }
1132  }
1133  else
1134  {
1135  if (red.ref->value_len==NoroCache<number_type>::backLinkCode)
1136  {
1137  temp_array[red.ref->term_index]=F4mat_to_number_type( npAddM((number)(long) temp_array[red.ref->term_index],red.coef,currRing->cf));
1138  }
1139  else
1140  {
1141  //PrintS("third case\n");
1142  }
1143  }
1144  }
1145  }
1146  int non_zeros=0;
1147  for(i=0;i<cache->nIrreducibleMonomials;i++)
1148  {
1149  //if (!(temp_array[i]==0))
1150  //{
1151  // non_zeros++;
1152  //}
1153  assume(((temp_array[i]!=0)==0)|| (((temp_array[i]!=0)==1)));
1154  non_zeros+=(temp_array[i]!=0);
1155  }
1156 
1157  if (non_zeros==0)
1158  {
1159  //omfree(mon);
1160  return NULL;
1161  }
1162  SparseRow<number_type>* res=new SparseRow<number_type>(temp_size,temp_array);//convert_to_sparse_row(temp_array,temp_size, non_zeros);
1163 
1164  //omfree(temp_array);
1165 
1166 
1167  return res;
1168 }
int nIrreducibleMonomials
Definition: tgb_internal.h:692
void ensureTempBufferSize(size_t size)
Definition: tgb_internal.h:656
void * tempBuffer
Definition: tgb_internal.h:694
void add_dense(number_type *const temp_array, int, const number_type *row, int len)
Definition: tgb_internal.h:987
void sub_dense(number_type *const temp_array, int, const number_type *row, int len)
void add_coef_times_sparse(number_type *const temp_array, int, SparseRow< number_type > *row, number coef)
Definition: tgb_internal.h:891
void sub_sparse(number_type *const temp_array, int, SparseRow< number_type > *row)
void add_sparse(number_type *const temp_array, int, SparseRow< number_type > *row)
void add_coef_times_dense(number_type *const temp_array, int, const number_type *row, int len, number coef)
Definition: tgb_internal.h:939

◆ noro_red_to_non_poly_sparse()

template<class number_type >
SparseRow<number_type>* noro_red_to_non_poly_sparse ( MonRedResNP< number_type > *  mon,
int  len,
NoroCache< number_type > *  cache 
)

Definition at line 1268 of file tgb_internal.h.

1269 {
1270  int i;
1271  int together=0;
1272  for(i=0;i<len;i++)
1273  {
1274  MonRedResNP<number_type> red=mon[i];
1275  if ((red.ref) &&( red.ref->row))
1276  {
1277  together+=red.ref->row->len;
1278  }
1279  else
1280  {
1281  if ((red.ref) &&(red.ref->value_len==NoroCache<number_type>::backLinkCode))
1282  together++;
1283  }
1284  }
1285  //PrintS("here\n");
1286  if (together==0) return 0;
1287  //PrintS("there\n");
1288  cache->ensureTempBufferSize(together*sizeof(CoefIdx<number_type>));
1289  CoefIdx<number_type>* pairs=(CoefIdx<number_type>*) cache->tempBuffer; //omalloc(together*sizeof(CoefIdx<number_type>));
1290  int pos=0;
1291  const number one=npInit(1, currRing->cf);
1292  const number minus_one=npInit(-1, currRing->cf);
1293  for(i=0;i<len;i++)
1294  {
1295  MonRedResNP<number_type> red=mon[i];
1296  if ((red.ref) &&( red.ref->row))
1297  {
1298  //together+=red.ref->row->len;
1299  int* idx_array=red.ref->row->idx_array;
1300  number_type* coef_array=red.ref->row->coef_array;
1301  int rlen=red.ref->row->len;
1302  number coef=red.coef;
1303  if (idx_array)
1304  {
1305  if ((coef!=one)&&(coef!=minus_one))
1306  {
1307  write_coef_times_xx_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen, coef);
1308  }
1309  else
1310  {
1311  if (coef==one)
1312  {
1313  write_coef_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen);
1314  }
1315  else
1316  {
1317  assume(coef==minus_one);
1318  write_minus_coef_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen);
1319  }
1320  }
1321  }
1322  else
1323  {
1324  if ((coef!=one)&&(coef!=minus_one))
1325  {
1326  write_coef_times_xx_idx_to_buffer_dense(pairs,pos,coef_array,rlen,coef);
1327  }
1328  else
1329  {
1330  if (coef==one)
1331  write_coef_idx_to_buffer_dense(pairs,pos,coef_array,rlen);
1332  else
1333  {
1334  assume(coef==minus_one);
1335  write_minus_coef_idx_to_buffer_dense(pairs,pos,coef_array,rlen);
1336  }
1337  }
1338  }
1339  }
1340  else
1341  {
1342  if ((red.ref) &&(red.ref->value_len==NoroCache<number_type>::backLinkCode))
1343  {
1345  ci.coef=F4mat_to_number_type(red.coef);
1346  ci.idx=red.ref->term_index;
1347  pairs[pos++]=ci;
1348  }
1349  }
1350  }
1351  assume(pos<=together);
1352  together=pos;
1353 
1354  std::sort(pairs,pairs+together);
1355 
1356  int act=0;
1357 
1358  assume(pairs[0].coef!=0);
1359  for(i=1;i<together;i++)
1360  {
1361  if (pairs[i].idx!=pairs[act].idx)
1362  {
1363  if (pairs[act].coef!=0)
1364  {
1365  act=act+1;
1366  }
1367  pairs[act]=pairs[i];
1368  }
1369  else
1370  {
1371  pairs[act].coef=F4mat_to_number_type(npAddM((number)(long)pairs[act].coef,(number)(long)pairs[i].coef,currRing->cf));
1372  }
1373  }
1374 
1375  if (pairs[act].coef==0)
1376  {
1377  act--;
1378  }
1379  int sparse_row_len=act+1;
1380  //Print("res len:%d",sparse_row_len);
1381  if (sparse_row_len==0) {return NULL;}
1382  SparseRow<number_type>* res=new SparseRow<number_type>(sparse_row_len);
1383  {
1384  number_type* coef_array=res->coef_array;
1385  int* idx_array=res->idx_array;
1386  for(i=0;i<sparse_row_len;i++)
1387  {
1388  idx_array[i]=pairs[i].idx;
1389  coef_array[i]=pairs[i].coef;
1390  }
1391  }
1392  //omfree(pairs);
1393 
1394  return res;
1395 }
number_type coef
void sort(CFArray &A, int l=0)
quick sort A
STATIC_VAR scmon act
Definition: hdegree.cc:1152
void pairs()
void write_minus_coef_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)
void write_minus_coef_idx_to_buffer(CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen)
void write_coef_idx_to_buffer(CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen)
void write_coef_times_xx_idx_to_buffer(CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen, const number coef)
void write_coef_times_xx_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen, const number coef)
void write_coef_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)

◆ noro_red_to_non_poly_t()

template<class number_type >
SparseRow< number_type > * noro_red_to_non_poly_t ( poly  p,
int &  len,
NoroCache< number_type > *  cache,
slimgb_alg c 
)

Definition at line 1396 of file tgb_internal.h.

1397 {
1398  assume(len==(int)pLength(p));
1399  if (p==NULL)
1400  {
1401  len=0;
1402  return NULL;
1403  }
1404 
1406  int i=0;
1407  double max_density=0.0;
1408  while(p!=NULL)
1409  {
1410  poly t=p;
1411  pIter(p);
1412  pNext(t)=NULL;
1413 
1415  if ((red.ref) && (red.ref->row))
1416  {
1417  double act_density=(double) red.ref->row->len;
1418  act_density/=(double) cache->nIrreducibleMonomials;
1419  max_density=std::max(act_density,max_density);
1420  }
1421  mon[i]=red;
1422  i++;
1423  }
1424 
1425  assume(i==len);
1426  len=i;
1427  bool dense=true;
1428  if (max_density<0.3) dense=false;
1429  if (dense)
1430  {
1432  omfree(mon);
1433  return res;
1434  }
1435  else
1436  {
1438  omfree(mon);
1439  return res;
1440  }
1441  //in the loop before nIrreducibleMonomials increases, so position here is important
1442 
1443 }
static int max(int a, int b)
Definition: fast_mult.cc:264
MonRedResNP< number_type > noro_red_mon_to_non_poly(poly t, NoroCache< number_type > *cache, slimgb_alg *c)
Definition: tgb_internal.h:744
SparseRow< number_type > * noro_red_to_non_poly_sparse(MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)
SparseRow< number_type > * noro_red_to_non_poly_dense(MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)

◆ noro_step()

template<class number_type >
void noro_step ( poly *  p,
int &  pn,
slimgb_alg c 
)

Definition at line 1864 of file tgb_internal.h.

1865 {
1866  //Print("Input rows %d\n",pn);
1867  int j;
1868  if (TEST_OPT_PROT)
1869  {
1870  Print("Input rows %d\n",pn);
1871  }
1872 
1873  NoroCache<number_type> cache;
1874 
1876  int non_zeros=0;
1877  for(j=0;j<pn;j++)
1878  {
1879  poly h=p[j];
1880  int h_len=pLength(h);
1881  //number coef;
1882  srows[non_zeros]=noro_red_to_non_poly_t<number_type>(h,h_len,&cache,c);
1883  if (srows[non_zeros]!=NULL) non_zeros++;
1884  }
1885  std::vector<DataNoroCacheNode<number_type>*> irr_nodes;
1886  cache.collectIrreducibleMonomials(irr_nodes);
1887  //now can build up terms array
1888  //Print("historic irred Mon%d\n",cache.nIrreducibleMonomials);
1889  int n=irr_nodes.size();//cache.countIrreducibleMonomials();
1890  cache.nIrreducibleMonomials=n;
1891  if (TEST_OPT_PROT)
1892  {
1893  Print("Irred Mon:%d\n",n);
1894  Print("red Mon:%d\n",cache.nReducibleMonomials);
1895  }
1897 
1898  for(j=0;j<n;j++)
1899  {
1900  assume(irr_nodes[j]!=NULL);
1901  assume(irr_nodes[j]->value_len==NoroCache<number_type>::backLinkCode);
1902  term_nodes[j].t=irr_nodes[j]->value_poly;
1903  assume(term_nodes[j].t!=NULL);
1904  term_nodes[j].node=irr_nodes[j];
1905  }
1906 
1907  qsort(term_nodes,n,sizeof(TermNoroDataNode<number_type>),term_nodes_sort_crit<number_type>);
1908  poly* terms=(poly*) omalloc(n*sizeof(poly));
1909 
1910  int* old_to_new_indices=(int*) omalloc(cache.nIrreducibleMonomials*sizeof(int));
1911  for(j=0;j<n;j++)
1912  {
1913  old_to_new_indices[term_nodes[j].node->term_index]=j;
1914  term_nodes[j].node->term_index=j;
1915  terms[j]=term_nodes[j].t;
1916  }
1917 
1918  //if (TEST_OPT_PROT)
1919  // Print("Evaluate Rows \n");
1920  pn=non_zeros;
1921  number_type* number_array=(number_type*) omalloc0(((size_t)n)*pn*sizeof(number_type));
1922 
1923  for(j=0;j<pn;j++)
1924  {
1925  int i;
1926  number_type* row=number_array+((long)n)*(long)j;
1927  /*for(i=0;i<n;i++)
1928  {
1929  row[i]=zero;
1930  }*/
1931 
1932  SparseRow<number_type>* srow=srows[j];
1933 
1934  if (srow)
1935  {
1936  int* const idx_array=srow->idx_array;
1937  number_type* const coef_array=srow->coef_array;
1938  const int len=srow->len;
1939  if (srow->idx_array)
1940  {
1941  for(i=0;i<len;i++)
1942  {
1943  int idx=old_to_new_indices[idx_array[i]];
1944  row[idx]=F4mat_to_number_type(coef_array[i]);
1945  }
1946  }
1947  else
1948  {
1949  for(i=0;i<len;i++)
1950  {
1951  row[old_to_new_indices[i]]=F4mat_to_number_type(coef_array[i]);
1952  }
1953  }
1954  delete srow;
1955  }
1956  }
1957 
1958  //static int export_n=0;
1959  //export_mat(number_array,pn,n,"mat%i.py",++export_n);
1961 
1962  int p_pos=0;
1963  for(j=0;j<pn;j++)
1964  {
1965  poly h=row_to_poly(number_array+((long)j)*((long)n),terms,n,c->r);
1966  if(h!=NULL)
1967  {
1968  p[p_pos++]=h;
1969  }
1970  }
1971  pn=p_pos;
1972  omfree(terms);
1973  omfree(term_nodes);
1975  #ifdef NORO_NON_POLY
1976  omfree(srows);
1977  omfree(old_to_new_indices);
1978  #endif
1979  //don't forget the rank
1980 
1981 }
void collectIrreducibleMonomials(std::vector< DataNoroCacheNode< number_type > * > &res)
int nReducibleMonomials
Definition: tgb_internal.h:693
#define Print
Definition: emacs.cc:80
number * number_array
Definition: ntupel.cc:25
#define omalloc0(size)
Definition: omAllocDecl.h:229
void simplest_gauss_modp(number_type *a, int nrows, int ncols)
poly row_to_poly(number_type *row, poly *terms, int tn, ring r)
DataNoroCacheNode< number_type > * node
Definition: tgb_internal.h:572

◆ now_t_rep()

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

Definition at line 3688 of file tgb.cc.

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

◆ pos_helper()

template<class len_type , class set_type >
int pos_helper ( kStrategy  strat,
poly  p,
len_type  len,
set_type  setL,
polyset  set 
)

Definition at line 383 of file tgb_internal.h.

384 {
385  //Print("POSHELER:%d",sizeof(wlen_type));
386  int length=strat->sl;
387  int i;
388  int an = 0;
389  int en= length;
390 
391  if ((len>setL[length])
392  || ((len==setL[length]) && (pLmCmp(set[length],p)== -1)))
393  return length+1;
394 
395  loop
396  {
397  if (an >= en-1)
398  {
399  if ((len<setL[an])
400  || ((len==setL[an]) && (pLmCmp(set[an],p) == 1))) return an;
401  return en;
402  }
403  i=(an+en) / 2;
404  if ((len<setL[i])
405  || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i;
406  //else if ((len>setL[i])
407  //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i;
408  else an=i;
409  }
410 
411 }
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:105
#define loop
Definition: structs.h:79

◆ quick_pop_pair()

sorted_pair_node* quick_pop_pair ( slimgb_alg c)

Definition at line 3914 of file tgb.cc.

3915 {
3916  if(c->pair_top < 0)
3917  return NULL;
3918  else
3919  return (c->apairs[c->pair_top--]);
3920 }

◆ row_to_poly()

template<class number_type >
poly row_to_poly ( number_type *  row,
poly *  terms,
int  tn,
ring  r 
)

Definition at line 1467 of file tgb_internal.h.

1468 {
1469  poly h=NULL;
1470  int j;
1471  number_type zero=0;//;npInit(0);
1472  for(j=tn-1;j>=0;j--)
1473  {
1474  if (!(zero==(row[j])))
1475  {
1476  poly t=terms[j];
1477  t=p_LmInit(t,r);
1478  p_SetCoeff(t,(number)(long) row[j],r);
1479  pNext(t)=h;
1480  h=t;
1481  }
1482 
1483  }
1484  return h;
1485 }
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1307

◆ simplest_gauss_modp()

template<class number_type >
void simplest_gauss_modp ( number_type *  a,
int  nrows,
int  ncols 
)

Definition at line 1841 of file tgb_internal.h.

1842 {
1843  //use memmoves for changing rows
1844  //if (TEST_OPT_PROT)
1845  // PrintS("StartGauss\n");
1847 
1848  int c=0;
1849  int r=0;
1850  while(mat.findPivot(r,c))
1851  {
1852  //int pivot=find_pivot()
1853  mat.reduceOtherRowsForward(r);
1854  r++;
1855  c++;
1856  }
1858  backmat.backwardSubstitute();
1859  //backward substitutions
1860  //if (TEST_OPT_PROT)
1861  //PrintS("StopGauss\n");
1862 }
int nrows
Definition: cf_linsys.cc:32

◆ 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 FORCE_INLINE int nlQlogSize(number n, const coeffs r)
only used by slimgb (tgb.cc)
Definition: longrat.h:76
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:501
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:507

◆ 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
#define omreallocSize(addr, o_size, size)
Definition: omAllocDecl.h:231
static int posInPairs(sorted_pair_node **p, int pn, sorted_pair_node *qe, slimgb_alg *c, int an=0)
Definition: tgb.cc:676

◆ sub_dense()

template<class number_type >
void sub_dense ( number_type *const  temp_array,
int  ,
const number_type *  row,
int  len 
)

Definition at line 1013 of file tgb_internal.h.

1019 {
1020  //int j;
1021  //const number_type* const coef_array=row;
1022  //int* const idx_array=row->idx_array;
1023  //const int len=temp_size;
1024  //tgb_uint32 buffer[256];
1025  //const tgb_uint32 prime=npPrimeM;
1026  //const tgb_uint32 c=F4mat_to_number_type(coef);
1027 
1028  int i;
1029  for(i=0;i<len;i++)
1030  {
1031  temp_array[i]=F4mat_to_number_type(npSubM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
1032  #ifndef SING_NDEBUG
1033  assume(i<temp_size);
1034  #endif
1035  }
1036 }
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:134

◆ sub_sparse()

template<class number_type >
void sub_sparse ( number_type *const  temp_array,
int  ,
SparseRow< number_type > *  row 
)

Definition at line 1059 of file tgb_internal.h.

1063 {
1064  int j;
1065 
1066  number_type* const coef_array=row->coef_array;
1067  int* const idx_array=row->idx_array;
1068  const int len=row->len;
1069  for(j=0;j<len;j++)
1070  {
1071  int idx=idx_array[j];
1072  temp_array[idx]=F4mat_to_number_type( (number_type)(long) npSubM((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
1073  #ifndef SING_NDEBUG
1074  assume(idx<temp_size);
1075  #endif
1076  }
1077 }

◆ term_nodes_sort_crit()

template<class number_type >
int term_nodes_sort_crit ( const void *  a,
const void *  b 
)

Definition at line 1499 of file tgb_internal.h.

1500 {
1502 }
CanonicalForm b
Definition: cfModGcd.cc:4103

◆ terms_sort_crit()

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

Definition at line 1993 of file tgb.cc.

1994 {
1995  return -pLmCmp (*((poly *) a), *((poly *) b));
1996 }

◆ 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 }
Definition: ap.h:40
static int tgb_pair_better_gen(const void *ap, const void *bp)
Definition: tgb.cc:4003

◆ top_pair()

sorted_pair_node* top_pair ( slimgb_alg c)

Definition at line 3890 of file tgb.cc.

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

◆ write_coef_idx_to_buffer()

template<class number_type >
void write_coef_idx_to_buffer ( CoefIdx< number_type > *const  pairs,
int &  pos,
int *const  idx_array,
number_type *const  coef_array,
const int  rlen 
)

Definition at line 1243 of file tgb_internal.h.

1244 {
1245  int j;
1246  for(j=0;j<rlen;j++)
1247  {
1248  assume(coef_array[j]!=0);
1250  ci.coef=coef_array[j];
1251  ci.idx=idx_array[j];
1252  pairs[pos++]=ci;
1253  }
1254 }

◆ write_coef_idx_to_buffer_dense()

template<class number_type >
void write_coef_idx_to_buffer_dense ( CoefIdx< number_type > *const  pairs,
int &  pos,
number_type *const  coef_array,
const int  rlen 
)

Definition at line 1208 of file tgb_internal.h.

1209 {
1210  int j;
1211 
1212  for(j=0;j<rlen;j++)
1213  {
1214  if (coef_array[j]!=0)
1215  {
1216  assume(coef_array[j]!=0);
1218  ci.coef=coef_array[j];
1219  assume(ci.coef!=0);
1220  ci.idx=j;
1221  pairs[pos++]=ci;
1222  }
1223  }
1224 }

◆ write_coef_times_xx_idx_to_buffer()

template<class number_type >
void write_coef_times_xx_idx_to_buffer ( CoefIdx< number_type > *const  pairs,
int &  pos,
int *const  idx_array,
number_type *const  coef_array,
const int  rlen,
const number  coef 
)

Definition at line 1179 of file tgb_internal.h.

1180 {
1181  int j;
1182  for(j=0;j<rlen;j++)
1183  {
1184  assume(coef_array[j]!=0);
1186  ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1187  ci.idx=idx_array[j];
1188  pairs[pos++]=ci;
1189  }
1190 }
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:71

◆ write_coef_times_xx_idx_to_buffer_dense()

template<class number_type >
void write_coef_times_xx_idx_to_buffer_dense ( CoefIdx< number_type > *const  pairs,
int &  pos,
number_type *const  coef_array,
const int  rlen,
const number  coef 
)

Definition at line 1191 of file tgb_internal.h.

1192 {
1193  int j;
1194 
1195  for(j=0;j<rlen;j++)
1196  {
1197  if (coef_array[j]!=0)
1198  {
1199  assume(coef_array[j]!=0);
1201  ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1202  assume(ci.coef!=0);
1203  ci.idx=j;
1204  pairs[pos++]=ci;
1205  }
1206  }
1207 }

◆ write_minus_coef_idx_to_buffer()

template<class number_type >
void write_minus_coef_idx_to_buffer ( CoefIdx< number_type > *const  pairs,
int &  pos,
int *const  idx_array,
number_type *const  coef_array,
const int  rlen 
)

Definition at line 1256 of file tgb_internal.h.

1257 {
1258  int j;
1259  for(j=0;j<rlen;j++)
1260  {
1261  assume(coef_array[j]!=0);
1263  ci.coef=F4mat_to_number_type(npNegM((number)(unsigned long)coef_array[j],currRing->cf)); // FIXME: inplace negation! // TODO: check if this is not a bug!?
1264  ci.idx=idx_array[j];
1265  pairs[pos++]=ci;
1266  }
1267 }

◆ write_minus_coef_idx_to_buffer_dense()

template<class number_type >
void write_minus_coef_idx_to_buffer_dense ( CoefIdx< number_type > *const  pairs,
int &  pos,
number_type *const  coef_array,
const int  rlen 
)

Definition at line 1226 of file tgb_internal.h.

1227 {
1228  int j;
1229 
1230  for(j=0;j<rlen;j++)
1231  {
1232  if (coef_array[j]!=0)
1233  {
1234  assume(coef_array[j]!=0);
1236  ci.coef=F4mat_to_number_type(npNegM((number)(long) coef_array[j],currRing->cf)); // FIXME: inplace negation! // TODO: check if this is not a bug!?
1237  assume(ci.coef!=0);
1238  ci.idx=j;
1239  pairs[pos++]=ci;
1240  }
1241  }
1242 }

◆ write_poly_to_row()

template<class number_type >
void write_poly_to_row ( number_type *  row,
poly  h,
poly *  terms,
int  tn 
)

Definition at line 1452 of file tgb_internal.h.

1453 {
1454  //poly* base=row;
1455  while(h!=NULL)
1456  {
1457  //Print("h:%i\n",h);
1458  number coef=pGetCoeff(h);
1459  poly* ptr_to_h=(poly*) bsearch(&h,terms,tn,sizeof(poly),terms_sort_crit);
1460  assume(ptr_to_h!=NULL);
1461  int pos=ptr_to_h-terms;
1462  row[pos]=F4mat_to_number_type(coef);
1463  //number_type_array[base+pos]=coef;
1464  pIter(h);
1465  }
1466 }
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
int terms_sort_crit(const void *a, const void *b)
Definition: tgb.cc:1993