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 143 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 167 of file tgb_internal.h.

Data Fields
poly_list_node * next
poly p

◆ int_pair_node

struct int_pair_node

Definition at line 173 of file tgb_internal.h.

Data Fields
int a
int b
int_pair_node * next

◆ monom_poly

struct monom_poly

Definition at line 179 of file tgb_internal.h.

Data Fields
poly f
poly m

◆ mp_array_list

struct mp_array_list

Definition at line 184 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 192 of file tgb_internal.h.

Data Fields
poly_array_list * next
poly * p
int size

◆ find_erg

struct find_erg

Definition at line 368 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 565 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 22 of file tgb_internal.h.

◆ AC_NEW_MIN

#define AC_NEW_MIN   2

Definition at line 21 of file tgb_internal.h.

◆ F4mat_to_number_type

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

Definition at line 410 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 28 of file tgb_internal.h.

◆ NORO_NON_POLY

#define NORO_NON_POLY   1

Definition at line 30 of file tgb_internal.h.

◆ NORO_SPARSE_ROWS_PRE

#define NORO_SPARSE_ROWS_PRE   1

Definition at line 29 of file tgb_internal.h.

◆ PAR_N

#define PAR_N   100

Definition at line 19 of file tgb_internal.h.

◆ PAR_N_F4

#define PAR_N_F4   5000

Definition at line 20 of file tgb_internal.h.

◆ REDTAIL_S

#define REDTAIL_S

Definition at line 18 of file tgb_internal.h.

◆ slim_prec_cast

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

Definition at line 409 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 411 of file tgb_internal.h.

◆ tgb_uint32

typedef unsigned int tgb_uint32

Definition at line 413 of file tgb_internal.h.

◆ tgb_uint8

typedef unsigned char tgb_uint8

Definition at line 412 of file tgb_internal.h.

Enumeration Type Documentation

◆ calc_state

enum calc_state
Enumerator
UNCALCULATED 
HASTREP 

Definition at line 307 of file tgb_internal.h.

308  {
309  UNCALCULATED,
310  HASTREP//,
311  //UNIMPORTANT,
312  //SOONTREP
313  };
@ UNCALCULATED
Definition: tgb_internal.h:309
@ HASTREP
Definition: tgb_internal.h:310

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 935 of file tgb_internal.h.

941 {
942  int j;
943  const number_type* const coef_array=row;
944  //int* const idx_array=row->idx_array;
945  //const int len=temp_size;
946  tgb_uint32 buffer[256];
947  const tgb_uint32 prime=n_GetChar(currRing->cf);
948  const tgb_uint32 c=F4mat_to_number_type(coef);
949  assume(!(npIsZero(coef,currRing->cf)));
950  for(j=0;j<len;j=j+256)
951  {
952  const int bound=std::min(j+256,len);
953  int i;
954  int bpos=0;
955  for(i=j;i<bound;i++)
956  {
957  buffer[bpos++]=coef_array[i];
958  }
959  int bpos_bound=bound-j;
960  for(i=0;i<bpos_bound;i++)
961  {
962  buffer[i]*=c;
963  }
964  for(i=0;i<bpos_bound;i++)
965  {
966  buffer[i]=buffer[i]%prime;
967  }
968  bpos=0;
969  for(i=j;i<bound;i++)
970  {
971  //int idx=idx_array[i];
972  assume(bpos<256);
973  //assume(!(npIsZero((number) buffer[bpos])));
974  temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) buffer[bpos++],currRing->cf));
975  #ifndef SING_NDEBUG
976  assume(i<temp_size);
977  #endif
978  }
979 
980  }
981 }
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:441
int j
Definition: facHensel.cc:110
static int min(int a, int b)
Definition: fast_mult.cc:268
#define assume(x)
Definition: mod2.h:389
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:413
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:410

◆ 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 887 of file tgb_internal.h.

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

◆ add_dense()

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

Definition at line 983 of file tgb_internal.h.

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

◆ add_sparse()

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

Definition at line 1035 of file tgb_internal.h.

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

◆ 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 order of polys in strat if you sort after lengths
1719 
1720  //for(i=c->strat->sl; i>0;i--)
1721  // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i);
1722  if(c->Rcounter > 50)
1723  {
1724  c->Rcounter = 0;
1725  cleanS (c->strat, c);
1726  }
1727 
1728 #ifdef HAVE_PLURAL
1729  // for SCA:
1730  // here write at the end of nodes_final[spc_final,...,spc_final+lmdeg-1]
1731  if(rIsSCA (c->r))
1732  {
1733  const poly pNext = pNext (h);
1734 
1735  if(pNext != NULL)
1736  {
1737  // for additional polynomials
1738  const unsigned int m_iFirstAltVar = scaFirstAltVar (c->r);
1739  const unsigned int m_iLastAltVar = scaLastAltVar (c->r);
1740 
1741  int N = // c->r->N;
1742  m_iLastAltVar - m_iFirstAltVar + 1; // should be enough
1743  // TODO: but we may also use got = gcd({m}_{m\in f}))!
1744 
1745  poly *array_arg = (poly *) omalloc (N * sizeof (poly)); // !
1746  int j = 0;
1747 
1748 
1749  for(unsigned short v = m_iFirstAltVar; v <= m_iLastAltVar; v++)
1750  // for all x_v | Ann(lm(h))
1751  if(p_GetExp (h, v, c->r)) // TODO: use 'got' here!
1752  {
1753  assume (p_GetExp (h, v, c->r) == 1);
1754 
1755  poly p = sca_pp_Mult_xi_pp (v, pNext, c->r); // x_v * h;
1756 
1757  if(p != NULL) // if (x_v * h != 0)
1758  array_arg[j++] = p;
1759  } // for all x_v | Ann(lm(h))
1760 
1761  c->introduceDelayedPairs (array_arg, j);
1762 
1763  omFree (array_arg); // !!!
1764  }
1765 // PrintS("Saturation - done!!!\n");
1766  }
1767 #endif // if SCAlgebra
1768 
1769 
1770  if(!ip)
1771  {
1772  qsort (nodes_final, spc_final, sizeof (sorted_pair_node *),
1774 
1775 
1776  c->apairs =
1777  spn_merge (c->apairs, c->pair_top + 1, nodes_final, spc_final, c);
1778  c->pair_top += spc_final;
1780  omFree (nodes_final);
1781  return NULL;
1782  }
1783  {
1784  *ip = spc_final;
1785  return nodes_final;
1786  }
1787 }
static int si_max(const int a, const int b)
Definition: auxiliary.h: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: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
STATIC_VAR Poly * h
Definition: janet.cc:971
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition: kspoly.cc:1453
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:111
#define TEST_V_FINDMONOM
Definition: options.h:143
#define TEST_V_UPTORADICAL
Definition: options.h:142
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4776
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2841
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3692
static int pLength(poly a)
Definition: p_polys.h:188
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1908
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:467
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1889
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:844
#define p_Test(p, r)
Definition: p_polys.h:159
#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:362
#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: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

◆ 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

◆ 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 819 of file tgb_internal.h.

820 {
822 //int pos=0;
823 //Print("denseness:%f\n",((double) non_zeros/(double) temp_size));
824 number_type* it_coef=res->coef_array;
825 int* it_idx=res->idx_array;
826 #if 0
827 for(i=0;i<cache->nIrreducibleMonomials;i++)
828 {
829  if (!(0==temp_array[i]))
830  {
831 
832  res->idx_array[pos]=i;
833  res->coef_array[pos]=temp_array[i];
834 
835  pos++;
836  non_zeros--;
837  if (non_zeros==0) break;
838  }
839 
840 }
841 #else
842 int64* start=(int64*) ((void*)temp_array);
843 int64* end;
844 const int multiple=sizeof(int64)/sizeof(number_type);
845 if (temp_size==0) end=start;
846 
847 else
848 {
849  int temp_size_rounded=temp_size+(multiple-(temp_size%multiple));
850  assume(temp_size_rounded>=temp_size);
851  assume(temp_size_rounded%multiple==0);
852  assume(temp_size_rounded<temp_size+multiple);
853  number_type* nt_end=temp_array+temp_size_rounded;
854  end=(int64*)((void*)nt_end);
855 }
856 int64* it=start;
857 while(it!=end)
858 {
859  if UNLIKELY((*it)!=0)
860  {
861  int small_i;
862  const int temp_index=((number_type*)((void*) it))-temp_array;
863  const int bound=temp_index+multiple;
864  number_type c;
865  for(small_i=temp_index;small_i<bound;small_i++)
866  {
867  if((c=temp_array[small_i])!=0)
868  {
869  //res->idx_array[pos]=small_i;
870  //res->coef_array[pos]=temp_array[small_i];
871  (*(it_idx++))=small_i;
872  (*(it_coef++))=c;
873  //pos++;
874  non_zeros--;
875 
876  }
877  if UNLIKELY(non_zeros==0) break;
878  }
879 
880  }
881  ++it;
882 }
883 #endif
884 return res;
885 }
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 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:3761
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:49
#define TEST_OPT_REDSB
Definition: options.h:105
#define TEST_OPT_DEGBOUND
Definition: options.h:114
#define TEST_OPT_PROT
Definition: options.h:104
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

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

◆ 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:296
unsigned 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 1482 of file tgb_internal.h.

1483 {
1484  int lastIndex;
1485  const number_type zero=0;//npInit(0);
1486  for(lastIndex=ncols-1;lastIndex>=0;lastIndex--)
1487  {
1488  if (!(row[lastIndex]==zero))
1489  {
1490  return lastIndex;
1491  }
1492  }
1493  return -1;
1494 }
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 740 of file tgb_internal.h.

741 {
742  MonRedResNP<number_type> res_holder;
743 
744 
746  if (ref!=NULL)
747  {
748  res_holder.coef=p_GetCoeff(t,c->r);
749 
750  res_holder.ref=ref;
751  p_Delete(&t,c->r);
752  return res_holder;
753  }
754 
755  unsigned long sev=p_GetShortExpVector(t,currRing);
756  int i=kFindDivisibleByInS_easy(c->strat,t,sev);
757  if (i>=0)
758  {
759  number coef_bak=p_GetCoeff(t,c->r);
760 
761  p_SetCoeff(t,npInit(1,c->r->cf),c->r);
762  assume(npIsOne(p_GetCoeff(c->strat->S[i],c->r),c->r->cf));
763  number coefstrat=p_GetCoeff(c->strat->S[i],c->r);
764 
765 
766  poly exp_diff=cache->temp_term;
767  p_ExpVectorDiff(exp_diff,t,c->strat->S[i],c->r);
768  p_SetCoeff(exp_diff,npNegM(npInversM(coefstrat,c->r->cf),c->r->cf),c->r);
769  p_Setm(exp_diff,c->r);
770  assume(c->strat->S[i]!=NULL);
771 
772  poly res;
773  res=pp_Mult_mm(pNext(c->strat->S[i]),exp_diff,c->r);
774 
775  int len=c->strat->lenS[i]-1;
777  srow=noro_red_to_non_poly_t<number_type>(res,len,cache,c);
778  ref=cache->insert(t,srow);
779  p_Delete(&t,c->r);
780 
781 
782  res_holder.coef=coef_bak;
783  res_holder.ref=ref;
784  return res_holder;
785 
786  } else {
787  number coef_bak=p_GetCoeff(t,c->r);
788  number one=npInit(1, c->r->cf);
789  p_SetCoeff(t,one,c->r);
790 
791  res_holder.ref=cache->insertAndTransferOwnerShip(t,c->r);
792  assume(res_holder.ref!=NULL);
793  res_holder.coef=coef_bak;
794 
795  return res_holder;
796 
797  }
798 
799 }
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:137
poly temp_term
Definition: tgb_internal.h:575
DataNoroCacheNode< number_type > * insertAndTransferOwnerShip(poly t, ring)
Definition: tgb_internal.h:629
DataNoroCacheNode< number_type > * getCacheReference(poly term)
DataNoroCacheNode< number_type > * insert(poly term, poly nf, int len)
Definition: tgb_internal.h:589
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:1029
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1472
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:410
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 1074 of file tgb_internal.h.

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

◆ 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 1264 of file tgb_internal.h.

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

1393 {
1394  assume(len==(int)pLength(p));
1395  if (p==NULL)
1396  {
1397  len=0;
1398  return NULL;
1399  }
1400 
1402  int i=0;
1403  double max_density=0.0;
1404  while(p!=NULL)
1405  {
1406  poly t=p;
1407  pIter(p);
1408  pNext(t)=NULL;
1409 
1411  if ((red.ref) && (red.ref->row))
1412  {
1413  double act_density=(double) red.ref->row->len;
1414  act_density/=(double) cache->nIrreducibleMonomials;
1415  max_density=std::max(act_density,max_density);
1416  }
1417  mon[i]=red;
1418  i++;
1419  }
1420 
1421  assume(i==len);
1422  len=i;
1423  bool dense=true;
1424  if (max_density<0.3) dense=false;
1425  if (dense)
1426  {
1428  omfree(mon);
1429  return res;
1430  }
1431  else
1432  {
1434  omfree(mon);
1435  return res;
1436  }
1437  //in the loop before nIrreducibleMonomials increases, so position here is important
1438 
1439 }
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:740
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 1860 of file tgb_internal.h.

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

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

◆ 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 379 of file tgb_internal.h.

380 {
381  //Print("POSHELER:%d",sizeof(wlen_type));
382  int length=strat->sl;
383  int i;
384  int an = 0;
385  int en= length;
386 
387  if ((len>setL[length])
388  || ((len==setL[length]) && (pLmCmp(set[length],p)== -1)))
389  return length+1;
390 
391  loop
392  {
393  if (an >= en-1)
394  {
395  if ((len<setL[an])
396  || ((len==setL[an]) && (pLmCmp(set[an],p) == 1))) return an;
397  return en;
398  }
399  i=(an+en) / 2;
400  if ((len<setL[i])
401  || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i;
402  //else if ((len>setL[i])
403  //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i;
404  else an=i;
405  }
406 
407 }
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:75

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

◆ row_to_poly()

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

Definition at line 1463 of file tgb_internal.h.

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

◆ simplest_gauss_modp()

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

Definition at line 1837 of file tgb_internal.h.

1838 {
1839  //use memmoves for changing rows
1840  //if (TEST_OPT_PROT)
1841  // PrintS("StartGauss\n");
1843 
1844  int c=0;
1845  int r=0;
1846  while(mat.findPivot(r,c))
1847  {
1848  //int pivot=find_pivot()
1849  mat.reduceOtherRowsForward(r);
1850  r++;
1851  c++;
1852  }
1854  backmat.backwardSubstitute();
1855  //backward substitutions
1856  //if (TEST_OPT_PROT)
1857  //PrintS("StopGauss\n");
1858 }
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:567
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:500
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:506

◆ 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 1009 of file tgb_internal.h.

1015 {
1016  //int j;
1017  //const number_type* const coef_array=row;
1018  //int* const idx_array=row->idx_array;
1019  //const int len=temp_size;
1020  //tgb_uint32 buffer[256];
1021  //const tgb_uint32 prime=npPrimeM;
1022  //const tgb_uint32 c=F4mat_to_number_type(coef);
1023 
1024  int i;
1025  for(i=0;i<len;i++)
1026  {
1027  temp_array[i]=F4mat_to_number_type(npSubM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
1028  #ifndef SING_NDEBUG
1029  assume(i<temp_size);
1030  #endif
1031  }
1032 }
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 1055 of file tgb_internal.h.

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

◆ term_nodes_sort_crit()

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

Definition at line 1495 of file tgb_internal.h.

1496 {
1498 }
CanonicalForm b
Definition: cfModGcd.cc:4103

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

◆ 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 1239 of file tgb_internal.h.

1240 {
1241  int j;
1242  for(j=0;j<rlen;j++)
1243  {
1244  assume(coef_array[j]!=0);
1246  ci.coef=coef_array[j];
1247  ci.idx=idx_array[j];
1248  pairs[pos++]=ci;
1249  }
1250 }

◆ 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 1204 of file tgb_internal.h.

1205 {
1206  int j;
1207 
1208  for(j=0;j<rlen;j++)
1209  {
1210  if (coef_array[j]!=0)
1211  {
1212  assume(coef_array[j]!=0);
1214  ci.coef=coef_array[j];
1215  assume(ci.coef!=0);
1216  ci.idx=j;
1217  pairs[pos++]=ci;
1218  }
1219  }
1220 }

◆ 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 1175 of file tgb_internal.h.

1176 {
1177  int j;
1178  for(j=0;j<rlen;j++)
1179  {
1180  assume(coef_array[j]!=0);
1182  ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1183  ci.idx=idx_array[j];
1184  pairs[pos++]=ci;
1185  }
1186 }
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 1187 of file tgb_internal.h.

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

◆ 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 1252 of file tgb_internal.h.

1253 {
1254  int j;
1255  for(j=0;j<rlen;j++)
1256  {
1257  assume(coef_array[j]!=0);
1259  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!?
1260  ci.idx=idx_array[j];
1261  pairs[pos++]=ci;
1262  }
1263 }

◆ 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 1222 of file tgb_internal.h.

1223 {
1224  int j;
1225 
1226  for(j=0;j<rlen;j++)
1227  {
1228  if (coef_array[j]!=0)
1229  {
1230  assume(coef_array[j]!=0);
1232  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!?
1233  assume(ci.coef!=0);
1234  ci.idx=j;
1235  pairs[pos++]=ci;
1236  }
1237  }
1238 }

◆ 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 1448 of file tgb_internal.h.

1449 {
1450  //poly* base=row;
1451  while(h!=NULL)
1452  {
1453  //Print("h:%i\n",h);
1454  number coef=pGetCoeff(h);
1455  poly* ptr_to_h=(poly*) bsearch(&h,terms,tn,sizeof(poly),terms_sort_crit);
1456  assume(ptr_to_h!=NULL);
1457  int pos=ptr_to_h-terms;
1458  row[pos]=F4mat_to_number_type(coef);
1459  //number_type_array[base+pos]=coef;
1460  pIter(h);
1461  }
1462 }
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:1982