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"

Go to the source code of this file.

Data Structures

class  PolySimple
 
class  DataNoroCacheNode< number_type >
 
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  ModPMatrixBackSubstProxyOnArray< 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 npInit   n_Init
 
#define npNeg   n_InpNeg
 
#define npInvers   n_Invers
 
#define npMult   n_Mult
 
#define npIsOne   n_IsOne
 
#define npIsZero   n_IsZero
 
#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)
 
wlen_type pELength (poly p, ring r)
 
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, ring r)
 
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 154 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 178 of file tgb_internal.h.

Data Fields
poly_list_node * next
poly p

◆ int_pair_node

struct int_pair_node

Definition at line 184 of file tgb_internal.h.

Data Fields
int a
int b
int_pair_node * next

◆ monom_poly

struct monom_poly

Definition at line 190 of file tgb_internal.h.

Data Fields
poly f
poly m

◆ mp_array_list

struct mp_array_list

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

Data Fields
poly_array_list * next
poly * p
int size

◆ find_erg

struct find_erg

Definition at line 382 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 579 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 424 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.

◆ npInit

#define npInit   n_Init

Definition at line 72 of file tgb_internal.h.

◆ npInvers

#define npInvers   n_Invers

Definition at line 74 of file tgb_internal.h.

◆ npIsOne

#define npIsOne   n_IsOne

Definition at line 76 of file tgb_internal.h.

◆ npIsZero

#define npIsZero   n_IsZero

Definition at line 77 of file tgb_internal.h.

◆ npMult

#define npMult   n_Mult

Definition at line 75 of file tgb_internal.h.

◆ npNeg

#define npNeg   n_InpNeg

Definition at line 73 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 423 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 425 of file tgb_internal.h.

◆ tgb_uint32

typedef unsigned int tgb_uint32

Definition at line 427 of file tgb_internal.h.

◆ tgb_uint8

typedef unsigned char tgb_uint8

Definition at line 426 of file tgb_internal.h.

Enumeration Type Documentation

◆ calc_state

enum calc_state
Enumerator
UNCALCULATED 
HASTREP 

Definition at line 321 of file tgb_internal.h.

322  {
323  UNCALCULATED,
324  HASTREP//,
325  //UNIMPORTANT,
326  //SOONTREP
327  };

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

952 {
953  int j;
954  const number_type* const coef_array=row;
955  //int* const idx_array=row->idx_array;
956  //const int len=temp_size;
957  tgb_uint32 buffer[256];
958  const tgb_uint32 prime=n_GetChar(currRing->cf);
959  const tgb_uint32 c=F4mat_to_number_type(coef);
960  assume(!(npIsZero(coef,currRing->cf)));
961  for(j=0;j<len;j=j+256)
962  {
963  const int bound=std::min(j+256,len);
964  int i;
965  int bpos=0;
966  for(i=j;i<bound;i++)
967  {
968  buffer[bpos++]=coef_array[i];
969  }
970  int bpos_bound=bound-j;
971  for(i=0;i<bpos_bound;i++)
972  {
973  buffer[i]*=c;
974  }
975  for(i=0;i<bpos_bound;i++)
976  {
977  buffer[i]=buffer[i]%prime;
978  }
979  bpos=0;
980  for(i=j;i<bound;i++)
981  {
982  //int idx=idx_array[i];
983  assume(bpos<256);
984  //assume(!(npIsZero((number) buffer[bpos])));
985  STATISTIC(n_Add); temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) buffer[bpos++],currRing->cf));
986  #ifndef SING_NDEBUG
987  assume(i<temp_size);
988  #endif
989  }
990 
991  }
992 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
static int min(int a, int b)
Definition: fast_mult.cc:268
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
unsigned int tgb_uint32
Definition: tgb_internal.h:427
#define npIsZero
Definition: tgb_internal.h:77
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
int i
Definition: cfEzgcd.cc:125
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

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

904 {
905  int j;
906  number_type* const coef_array=row->coef_array;
907  int* const idx_array=row->idx_array;
908  const int len=row->len;
909  tgb_uint32 buffer[256];
910  const tgb_uint32 prime=n_GetChar(currRing->cf);
911  const tgb_uint32 c=F4mat_to_number_type(coef);
912  assume(!(npIsZero(coef,currRing->cf)));
913  for(j=0;j<len;j=j+256)
914  {
915  const int bound=std::min(j+256,len);
916  int i;
917  int bpos=0;
918  for(i=j;i<bound;i++)
919  {
920  buffer[bpos++]=coef_array[i];
921  }
922  int bpos_bound=bound-j;
923  for(i=0;i<bpos_bound;i++)
924  {
925  buffer[i]*=c;
926  }
927  for(i=0;i<bpos_bound;i++)
928  {
929  buffer[i]=buffer[i]%prime;
930  }
931  bpos=0;
932  for(i=j;i<bound;i++)
933  {
934  int idx=idx_array[i];
935  assume(bpos<256);
936  assume(!(npIsZero((number)(long) buffer[bpos],currRing->cf)));
937  STATISTIC(n_Add); temp_array[idx]=F4mat_to_number_type(npAddM((number)(long) temp_array[idx], (number)(long) buffer[bpos++],currRing->cf));
938  #ifndef SING_NDEBUG
939  assume(idx<temp_size);
940  #endif
941  }
942 
943  }
944 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
static int min(int a, int b)
Definition: fast_mult.cc:268
int * idx_array
Definition: tgb_internal.h:513
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
unsigned int tgb_uint32
Definition: tgb_internal.h:427
#define npIsZero
Definition: tgb_internal.h:77
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
int i
Definition: cfEzgcd.cc:125
number_type * coef_array
Definition: tgb_internal.h:514
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

◆ add_dense()

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

Definition at line 994 of file tgb_internal.h.

1000 {
1001  //int j;
1002  //const number_type* const coef_array=row;
1003  //int* const idx_array=row->idx_array;
1004  //const int len=temp_size;
1005  //tgb_uint32 buffer[256];
1006  //const tgb_uint32 prime=npPrimeM;
1007  //const tgb_uint32 c=F4mat_to_number_type(coef);
1008 
1009  int i;
1010  for(i=0;i<len;i++)
1011  {
1012  STATISTIC(n_Add); temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
1013  #ifndef SING_NDEBUG
1014  assume(i<temp_size);
1015  #endif
1016  }
1017 
1018 }
#define STATISTIC(f)
Definition: numstats.h:16
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
int i
Definition: cfEzgcd.cc:125
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

◆ add_sparse()

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

Definition at line 1048 of file tgb_internal.h.

1052 {
1053  int j;
1054 
1055  number_type* const coef_array=row->coef_array;
1056  int* const idx_array=row->idx_array;
1057  const int len=row->len;
1058  for(j=0;j<len;j++)
1059  {
1060  int idx=idx_array[j];
1061  STATISTIC(n_Add); temp_array[idx]=F4mat_to_number_type( (number_type)(long)npAddM((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
1062  #ifndef SING_NDEBUG
1063  assume(idx<temp_size);
1064  #endif
1065  }
1066 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
int * idx_array
Definition: tgb_internal.h:513
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
number_type * coef_array
Definition: tgb_internal.h:514
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

◆ add_to_basis_ideal_quotient()

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

Definition at line 1426 of file tgb.cc.

1428 {
1429  p_Test (h, c->r);
1430  assume (h != NULL);
1431  poly got = gcd_of_terms (h, c->r);
1432  if((got != NULL) && (TEST_V_UPTORADICAL))
1433  {
1434  poly copy = p_Copy (got, c->r);
1435  //p_wrp(got,c->r);
1436  BOOLEAN changed = monomial_root (got, c->r);
1437  if(changed)
1438  {
1439  poly div_by = pMDivide (copy, got);
1440  poly iter = h;
1441  while(iter)
1442  {
1443  pExpVectorSub (iter, div_by);
1444  pIter (iter);
1445  }
1446  p_Delete (&div_by, c->r);
1447  PrintS ("U");
1448  }
1449  p_Delete (&copy, c->r);
1450  }
1451 
1452 #define ENLARGE(pointer, type) pointer=(type*) omrealloc(pointer, c->array_lengths*sizeof(type))
1453 
1454 #define ENLARGE_ALIGN(pointer, type) {if(pointer)\
1455  pointer=(type*)omReallocAligned(pointer, c->array_lengths*sizeof(type));\
1456  else pointer=(type*)omAllocAligned(c->array_lengths*sizeof(type));}
1457 // BOOLEAN corr=lenS_correct(c->strat);
1458  int sugar;
1459  int ecart = 0;
1460  ++(c->n);
1461  ++(c->S->ncols);
1462  int i, j;
1463  i = c->n - 1;
1464  sorted_pair_node **nodes =
1465  (sorted_pair_node **) omalloc (sizeof (sorted_pair_node *) * i);
1466  int spc = 0;
1467  if(c->n > c->array_lengths)
1468  {
1469  c->array_lengths = c->array_lengths * 2;
1470  assume (c->array_lengths >= c->n);
1471  ENLARGE (c->T_deg, int);
1472  ENLARGE_ALIGN (c->tmp_pair_lm, poly);
1474 
1475  ENLARGE_ALIGN (c->short_Exps, long);
1476  ENLARGE (c->lengths, int);
1477 #ifndef HAVE_BOOST
1478 #ifndef USE_STDVECBOOL
1479 
1480  ENLARGE_ALIGN (c->states, char *);
1481 #endif
1482 #endif
1483  ENLARGE_ALIGN (c->gcd_of_terms, poly);
1484  //if (c->weighted_lengths!=NULL) {
1486  //}
1487  //ENLARGE_ALIGN(c->S->m,poly);
1488  }
1489  pEnlargeSet (&c->S->m, c->n - 1, 1);
1490  if(c->T_deg_full)
1491  ENLARGE (c->T_deg_full, int);
1492  sugar = c->T_deg[i] = c->pTotaldegree (h);
1493  if(c->T_deg_full)
1494  {
1495  sugar = c->T_deg_full[i] = c->pTotaldegree_full (h);
1496  ecart = sugar - c->T_deg[i];
1497  assume (ecart >= 0);
1498  }
1499  c->tmp_pair_lm[i] = pOne_Special (c->r);
1500 
1501  c->tmp_spn[i] = (sorted_pair_node *) omAlloc (sizeof (sorted_pair_node));
1502 
1503  c->lengths[i] = pLength (h);
1504 
1505  //necessary for correct weighted length
1506 
1508  {
1509  p_Cleardenom (h, c->r); //includes p_Content(h,c->r);
1510  }
1511  else
1512  pNorm (h);
1513  //pNormalize (h);
1514 
1515  c->weighted_lengths[i] = pQuality (h, c, c->lengths[i]);
1516  c->gcd_of_terms[i] = got;
1517 #ifdef HAVE_BOOST
1518  c->states.push_back (dynamic_bitset <> (i));
1519 
1520 #else
1521 #ifdef USE_STDVECBOOL
1522 
1523  c->states.push_back (vector < bool > (i));
1524 
1525 #else
1526  if(i > 0)
1527  c->states[i] = (char *) omAlloc (i * sizeof (char));
1528  else
1529  c->states[i] = NULL;
1530 #endif
1531 #endif
1532 
1533  c->S->m[i] = h;
1534  c->short_Exps[i] = p_GetShortExpVector (h, c->r);
1535 
1536 #undef ENLARGE
1537 #undef ENLARGE_ALIGN
1538  if(p_GetComp (h, currRing) <= c->syz_comp)
1539  {
1540  for(j = 0; j < i; j++)
1541  {
1542 
1543 
1544 #ifndef HAVE_BOOST
1545  c->states[i][j] = UNCALCULATED;
1546 #endif
1547  assume (p_LmDivisibleBy (c->S->m[i], c->S->m[j], c->r) ==
1548  p_LmShortDivisibleBy (c->S->m[i], c->short_Exps[i], c->S->m[j],
1549  ~(c->short_Exps[j]), c->r));
1550 
1551  if(__p_GetComp (c->S->m[i], c->r) != __p_GetComp (c->S->m[j], c->r))
1552  {
1553  //c->states[i][j]=UNCALCULATED;
1554  //WARNUNG: be careful
1555  continue;
1556  }
1557  else if((!c->nc) && (c->lengths[i] == 1) && (c->lengths[j] == 1))
1558  {
1559  c->states[i][j] = HASTREP;
1560  }
1561  else if(((!c->nc) || (c->is_homog && rIsSCA (c->r)))
1562  && (pHasNotCF (c->S->m[i], c->S->m[j])))
1563 // else if ((!(c->nc)) && (pHasNotCF(c->S->m[i],c->S->m[j])))
1564  {
1565  c->easy_product_crit++;
1566  c->states[i][j] = HASTREP;
1567  continue;
1568  }
1569  else
1571  (c->S->m[i], c->gcd_of_terms[i], c->S->m[j], c->gcd_of_terms[j],
1572  c))
1573  {
1574  c->states[i][j] = HASTREP;
1575  c->extended_product_crit++;
1576  //PrintS("E");
1577  }
1578  // if (c->states[i][j]==UNCALCULATED)
1579  // {
1580 
1581  if((TEST_V_FINDMONOM) && (!c->nc))
1582  {
1583  //PrintS("COMMU");
1584  // if (c->lengths[i]==c->lengths[j])
1585  // {
1586 // poly short_s=ksCreateShortSpoly(c->S->m[i],c->S->m[j],c->r);
1587 // if (short_s==NULL)
1588 // {
1589 // c->states[i][j]=HASTREP;
1590 // }
1591 // else
1592 // {
1593 // p_Delete(&short_s, currRing);
1594 // }
1595 // }
1596  if(c->lengths[i] + c->lengths[j] == 3)
1597  {
1598 
1599 
1600  poly short_s = ksCreateShortSpoly (c->S->m[i], c->S->m[j], c->r);
1601  if(short_s == NULL)
1602  {
1603  c->states[i][j] = HASTREP;
1604  }
1605  else
1606  {
1607  assume (pLength (short_s) == 1);
1608  if(TEST_V_UPTORADICAL)
1609  monomial_root (short_s, c->r);
1610  int iS = kFindDivisibleByInS_easy (c->strat, short_s,
1611  p_GetShortExpVector (short_s,
1612  c->r));
1613  if(iS < 0)
1614  {
1615  //PrintS("N");
1616  if(TRUE)
1617  {
1618  c->states[i][j] = HASTREP;
1619  add_later (short_s, "N", c);
1620  }
1621  else
1622  p_Delete (&short_s, currRing);
1623  }
1624  else
1625  {
1626  if(c->strat->lenS[iS] > 1)
1627  {
1628  //PrintS("O");
1629  if(TRUE)
1630  {
1631  c->states[i][j] = HASTREP;
1632  add_later (short_s, "O", c);
1633  }
1634  else
1635  p_Delete (&short_s, currRing);
1636  }
1637  else
1638  p_Delete (&short_s, currRing);
1639  c->states[i][j] = HASTREP;
1640  }
1641 
1642 
1643  }
1644  }
1645  }
1646  // if (short_s)
1647  // {
1648  assume (spc <= j);
1649  sorted_pair_node *s = c->tmp_spn[spc]; //(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
1650  s->i = si_max (i, j);
1651  s->j = si_min (i, j);
1652  assume (s->j == j);
1653  s->expected_length = pair_weighted_length (i, j, c); //c->lengths[i]+c->lengths[j]-2;
1654 
1655  poly lm = c->tmp_pair_lm[spc]; //=pOne_Special();
1656 
1657  pLcm (c->S->m[i], c->S->m[j], lm);
1658  pSetm (lm);
1659  p_Test (lm, c->r);
1660  s->deg = c->pTotaldegree (lm);
1661 
1662  if(c->T_deg_full) //Sugar
1663  {
1664  int t_i = c->T_deg_full[s->i] - c->T_deg[s->i];
1665  int t_j = c->T_deg_full[s->j] - c->T_deg[s->j];
1666  s->deg += si_max (t_i, t_j);
1667  //Print("\n max: %d\n",max(t_i,t_j));
1668  }
1669  p_Test (lm, c->r);
1670  s->lcm_of_lm = lm;
1671  // pDelete(&short_s);
1672  //assume(lm!=NULL);
1673  nodes[spc] = s;
1674  spc++;
1675 
1676  // }
1677  //else
1678  //{
1679  //c->states[i][j]=HASTREP;
1680  //}
1681  }
1682  } //if syz_comp end
1683 
1684  assume (spc <= i);
1685  //now ideal quotient crit
1686  qsort (nodes, spc, sizeof (sorted_pair_node *), iq_crit);
1687 
1688  sorted_pair_node **nodes_final =
1689  (sorted_pair_node **) omalloc (sizeof (sorted_pair_node *) * i);
1690  int spc_final = 0;
1691  j = 0;
1692  while(j < spc)
1693  {
1694  int lower = j;
1695  int upper;
1696  BOOLEAN has = FALSE;
1697  for(upper = lower + 1; upper < spc; upper++)
1698  {
1699  if(!pLmEqual (nodes[lower]->lcm_of_lm, nodes[upper]->lcm_of_lm))
1700  {
1701  break;
1702  }
1703  if(has_t_rep (nodes[upper]->i, nodes[upper]->j, c))
1704  has = TRUE;
1705  }
1706  upper = upper - 1;
1707  int z;
1708  assume (spc_final <= j);
1709  for(z = 0; z < spc_final; z++)
1710  {
1711  if(p_LmDivisibleBy
1712  (nodes_final[z]->lcm_of_lm, nodes[lower]->lcm_of_lm, c->r))
1713  {
1714  has = TRUE;
1715  break;
1716  }
1717  }
1718 
1719  if(has)
1720  {
1721  for(; lower <= upper; lower++)
1722  {
1723  //free_sorted_pair_node(nodes[lower],c->r);
1724  //omfree(nodes[lower]);
1725  nodes[lower] = NULL;
1726  }
1727  j = upper + 1;
1728  continue;
1729  }
1730  else
1731  {
1732  p_Test (nodes[lower]->lcm_of_lm, c->r);
1733  nodes[lower]->lcm_of_lm = pCopy (nodes[lower]->lcm_of_lm);
1734  assume (__p_GetComp (c->S->m[nodes[lower]->i], c->r) ==
1735  __p_GetComp (c->S->m[nodes[lower]->j], c->r));
1736  nodes_final[spc_final] =
1737  (sorted_pair_node *) omAlloc (sizeof (sorted_pair_node));
1738 
1739  *(nodes_final[spc_final++]) = *(nodes[lower]);
1740  //c->tmp_spn[nodes[lower]->j]=(sorted_pair_node*) omalloc(sizeof(sorted_pair_node));
1741  nodes[lower] = NULL;
1742  for(lower = lower + 1; lower <= upper; lower++)
1743  {
1744  // free_sorted_pair_node(nodes[lower],c->r);
1745  //omfree(nodes[lower]);
1746  nodes[lower] = NULL;
1747  }
1748  j = upper + 1;
1749  continue;
1750  }
1751  }
1752 
1753  // Print("i:%d,spc_final:%d",i,spc_final);
1754 
1755  assume (spc_final <= spc);
1756  omFree (nodes);
1757  nodes = NULL;
1758 
1759  add_to_reductors (c, h, c->lengths[c->n - 1], ecart, TRUE);
1760  //i=posInS(c->strat,c->strat->sl,h,0 ecart);
1761  if(!(c->nc))
1762  {
1763  if(c->lengths[c->n - 1] == 1)
1764  shorten_tails (c, c->S->m[c->n - 1]);
1765  }
1766  //you should really update c->lengths, c->strat->lenS, and the oder of polys in strat if you sort after lengths
1767 
1768  //for(i=c->strat->sl; i>0;i--)
1769  // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i);
1770  if(c->Rcounter > 50)
1771  {
1772  c->Rcounter = 0;
1773  cleanS (c->strat, c);
1774  }
1775 
1776 #ifdef HAVE_PLURAL
1777  // for SCA:
1778  // here write at the end of nodes_final[spc_final,...,spc_final+lmdeg-1]
1779  if(rIsSCA (c->r))
1780  {
1781  const poly pNext = pNext (h);
1782 
1783  if(pNext != NULL)
1784  {
1785  // for additional polynomials
1786  const unsigned int m_iFirstAltVar = scaFirstAltVar (c->r);
1787  const unsigned int m_iLastAltVar = scaLastAltVar (c->r);
1788 
1789  int N = // c->r->N;
1790  m_iLastAltVar - m_iFirstAltVar + 1; // should be enough
1791  // TODO: but we may also use got = gcd({m}_{m\in f}))!
1792 
1793  poly *array_arg = (poly *) omalloc (N * sizeof (poly)); // !
1794  int j = 0;
1795 
1796 
1797  for(unsigned short v = m_iFirstAltVar; v <= m_iLastAltVar; v++)
1798  // for all x_v | Ann(lm(h))
1799  if(p_GetExp (h, v, c->r)) // TODO: use 'got' here!
1800  {
1801  assume (p_GetExp (h, v, c->r) == 1);
1802 
1803  poly p = sca_pp_Mult_xi_pp (v, pNext, c->r); // x_v * h;
1804 
1805  if(p != NULL) // if (x_v * h != 0)
1806  array_arg[j++] = p;
1807  } // for all x_v | Ann(lm(h))
1808 
1809  c->introduceDelayedPairs (array_arg, j);
1810 
1811  omFree (array_arg); // !!!
1812  }
1813 // PrintS("Saturation - done!!!\n");
1814  }
1815 #endif // if SCAlgebra
1816 
1817 
1818  if(!ip)
1819  {
1820  qsort (nodes_final, spc_final, sizeof (sorted_pair_node *),
1822 
1823 
1824  c->apairs =
1825  spn_merge (c->apairs, c->pair_top + 1, nodes_final, spc_final, c);
1826  c->pair_top += spc_final;
1828  omFree (nodes_final);
1829  return NULL;
1830  }
1831  {
1832  *ip = spc_final;
1833  return nodes_final;
1834  }
1835 }
static int iq_crit(const void *ap, const void *bp)
Definition: tgb.cc:1340
#define __p_GetComp(p, r)
Definition: monomials.h:70
static int add_to_reductors(slimgb_alg *c, poly h, int len, int ecart, BOOLEAN simplified=FALSE)
Definition: tgb.cc:965
const CanonicalForm int s
Definition: facAbsFact.cc:55
void introduceDelayedPairs(poly *pa, int s)
Definition: tgb.cc:3102
unsigned long pTotaldegree(poly p)
Definition: tgb_internal.h:285
int j
Definition: facHensel.cc:105
CFArray copy(const CFList &list)
write elements of list into an array
#define pSetm(p)
Definition: polys.h:257
static void add_later(poly p, const char *prot, slimgb_alg *c)
Definition: tgb.cc:1292
static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg *c)
Definition: tgb.cc:4042
sorted_pair_node ** apairs
Definition: tgb_internal.h:240
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
#define FALSE
Definition: auxiliary.h:94
sorted_pair_node ** tmp_spn
Definition: tgb_internal.h:236
wlen_type * weighted_lengths
Definition: tgb_internal.h:229
#define p_GetComp(p, r)
Definition: monomials.h:71
int pTotaldegree_full(poly p)
Definition: tgb_internal.h:293
CFFListIterator iter
Definition: facAbsBiFact.cc:54
int * T_deg_full
Definition: tgb_internal.h:233
#define TRUE
Definition: auxiliary.h:98
int kFindDivisibleByInS_easy(kStrategy strat, const red_object &obj)
Definition: tgb.cc:685
static void shorten_tails(slimgb_alg *c, poly monom)
Definition: tgb.cc:3677
#define pHasNotCF(p1, p2)
Definition: polys.h:249
#define pLcm(a, b, m)
Definition: polys.h:281
#define pMDivide(a, b)
Definition: polys.h:279
#define pExpVectorSub(p1, p2)
Definition: polys.h:88
static poly pOne_Special(const ring r=currRing)
Definition: tgb.cc:142
static BOOLEAN monomial_root(poly m, ring r)
Definition: tgb.cc:89
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
Definition: kspoly.cc:1005
#define omAlloc(size)
Definition: omAllocDecl.h:210
void clean_top_of_pair_list(slimgb_alg *c)
Definition: tgb.cc:3883
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
#define pIter(p)
Definition: monomials.h:44
long * short_Exps
Definition: tgb_internal.h:230
BOOLEAN nc
Definition: tgb_internal.h:281
static BOOLEAN has_t_rep(const int &arg_i, const int &arg_j, slimgb_alg *state)
Definition: tgb.cc:3644
#define TEST_OPT_INTSTRATEGY
Definition: options.h:109
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:469
#define omFree(addr)
Definition: omAllocDecl.h:261
int tgb_pair_better_gen2(const void *ap, const void *bp)
Definition: tgb.cc:680
#define assume(x)
Definition: mod2.h:390
kStrategy strat
Definition: tgb_internal.h:231
poly sca_pp_Mult_xi_pp(short i, const poly pPoly, const ring rRing)
Definition: sca.cc:1203
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition: p_polys.h:1849
int extended_product_crit
Definition: tgb_internal.h:268
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
static unsigned pLength(poly a)
Definition: p_polys.h:192
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1815
static short scaFirstAltVar(ring r)
Definition: sca.h:18
BOOLEAN is_homog
Definition: tgb_internal.h:277
intset lenS
Definition: kutil.h:310
#define p_Test(p, r)
Definition: p_polys.h:163
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4665
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
wlen_type expected_length
Definition: tgb_internal.h:157
#define ENLARGE(pointer, type)
#define omalloc(size)
Definition: omAllocDecl.h:228
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3633
static void cleanS(kStrategy strat, slimgb_alg *c)
Definition: tgb.cc:919
int64 wlen_type
Definition: kutil.h:50
static poly gcd_of_terms(poly p, ring r)
Definition: tgb.cc:3983
char ** states
Definition: tgb_internal.h:220
int * lengths
Definition: tgb_internal.h:228
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:349
poly * tmp_pair_lm
Definition: tgb_internal.h:235
static short scaLastAltVar(ring r)
Definition: sca.h:25
static bool rIsSCA(const ring r)
Definition: nc.h:198
#define pNext(p)
Definition: monomials.h:43
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
int array_lengths
Definition: tgb_internal.h:260
poly * gcd_of_terms
Definition: tgb_internal.h:238
static wlen_type pair_weighted_length(int i, int j, slimgb_alg *c)
Definition: tgb.cc:1373
#define TEST_V_FINDMONOM
Definition: options.h:139
sorted_pair_node ** spn_merge(sorted_pair_node **p, int pn, sorted_pair_node **q, int qn, slimgb_alg *c)
Definition: tgb.cc:751
int easy_product_crit
Definition: tgb_internal.h:267
int p
Definition: cfModGcd.cc:4019
#define TEST_V_UPTORADICAL
Definition: options.h:138
int syz_comp
array_lengths should be greater equal n;
Definition: tgb_internal.h:259
static Poly * h
Definition: janet.cc:972
int BOOLEAN
Definition: auxiliary.h:85
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2782
static wlen_type pQuality(poly p, slimgb_alg *c, int l=-1)
Definition: tgb.cc:544
#define pLmEqual(p1, p2)
Definition: polys.h:111
#define ENLARGE_ALIGN(pointer, type)
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172

◆ clean_top_of_pair_list()

void clean_top_of_pair_list ( slimgb_alg c)

Definition at line 3883 of file tgb.cc.

3884 {
3885  while((c->pair_top >= 0) && (c->apairs[c->pair_top]->i >= 0)
3886  &&
3887  (!state_is
3888  (UNCALCULATED, c->apairs[c->pair_top]->j, c->apairs[c->pair_top]->i,
3889  c)))
3890  {
3891  free_sorted_pair_node (c->apairs[c->pair_top], c->r);
3892  c->pair_top--;
3893  }
3894 }
sorted_pair_node ** apairs
Definition: tgb_internal.h:240
void free_sorted_pair_node(sorted_pair_node *s, const ring r)
Definition: tgb.cc:3916
static BOOLEAN state_is(calc_state state, const int &i, const int &j, slimgb_alg *c)
Definition: tgb.cc:3897

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

833  {
835 //int pos=0;
836 //Print("denseness:%f\n",((double) non_zeros/(double) temp_size));
837 number_type* it_coef=res->coef_array;
838 int* it_idx=res->idx_array;
839 #if 0
840 for(i=0;i<cache->nIrreducibleMonomials;i++){
841  if (!(0==temp_array[i])){
842 
843  res->idx_array[pos]=i;
844  res->coef_array[pos]=temp_array[i];
845 
846  pos++;
847  non_zeros--;
848  if (non_zeros==0) break;
849  }
850 
851 }
852 #else
853 int64* start=(int64*) ((void*)temp_array);
854 int64* end;
855 const int multiple=sizeof(int64)/sizeof(number_type);
856 if (temp_size==0) end=start;
857 
858 else
859 {
860  int temp_size_rounded=temp_size+(multiple-(temp_size%multiple));
861  assume(temp_size_rounded>=temp_size);
862  assume(temp_size_rounded%multiple==0);
863  assume(temp_size_rounded<temp_size+multiple);
864  number_type* nt_end=temp_array+temp_size_rounded;
865  end=(int64*)((void*)nt_end);
866 }
867 int64* it=start;
868 while(it!=end)
869 {
870  if UNLIKELY((*it)!=0)
871  {
872  int small_i;
873  const int temp_index=((number_type*)((void*) it))-temp_array;
874  const int bound=temp_index+multiple;
875  number_type c;
876  for(small_i=temp_index;small_i<bound;small_i++)
877  {
878  if((c=temp_array[small_i])!=0)
879  {
880  //res->idx_array[pos]=small_i;
881  //res->coef_array[pos]=temp_array[small_i];
882  (*(it_idx++))=small_i;
883  (*(it_coef++))=c;
884  //pos++;
885  non_zeros--;
886 
887  }
888  if UNLIKELY(non_zeros==0) break;
889  }
890 
891  }
892  ++it;
893 }
894 #endif
895 return res;
896 }
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
int * idx_array
Definition: tgb_internal.h:513
long int64
Definition: auxiliary.h:66
#define UNLIKELY
Definition: auxiliary.h:422
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
number_type * coef_array
Definition: tgb_internal.h:514

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

3569 {
3570  // 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)));
3571 
3572  if(TEST_OPT_PROT)
3573  if(F4_mode)
3574  PrintS ("F4 Modus\n");
3575 
3576  //debug_Ideal=arg_debug_Ideal;
3577  //if (debug_Ideal) PrintS("DebugIdeal received\n");
3578  // Print("Idelems %i \n----------\n",IDELEMS(arg_I));
3579  ideal I = arg_I;
3580  id_Compactify (I,currRing);
3581  if(idIs0 (I))
3582  return I;
3583  int i;
3584  for(i = 0; i < IDELEMS (I); i++)
3585  {
3586  assume (I->m[i] != NULL);
3587  simplify_poly (I->m[i], currRing);
3588  }
3589 
3590  qsort (I->m, IDELEMS (I), sizeof (poly), poly_crit);
3591  //Print("Idelems %i \n----------\n",IDELEMS(I));
3592  //slimgb_alg* c=(slimgb_alg*) omalloc(sizeof(slimgb_alg));
3593  //int syz_comp=arg_I->rank;
3594  slimgb_alg *c = new slimgb_alg (I, syz_comp, F4_mode, deg_pos);
3595 
3596  while((c->pair_top >= 0)
3597  && ((!(TEST_OPT_DEGBOUND))
3598  || (c->apairs[c->pair_top]->deg <= Kstd1_deg)))
3599  {
3600 #ifdef HAVE_F4
3601  if(F4_mode)
3602  go_on_F4 (c);
3603  else
3604 #endif
3605  go_on (c);
3606  }
3607  if(c->pair_top < 0)
3608  c->completed = TRUE;
3609  I = c->S;
3610  delete c;
3611  if(TEST_OPT_REDSB)
3612  {
3613  ideal erg = kInterRed (I, NULL);
3614  assume (I != erg);
3615  id_Delete (&I, currRing);
3616  return erg;
3617  }
3618  //qsort(I->m, IDELEMS(I),sizeof(poly),pLmCmp_func);
3619  assume (I->rank >= id_RankFreeModule (I,currRing));
3620  return (I);
3621 }
#define TEST_OPT_DEGBOUND
Definition: options.h:112
sorted_pair_node ** apairs
Definition: tgb_internal.h:240
#define TEST_OPT_PROT
Definition: options.h:102
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define TRUE
Definition: auxiliary.h:98
#define TEST_OPT_REDSB
Definition: options.h:103
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
static void go_on(slimgb_alg *c)
Definition: tgb.cc:2678
#define assume(x)
Definition: mod2.h:390
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3387
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define IDELEMS(i)
Definition: simpleideals.h:24
static int poly_crit(const void *ap1, const void *ap2)
Definition: tgb.cc:3084
#define NULL
Definition: omList.c:10
BOOLEAN completed
Definition: tgb_internal.h:276
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static void simplify_poly(poly p, ring r)
Definition: tgb.cc:59
int Kstd1_deg
Definition: kutil.cc:236
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void id_Compactify(ideal id, const ring r)

◆ free_sorted_pair_node()

void free_sorted_pair_node ( sorted_pair_node s,
const ring  r 
)

Definition at line 3916 of file tgb.cc.

3917 {
3918  if(s->i >= 0)
3919  p_Delete (&s->lcm_of_lm, r);
3920  omFree (s);
3921 }
#define omFree(addr)
Definition: omAllocDecl.h:261
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857

◆ kFindDivisibleByInS_easy() [1/2]

int kFindDivisibleByInS_easy ( kStrategy  strat,
const red_object obj 
)

Definition at line 685 of file tgb.cc.

686 {
687  poly p = obj.p;
688  if ((strat->syzComp>0) && (pGetComp(p)>strat->syzComp)) return -1;
689  long not_sev = ~obj.sev;
690  for(int i = 0; i <= strat->sl; i++)
691  {
692  if(pLmShortDivisibleBy (strat->S[i], strat->sevS[i], p, not_sev))
693  return i;
694  }
695  return -1;
696 }
int syzComp
Definition: kutil.h:347
#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
int i
Definition: cfEzgcd.cc:125
polyset S
Definition: kutil.h:297
unsigned long * sevS
Definition: kutil.h:313
int sl
Definition: kutil.h:341
unsigned long sev
Definition: tgb_internal.h:310
int p
Definition: cfModGcd.cc:4019

◆ kFindDivisibleByInS_easy() [2/2]

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

Definition at line 698 of file tgb.cc.

699 {
700  if ((strat->syzComp>0) && (pGetComp(p)>strat->syzComp)) return -1;
701  long not_sev = ~sev;
702  for(int i = 0; i <= strat->sl; i++)
703  {
704  if(pLmShortDivisibleBy (strat->S[i], strat->sevS[i], p, not_sev))
705  return i;
706  }
707  return -1;
708 }
int syzComp
Definition: kutil.h:347
#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
int i
Definition: cfEzgcd.cc:125
polyset S
Definition: kutil.h:297
unsigned long * sevS
Definition: kutil.h:313
int sl
Definition: kutil.h:341
int p
Definition: cfModGcd.cc:4019

◆ modP_lastIndexRow()

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

Definition at line 1489 of file tgb_internal.h.

1490 {
1491  int lastIndex;
1492  const number_type zero=0;//npInit(0);
1493  for(lastIndex=ncols-1;lastIndex>=0;lastIndex--)
1494  {
1495  if (!(row[lastIndex]==zero))
1496  {
1497  return lastIndex;
1498  }
1499  }
1500  return -1;
1501 }
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 754 of file tgb_internal.h.

755 {
756  MonRedResNP<number_type> res_holder;
757 
758 
760  if (ref!=NULL)
761  {
762  res_holder.coef=p_GetCoeff(t,c->r);
763 
764  res_holder.ref=ref;
765  p_Delete(&t,c->r);
766  return res_holder;
767  }
768 
769  unsigned long sev=p_GetShortExpVector(t,currRing);
770  int i=kFindDivisibleByInS_easy(c->strat,t,sev);
771  if (i>=0)
772  {
773  number coef_bak=p_GetCoeff(t,c->r);
774 
775  p_SetCoeff(t,npInit(1,c->r->cf),c->r);
776  assume(npIsOne(p_GetCoeff(c->strat->S[i],c->r),c->r->cf));
777  number coefstrat=p_GetCoeff(c->strat->S[i],c->r);
778 
779 
780  poly exp_diff=cache->temp_term;
781  p_ExpVectorDiff(exp_diff,t,c->strat->S[i],c->r);
782  p_SetCoeff(exp_diff,npNeg(npInvers(coefstrat,c->r->cf),c->r->cf),c->r);
783  p_Setm(exp_diff,c->r);
784  assume(c->strat->S[i]!=NULL);
785 
786  poly res;
787  res=pp_Mult_mm(pNext(c->strat->S[i]),exp_diff,c->r);
788 
789  int len=c->strat->lenS[i]-1;
791  srow=noro_red_to_non_poly_t<number_type>(res,len,cache,c);
792  ref=cache->insert(t,srow);
793  p_Delete(&t,c->r);
794 
795 
796  res_holder.coef=coef_bak;
797  res_holder.ref=ref;
798  return res_holder;
799 
800  } else {
801  number coef_bak=p_GetCoeff(t,c->r);
802  number one=npInit(1, c->r->cf);
803  p_SetCoeff(t,one,c->r);
804 
805  res_holder.ref=cache->insertAndTransferOwnerShip(t,c->r);
806  assume(res_holder.ref!=NULL);
807  res_holder.coef=coef_bak;
808 
809  return res_holder;
810 
811  }
812 
813 }
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:987
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
#define npInvers
Definition: tgb_internal.h:74
CanonicalForm res
Definition: facAbsFact.cc:64
int kFindDivisibleByInS_easy(kStrategy strat, const red_object &obj)
Definition: tgb.cc:685
#define assume(x)
Definition: mod2.h:390
DataNoroCacheNode< number_type > * getCacheReference(poly term)
kStrategy strat
Definition: tgb_internal.h:231
int i
Definition: cfEzgcd.cc:125
polyset S
Definition: kutil.h:297
intset lenS
Definition: kutil.h:310
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4665
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1420
poly temp_term
Definition: tgb_internal.h:589
#define NULL
Definition: omList.c:10
#define npInit
Definition: tgb_internal.h:72
#define pNext(p)
Definition: monomials.h:43
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
#define p_GetCoeff(p, r)
Definition: monomials.h:57
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:148
#define npNeg
Definition: tgb_internal.h:73
#define npIsOne
Definition: tgb_internal.h:76

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

1088 {
1089  size_t temp_size_bytes=cache->nIrreducibleMonomials*sizeof(number_type)+8;//use 8bit int for testing
1090  assume(sizeof(int64)==8);
1091  cache->ensureTempBufferSize(temp_size_bytes);
1092  number_type* temp_array=(number_type*) cache->tempBuffer;//omalloc(cache->nIrreducibleMonomials*sizeof(number_type));
1093  int temp_size=cache->nIrreducibleMonomials;
1094  memset(temp_array,0,temp_size_bytes);
1095  number minus_one=npInit(-1,currRing->cf);
1096  int i;
1097  for(i=0;i<len;i++)
1098  {
1099  MonRedResNP<number_type> red=mon[i];
1100  if ( /*(*/ red.ref /*)*/ )
1101  {
1102  if (red.ref->row)
1103  {
1104  SparseRow<number_type>* row=red.ref->row;
1105  number coef=red.coef;
1106  if (row->idx_array)
1107  {
1108  if (!((coef==(number)1L)||(coef==minus_one)))
1109  {
1110  add_coef_times_sparse(temp_array,temp_size,row,coef);
1111  }
1112  else
1113  {
1114  if (coef==(number)1L)
1115  {
1116  add_sparse(temp_array,temp_size,row);
1117  }
1118  else
1119  {
1120  sub_sparse(temp_array,temp_size,row);
1121  }
1122  }
1123  }
1124  else
1125  //TODO: treat, 1,-1
1126  if (!((coef==(number)1L)||(coef==minus_one)))
1127  {
1128  add_coef_times_dense(temp_array,temp_size,row->coef_array,row->len,coef);
1129  }
1130  else
1131  {
1132  if (coef==(number)1L)
1133  add_dense(temp_array,temp_size,row->coef_array,row->len);
1134  else
1135  {
1136  assume(coef==minus_one);
1137  sub_dense(temp_array,temp_size,row->coef_array,row->len);
1138  //add_coef_times_dense(temp_array,temp_size,row->coef_array,row->len,coef);
1139  }
1140  }
1141  }
1142  else
1143  {
1144  if (red.ref->value_len==NoroCache<number_type>::backLinkCode)
1145  {
1146  STATISTIC(n_Add); temp_array[red.ref->term_index]=F4mat_to_number_type( npAddM((number)(long) temp_array[red.ref->term_index],red.coef,currRing->cf));
1147  }
1148  else
1149  {
1150  //PrintS("third case\n");
1151  }
1152  }
1153  }
1154  }
1155  int non_zeros=0;
1156  for(i=0;i<cache->nIrreducibleMonomials;i++)
1157  {
1158  //if (!(temp_array[i]==0)){
1159  // non_zeros++;
1160  //}
1161  assume(((temp_array[i]!=0)==0)|| (((temp_array[i]!=0)==1)));
1162  non_zeros+=(temp_array[i]!=0);
1163  }
1164 
1165  if (non_zeros==0)
1166  {
1167  //omfree(mon);
1168  return NULL;
1169  }
1170  SparseRow<number_type>* res=new SparseRow<number_type>(temp_size,temp_array);//convert_to_sparse_row(temp_array,temp_size, non_zeros);
1171 
1172  //omfree(temp_array);
1173 
1174 
1175  return res;
1176 }
#define STATISTIC(f)
Definition: numstats.h:16
void add_dense(number_type *const temp_array, int, const number_type *row, int len)
Definition: tgb_internal.h:994
int * idx_array
Definition: tgb_internal.h:513
long int64
Definition: auxiliary.h:66
void add_coef_times_sparse(number_type *const temp_array, int, SparseRow< number_type > *row, number coef)
Definition: tgb_internal.h:898
void add_coef_times_dense(number_type *const temp_array, int, const number_type *row, int len, number coef)
Definition: tgb_internal.h:946
void add_sparse(number_type *const temp_array, int, SparseRow< number_type > *row)
void * tempBuffer
Definition: tgb_internal.h:704
CanonicalForm res
Definition: facAbsFact.cc:64
void ensureTempBufferSize(size_t size)
Definition: tgb_internal.h:666
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
int i
Definition: cfEzgcd.cc:125
number_type * coef_array
Definition: tgb_internal.h:514
void sub_sparse(number_type *const temp_array, int, SparseRow< number_type > *row)
#define NULL
Definition: omList.c:10
#define npInit
Definition: tgb_internal.h:72
void sub_dense(number_type *const temp_array, int, const number_type *row, int len)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424
int nIrreducibleMonomials
Definition: tgb_internal.h:702
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:148

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

1277 {
1278  int i;
1279  int together=0;
1280  for(i=0;i<len;i++)
1281  {
1282  MonRedResNP<number_type> red=mon[i];
1283  if ((red.ref) &&( red.ref->row))
1284  {
1285  together+=red.ref->row->len;
1286  }
1287  else
1288  {
1289  if ((red.ref) &&(red.ref->value_len==NoroCache<number_type>::backLinkCode))
1290  together++;
1291  }
1292  }
1293  //PrintS("here\n");
1294  if (together==0) return 0;
1295  //PrintS("there\n");
1296  cache->ensureTempBufferSize(together*sizeof(CoefIdx<number_type>));
1297  CoefIdx<number_type>* pairs=(CoefIdx<number_type>*) cache->tempBuffer; //omalloc(together*sizeof(CoefIdx<number_type>));
1298  int pos=0;
1299  const number one=npInit(1, currRing->cf);
1300  const number minus_one=npInit(-1, currRing->cf);
1301  for(i=0;i<len;i++)
1302  {
1303  MonRedResNP<number_type> red=mon[i];
1304  if ((red.ref) &&( red.ref->row))
1305  {
1306  //together+=red.ref->row->len;
1307  int* idx_array=red.ref->row->idx_array;
1308  number_type* coef_array=red.ref->row->coef_array;
1309  int rlen=red.ref->row->len;
1310  number coef=red.coef;
1311  if (idx_array)
1312  {
1313  if ((coef!=one)&&(coef!=minus_one))
1314  {
1315  write_coef_times_xx_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen, coef);
1316  }
1317  else
1318  {
1319  if (coef==one)
1320  {
1321  write_coef_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen);
1322  }
1323  else
1324  {
1325  assume(coef==minus_one);
1326  write_minus_coef_idx_to_buffer(pairs,pos,idx_array, coef_array,rlen);
1327  }
1328  }
1329  }
1330  else
1331  {
1332  if ((coef!=one)&&(coef!=minus_one))
1333  {
1334  write_coef_times_xx_idx_to_buffer_dense(pairs,pos,coef_array,rlen,coef);
1335  }
1336  else
1337  {
1338  if (coef==one)
1339  write_coef_idx_to_buffer_dense(pairs,pos,coef_array,rlen);
1340  else
1341  {
1342  assume(coef==minus_one);
1343  write_minus_coef_idx_to_buffer_dense(pairs,pos,coef_array,rlen);
1344  }
1345  }
1346  }
1347  }
1348  else
1349  {
1350  if ((red.ref) &&(red.ref->value_len==NoroCache<number_type>::backLinkCode))
1351  {
1353  ci.coef=F4mat_to_number_type(red.coef);
1354  ci.idx=red.ref->term_index;
1355  pairs[pos++]=ci;
1356  }
1357  }
1358  }
1359  assume(pos<=together);
1360  together=pos;
1361 
1362  std::sort(pairs,pairs+together);
1363 
1364  int act=0;
1365 
1366  assume(pairs[0].coef!=0);
1367  for(i=1;i<together;i++)
1368  {
1369  if (pairs[i].idx!=pairs[act].idx)
1370  {
1371  if (pairs[act].coef!=0)
1372  {
1373  act=act+1;
1374  }
1375  pairs[act]=pairs[i];
1376  }
1377  else
1378  {
1379  STATISTIC(n_Add); pairs[act].coef=F4mat_to_number_type(npAddM((number)(long)pairs[act].coef,(number)(long)pairs[i].coef,currRing->cf));
1380  }
1381  }
1382 
1383  if (pairs[act].coef==0)
1384  {
1385  act--;
1386  }
1387  int sparse_row_len=act+1;
1388  //Print("res len:%d",sparse_row_len);
1389  if (sparse_row_len==0) {return NULL;}
1390  SparseRow<number_type>* res=new SparseRow<number_type>(sparse_row_len);
1391  {
1392  number_type* coef_array=res->coef_array;
1393  int* idx_array=res->idx_array;
1394  for(i=0;i<sparse_row_len;i++)
1395  {
1396  idx_array[i]=pairs[i].idx;
1397  coef_array[i]=pairs[i].coef;
1398  }
1399  }
1400  //omfree(pairs);
1401 
1402  return res;
1403 }
#define STATISTIC(f)
Definition: numstats.h:16
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_minus_coef_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)
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)
int * idx_array
Definition: tgb_internal.h:513
number_type coef
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 * tempBuffer
Definition: tgb_internal.h:704
void write_coef_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)
CanonicalForm res
Definition: facAbsFact.cc:64
void ensureTempBufferSize(size_t size)
Definition: tgb_internal.h:666
void pairs()
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
int i
Definition: cfEzgcd.cc:125
number_type * coef_array
Definition: tgb_internal.h:514
#define NULL
Definition: omList.c:10
#define npInit
Definition: tgb_internal.h:72
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void sort(CFArray &A, int l=0)
quick sort A
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424
static scmon act
Definition: hdegree.cc:1078
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:148
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)

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

1404  {
1405  assume(len==pLength(p));
1406  if (p==NULL)
1407  {
1408  len=0;
1409  return NULL;
1410  }
1411 
1413  int i=0;
1414  double max_density=0.0;
1415  while(p!=NULL)
1416  {
1417  poly t=p;
1418  pIter(p);
1419  pNext(t)=NULL;
1420 
1422  if ((red.ref) && (red.ref->row))
1423  {
1424  double act_density=(double) red.ref->row->len;
1425  act_density/=(double) cache->nIrreducibleMonomials;
1426  max_density=std::max(act_density,max_density);
1427  }
1428  mon[i]=red;
1429  i++;
1430  }
1431 
1432  assume(i==len);
1433  len=i;
1434  bool dense=true;
1435  if (max_density<0.3) dense=false;
1436  if (dense)
1437  {
1439  omfree(mon);
1440  return res;
1441  }
1442  else
1443  {
1445  omfree(mon);
1446  return res;
1447  }
1448  //in the loop before nIrreducibleMonomials increases, so position here is important
1449 
1450 }
#define pIter(p)
Definition: monomials.h:44
CanonicalForm res
Definition: facAbsFact.cc:64
static int max(int a, int b)
Definition: fast_mult.cc:264
#define assume(x)
Definition: mod2.h:390
#define omfree(addr)
Definition: omAllocDecl.h:237
MonRedResNP< number_type > noro_red_mon_to_non_poly(poly t, NoroCache< number_type > *cache, slimgb_alg *c)
Definition: tgb_internal.h:754
int i
Definition: cfEzgcd.cc:125
SparseRow< number_type > * noro_red_to_non_poly_dense(MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)
static unsigned pLength(poly a)
Definition: p_polys.h:192
SparseRow< number_type > * noro_red_to_non_poly_sparse(MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)
#define omalloc(size)
Definition: omAllocDecl.h:228
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
int nIrreducibleMonomials
Definition: tgb_internal.h:702
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:148
int p
Definition: cfModGcd.cc:4019

◆ noro_step()

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

Definition at line 1786 of file tgb_internal.h.

1786  {
1787  //Print("Input rows %d\n",pn);
1788  int j;
1789  if (TEST_OPT_PROT)
1790  {
1791  Print("Input rows %d\n",pn);
1792  }
1793 
1794  NoroCache<number_type> cache;
1795 
1797  int non_zeros=0;
1798  for(j=0;j<pn;j++)
1799  {
1800  poly h=p[j];
1801  int h_len=pLength(h);
1802  //number coef;
1803  srows[non_zeros]=noro_red_to_non_poly_t<number_type>(h,h_len,&cache,c);
1804  if (srows[non_zeros]!=NULL) non_zeros++;
1805  }
1806  std::vector<DataNoroCacheNode<number_type>*> irr_nodes;
1807  cache.collectIrreducibleMonomials(irr_nodes);
1808  //now can build up terms array
1809  //Print("historic irred Mon%d\n",cache.nIrreducibleMonomials);
1810  int n=irr_nodes.size();//cache.countIrreducibleMonomials();
1811  cache.nIrreducibleMonomials=n;
1812  if (TEST_OPT_PROT)
1813  {
1814  Print("Irred Mon:%d\n",n);
1815  Print("red Mon:%d\n",cache.nReducibleMonomials);
1816  }
1818 
1819  for(j=0;j<n;j++)
1820  {
1821  assume(irr_nodes[j]!=NULL);
1822  assume(irr_nodes[j]->value_len==NoroCache<number_type>::backLinkCode);
1823  term_nodes[j].t=irr_nodes[j]->value_poly;
1824  assume(term_nodes[j].t!=NULL);
1825  term_nodes[j].node=irr_nodes[j];
1826  }
1827 
1828  qsort(term_nodes,n,sizeof(TermNoroDataNode<number_type>),term_nodes_sort_crit<number_type>);
1829  poly* terms=(poly*) omalloc(n*sizeof(poly));
1830 
1831  int* old_to_new_indices=(int*) omalloc(cache.nIrreducibleMonomials*sizeof(int));
1832  for(j=0;j<n;j++)
1833  {
1834  old_to_new_indices[term_nodes[j].node->term_index]=j;
1835  term_nodes[j].node->term_index=j;
1836  terms[j]=term_nodes[j].t;
1837  }
1838 
1839  //if (TEST_OPT_PROT)
1840  // Print("Evaluate Rows \n");
1841  pn=non_zeros;
1842  number_type* number_array=(number_type*) omalloc0(n*pn*sizeof(number_type));
1843 
1844  for(j=0;j<pn;j++)
1845  {
1846  int i;
1847  number_type* row=number_array+n*j;
1848  /*for(i=0;i<n;i++)
1849  {
1850  row[i]=zero;
1851  }*/
1852 
1853  SparseRow<number_type>* srow=srows[j];
1854 
1855  if (srow)
1856  {
1857  int* const idx_array=srow->idx_array;
1858  number_type* const coef_array=srow->coef_array;
1859  const int len=srow->len;
1860  if (srow->idx_array)
1861  {
1862  for(i=0;i<len;i++)
1863  {
1864  int idx=old_to_new_indices[idx_array[i]];
1865  row[idx]=F4mat_to_number_type(coef_array[i]);
1866  }
1867  }
1868  else
1869  {
1870  for(i=0;i<len;i++)
1871  {
1872  row[old_to_new_indices[i]]=F4mat_to_number_type(coef_array[i]);
1873  }
1874  }
1875  delete srow;
1876  }
1877  }
1878 
1879  //static int export_n=0;
1880  //export_mat(number_array,pn,n,"mat%i.py",++export_n);
1881  simplest_gauss_modp(number_array,pn,n);
1882 
1883  int p_pos=0;
1884  for(j=0;j<pn;j++){
1885  poly h=row_to_poly(number_array+j*n,terms,n,c->r);
1886  if(h!=NULL){
1887  p[p_pos++]=h;
1888  }
1889  }
1890  pn=p_pos;
1891  omfree(terms);
1892  omfree(term_nodes);
1893  omfree(number_array);
1894  #ifdef NORO_NON_POLY
1895  omfree(srows);
1896  omfree(old_to_new_indices);
1897  #endif
1898  //don't forget the rank
1899 
1900 }
int j
Definition: facHensel.cc:105
#define Print
Definition: emacs.cc:80
void simplest_gauss_modp(number_type *a, int nrows, int ncols)
#define TEST_OPT_PROT
Definition: options.h:102
number * number_array
Definition: ntupel.cc:26
int * idx_array
Definition: tgb_internal.h:513
#define omAlloc(size)
Definition: omAllocDecl.h:210
poly row_to_poly(number_type *row, poly *terms, int tn, ring r)
#define assume(x)
Definition: mod2.h:390
#define omfree(addr)
Definition: omAllocDecl.h:237
int i
Definition: cfEzgcd.cc:125
number_type * coef_array
Definition: tgb_internal.h:514
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define omalloc(size)
Definition: omAllocDecl.h:228
#define NULL
Definition: omList.c:10
#define omalloc0(size)
Definition: omAllocDecl.h:229
DataNoroCacheNode< number_type > * node
Definition: tgb_internal.h:582
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424
int p
Definition: cfModGcd.cc:4019
static Poly * h
Definition: janet.cc:972

◆ now_t_rep()

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

Definition at line 3623 of file tgb.cc.

3624 {
3625  int i, j;
3626  if(arg_i == arg_j)
3627  {
3628  return;
3629  }
3630  if(arg_i > arg_j)
3631  {
3632  i = arg_j;
3633  j = arg_i;
3634  }
3635  else
3636  {
3637  i = arg_i;
3638  j = arg_j;
3639  }
3640  c->states[j][i] = HASTREP;
3641 }
int j
Definition: facHensel.cc:105
int i
Definition: cfEzgcd.cc:125
char ** states
Definition: tgb_internal.h:220

◆ pELength()

wlen_type pELength ( poly  p,
ring  r 
)

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

394 {
395  //Print("POSHELER:%d",sizeof(wlen_type));
396  int length=strat->sl;
397  int i;
398  int an = 0;
399  int en= length;
400 
401  if ((len>setL[length])
402  || ((len==setL[length]) && (pLmCmp(set[length],p)== -1)))
403  return length+1;
404 
405  loop
406  {
407  if (an >= en-1)
408  {
409  if ((len<setL[an])
410  || ((len==setL[an]) && (pLmCmp(set[an],p) == 1))) return an;
411  return en;
412  }
413  i=(an+en) / 2;
414  if ((len<setL[i])
415  || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i;
416  //else if ((len>setL[i])
417  //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i;
418  else an=i;
419  }
420 
421 }
#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:78
int i
Definition: cfEzgcd.cc:125
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
int sl
Definition: kutil.h:341
int p
Definition: cfModGcd.cc:4019

◆ quick_pop_pair()

sorted_pair_node* quick_pop_pair ( slimgb_alg c)

Definition at line 3862 of file tgb.cc.

3863 {
3864  if(c->pair_top < 0)
3865  return NULL;
3866  else
3867  return (c->apairs[c->pair_top--]);
3868 }
sorted_pair_node ** apairs
Definition: tgb_internal.h:240
#define NULL
Definition: omList.c:10

◆ row_to_poly()

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

Definition at line 1473 of file tgb_internal.h.

1473  {
1474  poly h=NULL;
1475  int j;
1476  number_type zero=0;//;npInit(0);
1477  for(j=tn-1;j>=0;j--){
1478  if (!(zero==(row[j]))){
1479  poly t=terms[j];
1480  t=p_LmInit(t,r);
1481  p_SetCoeff(t,(number)(long) row[j],r);
1482  pNext(t)=h;
1483  h=t;
1484  }
1485 
1486  }
1487  return h;
1488 }
int j
Definition: facHensel.cc:105
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1281
static Poly * h
Definition: janet.cc:972

◆ simplest_gauss_modp()

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

Definition at line 1764 of file tgb_internal.h.

1765 {
1766  //use memmoves for changing rows
1767  //if (TEST_OPT_PROT)
1768  // PrintS("StartGauss\n");
1770 
1771  int c=0;
1772  int r=0;
1773  while(mat.findPivot(r,c)){
1774  //int pivot=find_pivot()
1775  mat.reduceOtherRowsForward(r);
1776  r++;
1777  c++;
1778  }
1780  backmat.backwardSubstitute();
1781  //backward substitutions
1782  //if (TEST_OPT_PROT)
1783  //PrintS("StopGauss\n");
1784 }
int nrows
Definition: cf_linsys.cc:32
int int ncols
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 nlQlogSize(number n, const coeffs r)
only used by slimgb (tgb.cc)
Definition: longrat.h:77
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:495
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:571

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

753 {
754  int i;
755  int *a = (int *) omalloc (qn * sizeof (int));
756 // int mc;
757 // PrintS("Debug\n");
758 // for(mc=0;mc<qn;mc++)
759 // {
760 // wrp(q[mc]->lcm_of_lm);
761 // PrintS("\n");
762 // }
763 // PrintS("Debug they are in\n");
764 // for(mc=0;mc<pn;mc++)
765 // {
766 // wrp(p[mc]->lcm_of_lm);
767 // PrintS("\n");
768 // }
769  int lastpos = 0;
770  for(i = 0; i < qn; i++)
771  {
772  lastpos = posInPairs (p, pn, q[i], c, si_max (lastpos - 1, 0));
773  // cout<<lastpos<<"\n";
774  a[i] = lastpos;
775  }
776  if((pn + qn) > c->max_pairs)
777  {
778  p =
779  (sorted_pair_node **) omrealloc (p,
780  2 * (pn +
781  qn) *
782  sizeof (sorted_pair_node *));
783  c->max_pairs = 2 * (pn + qn);
784  }
785  for(i = qn - 1; i >= 0; i--)
786  {
787  size_t size;
788  if(qn - 1 > i)
789  size = (a[i + 1] - a[i]) * sizeof (sorted_pair_node *);
790  else
791  size = (pn - a[i]) * sizeof (sorted_pair_node *); //as indices begin with 0
792  memmove (p + a[i] + (1 + i), p + a[i], size);
793  p[a[i] + i] = q[i];
794  }
795  omFree (a);
796  return p;
797 }
#define omFree(addr)
Definition: omAllocDecl.h:261
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
static int posInPairs(sorted_pair_node **p, int pn, sorted_pair_node *qe, slimgb_alg *c, int an=0)
Definition: tgb.cc:711
int i
Definition: cfEzgcd.cc:125
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define omalloc(size)
Definition: omAllocDecl.h:228
#define omrealloc(addr, size)
Definition: omAllocDecl.h:233
int p
Definition: cfModGcd.cc:4019

◆ sub_dense()

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

Definition at line 1020 of file tgb_internal.h.

1026 {
1027  //int j;
1028  //const number_type* const coef_array=row;
1029  //int* const idx_array=row->idx_array;
1030  //const int len=temp_size;
1031  //tgb_uint32 buffer[256];
1032  //const tgb_uint32 prime=npPrimeM;
1033  //const tgb_uint32 c=F4mat_to_number_type(coef);
1034 
1035  int i;
1036  for(i=0;i<len;i++)
1037  {
1038 
1039  STATISTIC(n_Sub); temp_array[i]=F4mat_to_number_type(npSubM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
1040  #ifndef SING_NDEBUG
1041  assume(i<temp_size);
1042  #endif
1043  }
1044 
1045 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:670
#define STATISTIC(f)
Definition: numstats.h:16
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:126
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

◆ sub_sparse()

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

Definition at line 1068 of file tgb_internal.h.

1072 {
1073  int j;
1074 
1075  number_type* const coef_array=row->coef_array;
1076  int* const idx_array=row->idx_array;
1077  const int len=row->len;
1078  for(j=0;j<len;j++)
1079  {
1080  int idx=idx_array[j];
1081  STATISTIC(n_Sub); temp_array[idx]=F4mat_to_number_type( (number_type)(long) npSubM((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
1082  #ifndef SING_NDEBUG
1083  assume(idx<temp_size);
1084  #endif
1085  }
1086 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:670
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
int * idx_array
Definition: tgb_internal.h:513
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:126
#define assume(x)
Definition: mod2.h:390
number_type * coef_array
Definition: tgb_internal.h:514
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

◆ term_nodes_sort_crit()

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

Definition at line 1502 of file tgb_internal.h.

1503 {
1505 }
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:105
CanonicalForm b
Definition: cfModGcd.cc:4044

◆ terms_sort_crit()

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

Definition at line 2030 of file tgb.cc.

2031 {
2032  return -pLmCmp (*((poly *) a), *((poly *) b));
2033 }
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:105
CanonicalForm b
Definition: cfModGcd.cc:4044

◆ tgb_pair_better_gen2()

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

Definition at line 680 of file tgb.cc.

681 {
682  return (-tgb_pair_better_gen (ap, bp));
683 }
Definition: ap.h:39
static int tgb_pair_better_gen(const void *ap, const void *bp)
Definition: tgb.cc:3951

◆ top_pair()

sorted_pair_node* top_pair ( slimgb_alg c)

Definition at line 3838 of file tgb.cc.

3839 {
3840  while(c->pair_top >= 0)
3841  {
3842  super_clean_top_of_pair_list (c); //yeah, I know, it's odd that I use a different proc here
3843  if((c->is_homog) && (c->pair_top >= 0)
3844  && (c->apairs[c->pair_top]->deg >= c->lastCleanedDeg + 2))
3845  {
3846  int upper = c->apairs[c->pair_top]->deg - 1;
3847  c->cleanDegs (c->lastCleanedDeg + 1, upper);
3848  c->lastCleanedDeg = upper;
3849  }
3850  else
3851  {
3852  break;
3853  }
3854  }
3855 
3856  if(c->pair_top < 0)
3857  return NULL;
3858  else
3859  return (c->apairs[c->pair_top]);
3860 }
sorted_pair_node ** apairs
Definition: tgb_internal.h:240
void cleanDegs(int lower, int upper)
Definition: tgb.cc:3756
BOOLEAN is_homog
Definition: tgb_internal.h:277
static void super_clean_top_of_pair_list(slimgb_alg *c)
Definition: tgb.cc:3870
int lastCleanedDeg
Definition: tgb_internal.h:271
#define NULL
Definition: omList.c:10

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

1252 {
1253  int j;
1254  for(j=0;j<rlen;j++)
1255  {
1256  assume(coef_array[j]!=0);
1258  ci.coef=coef_array[j];
1259  ci.idx=idx_array[j];
1260  pairs[pos++]=ci;
1261  }
1262 }
int j
Definition: facHensel.cc:105
number_type coef
#define assume(x)
Definition: mod2.h:390

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

1217 {
1218  int j;
1219 
1220  for(j=0;j<rlen;j++)
1221  {
1222  if (coef_array[j]!=0)
1223  {
1224  assume(coef_array[j]!=0);
1226  ci.coef=coef_array[j];
1227  assume(ci.coef!=0);
1228  ci.idx=j;
1229  pairs[pos++]=ci;
1230  }
1231  }
1232 }
int j
Definition: facHensel.cc:105
number_type coef
#define assume(x)
Definition: mod2.h:390

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

1188 {
1189  int j;
1190  for(j=0;j<rlen;j++)
1191  {
1192  assume(coef_array[j]!=0);
1194  STATISTIC(n_Mult); ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1195  ci.idx=idx_array[j];
1196  pairs[pos++]=ci;
1197  }
1198 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:63
number_type coef
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:637
#define assume(x)
Definition: mod2.h:390
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

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

1200 {
1201  int j;
1202 
1203  for(j=0;j<rlen;j++)
1204  {
1205  if (coef_array[j]!=0)
1206  {
1207  assume(coef_array[j]!=0);
1209  STATISTIC(n_Mult); ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1210  assume(ci.coef!=0);
1211  ci.idx=j;
1212  pairs[pos++]=ci;
1213  }
1214  }
1215 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:63
number_type coef
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:637
#define assume(x)
Definition: mod2.h:390
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

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

1265 {
1266  int j;
1267  for(j=0;j<rlen;j++)
1268  {
1269  assume(coef_array[j]!=0);
1271  STATISTIC(n_InpNeg); 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!?
1272  ci.idx=idx_array[j];
1273  pairs[pos++]=ci;
1274  }
1275 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
number_type coef
static number npNegM(number a, const coeffs r)
Definition: modulop.h:166
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

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

1235 {
1236  int j;
1237 
1238  for(j=0;j<rlen;j++)
1239  {
1240  if (coef_array[j]!=0)
1241  {
1242  assume(coef_array[j]!=0);
1244  STATISTIC(n_InpNeg); 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!?
1245  assume(ci.coef!=0);
1246  ci.idx=j;
1247  pairs[pos++]=ci;
1248  }
1249  }
1250 }
#define STATISTIC(f)
Definition: numstats.h:16
int j
Definition: facHensel.cc:105
number_type coef
static number npNegM(number a, const coeffs r)
Definition: modulop.h:166
#define assume(x)
Definition: mod2.h:390
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424

◆ write_poly_to_row()

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

Definition at line 1460 of file tgb_internal.h.

1460  {
1461  //poly* base=row;
1462  while(h!=NULL){
1463  //Print("h:%i\n",h);
1464  number coef=p_GetCoeff(h,r);
1465  poly* ptr_to_h=(poly*) bsearch(&h,terms,tn,sizeof(poly),terms_sort_crit);
1466  assume(ptr_to_h!=NULL);
1467  int pos=ptr_to_h-terms;
1468  row[pos]=F4mat_to_number_type(coef);
1469  //number_type_array[base+pos]=coef;
1470  pIter(h);
1471  }
1472 }
int terms_sort_crit(const void *a, const void *b)
Definition: tgb.cc:2030
#define pIter(p)
Definition: monomials.h:44
#define assume(x)
Definition: mod2.h:390
#define NULL
Definition: omList.c:10
#define p_GetCoeff(p, r)
Definition: monomials.h:57
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:424
static Poly * h
Definition: janet.cc:972