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 HANS_IDEA
 
#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)
 
#define LIKELY(expression)   (expression)
 
#define UNLIKELY(expression)   (expression)
 

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, 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 temp_size, SparseRow< number_type > *row, number coef)
 
template<class number_type >
void add_coef_times_dense (number_type *const temp_array, int temp_size, const number_type *row, int len, number coef)
 
template<class number_type >
void add_dense (number_type *const temp_array, int temp_size, const number_type *row, int len)
 
template<class number_type >
void sub_dense (number_type *const temp_array, int temp_size, const number_type *row, int len)
 
template<class number_type >
void add_sparse (number_type *const temp_array, int temp_size, SparseRow< number_type > *row)
 
template<class number_type >
void sub_sparse (number_type *const temp_array, int temp_size, 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

struct sorted_pair_node

Definition at line 155 of file tgb_internal.h.

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

Definition at line 179 of file tgb_internal.h.

Data Fields
poly_list_node * next
poly p
struct int_pair_node

Definition at line 185 of file tgb_internal.h.

Data Fields
int a
int b
int_pair_node * next
struct monom_poly

Definition at line 191 of file tgb_internal.h.

Data Fields
poly f
poly m
struct mp_array_list

Definition at line 196 of file tgb_internal.h.

Data Fields
monom_poly * mp
mp_array_list * next
int size
struct poly_array_list

Definition at line 204 of file tgb_internal.h.

Data Fields
poly_array_list * next
poly * p
int size
struct find_erg

Definition at line 383 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
class TermNoroDataNode

template<class number_type>
class TermNoroDataNode< number_type >

Definition at line 580 of file tgb_internal.h.

Data Fields
DataNoroCacheNode< number_type > * node
poly t

Macro Definition Documentation

#define AC_FLATTEN   1

Definition at line 24 of file tgb_internal.h.

#define AC_NEW_MIN   2

Definition at line 23 of file tgb_internal.h.

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

Definition at line 425 of file tgb_internal.h.

#define FULLREDUCTIONS

Definition at line 15 of file tgb_internal.h.

#define HANS_IDEA

Definition at line 16 of file tgb_internal.h.

#define LIKELY (   expression)    (expression)

Definition at line 837 of file tgb_internal.h.

#define NORO_CACHE   1

Definition at line 30 of file tgb_internal.h.

#define NORO_NON_POLY   1

Definition at line 32 of file tgb_internal.h.

#define NORO_SPARSE_ROWS_PRE   1

Definition at line 31 of file tgb_internal.h.

#define npInit   n_Init

Definition at line 73 of file tgb_internal.h.

#define npInvers   n_Invers

Definition at line 75 of file tgb_internal.h.

#define npIsOne   n_IsOne

Definition at line 77 of file tgb_internal.h.

#define npIsZero   n_IsZero

Definition at line 78 of file tgb_internal.h.

#define npMult   n_Mult

Definition at line 76 of file tgb_internal.h.

#define npNeg   n_InpNeg

Definition at line 74 of file tgb_internal.h.

#define PAR_N   100

Definition at line 21 of file tgb_internal.h.

#define PAR_N_F4   5000

Definition at line 22 of file tgb_internal.h.

#define REDTAIL_S

Definition at line 20 of file tgb_internal.h.

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

Definition at line 424 of file tgb_internal.h.

#define UNLIKELY (   expression)    (expression)

Definition at line 838 of file tgb_internal.h.

#define USE_NORO   1

Definition at line 10 of file tgb_internal.h.

Typedef Documentation

typedef unsigned short tgb_uint16

Definition at line 426 of file tgb_internal.h.

typedef unsigned int tgb_uint32

Definition at line 428 of file tgb_internal.h.

typedef unsigned char tgb_uint8

Definition at line 427 of file tgb_internal.h.

Enumeration Type Documentation

enum calc_state
Enumerator
UNCALCULATED 
HASTREP 

Definition at line 322 of file tgb_internal.h.

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

Function Documentation

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

Definition at line 955 of file tgb_internal.h.

958 {
959  int j;
960  const number_type* const coef_array=row;
961  //int* const idx_array=row->idx_array;
962  //const int len=temp_size;
963  tgb_uint32 buffer[256];
964  const tgb_uint32 prime=n_GetChar(currRing->cf);
965  const tgb_uint32 c=F4mat_to_number_type(coef);
966  assume(!(npIsZero(coef,currRing->cf)));
967  for(j=0;j<len;j=j+256)
968  {
969  const int bound=std::min(j+256,len);
970  int i;
971  int bpos=0;
972  for(i=j;i<bound;i++)
973  {
974  buffer[bpos++]=coef_array[i];
975  }
976  int bpos_bound=bound-j;
977  for(i=0;i<bpos_bound;i++)
978  {
979  buffer[i]*=c;
980  }
981  for(i=0;i<bpos_bound;i++)
982  {
983  buffer[i]=buffer[i]%prime;
984  }
985  bpos=0;
986  for(i=j;i<bound;i++)
987  {
988  //int idx=idx_array[i];
989  assume(bpos<256);
990  //assume(!(npIsZero((number) buffer[bpos])));
991  STATISTIC(n_Add); temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) buffer[bpos++],currRing->cf));
992  assume(i<temp_size);
993  }
994 
995  }
996 }
#define STATISTIC(f)
Definition: numstats.h:16
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:444
unsigned int tgb_uint32
Definition: tgb_internal.h:428
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define npIsZero
Definition: tgb_internal.h:78
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:77
int i
Definition: cfEzgcd.cc:123
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
template<class number_type >
void add_coef_times_sparse ( number_type *const  temp_array,
int  temp_size,
SparseRow< number_type > *  row,
number  coef 
)

Definition at line 909 of file tgb_internal.h.

912 {
913  int j;
914  number_type* const coef_array=row->coef_array;
915  int* const idx_array=row->idx_array;
916  const int len=row->len;
917  tgb_uint32 buffer[256];
918  const tgb_uint32 prime=n_GetChar(currRing->cf);
919  const tgb_uint32 c=F4mat_to_number_type(coef);
920  assume(!(npIsZero(coef,currRing->cf)));
921  for(j=0;j<len;j=j+256)
922  {
923  const int bound=std::min(j+256,len);
924  int i;
925  int bpos=0;
926  for(i=j;i<bound;i++)
927  {
928  buffer[bpos++]=coef_array[i];
929  }
930  int bpos_bound=bound-j;
931  for(i=0;i<bpos_bound;i++)
932  {
933  buffer[i]*=c;
934  }
935  for(i=0;i<bpos_bound;i++)
936  {
937  buffer[i]=buffer[i]%prime;
938  }
939  bpos=0;
940  for(i=j;i<bound;i++)
941  {
942  int idx=idx_array[i];
943  assume(bpos<256);
944  assume(!(npIsZero((number)(long) buffer[bpos],currRing->cf)));
945  STATISTIC(n_Add); temp_array[idx]=F4mat_to_number_type(npAddM((number)(long) temp_array[idx], (number)(long) buffer[bpos++],currRing->cf));
946  assume(idx<temp_size);
947  }
948 
949  }
950 }
#define STATISTIC(f)
Definition: numstats.h:16
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:514
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
unsigned int tgb_uint32
Definition: tgb_internal.h:428
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define npIsZero
Definition: tgb_internal.h:78
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:77
int i
Definition: cfEzgcd.cc:123
number_type * coef_array
Definition: tgb_internal.h:515
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
template<class number_type >
void add_dense ( number_type *const  temp_array,
int  temp_size,
const number_type *  row,
int  len 
)

Definition at line 1001 of file tgb_internal.h.

1004 {
1005  //int j;
1006  //const number_type* const coef_array=row;
1007  //int* const idx_array=row->idx_array;
1008  //const int len=temp_size;
1009  //tgb_uint32 buffer[256];
1010  //const tgb_uint32 prime=npPrimeM;
1011  //const tgb_uint32 c=F4mat_to_number_type(coef);
1012 
1013  int i;
1014  for(i=0;i<len;i++)
1015  {
1016  STATISTIC(n_Add); temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
1017  assume(i<temp_size);
1018  }
1019 
1020 }
#define STATISTIC(f)
Definition: numstats.h:16
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:77
int i
Definition: cfEzgcd.cc:123
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
template<class number_type >
void add_sparse ( number_type *const  temp_array,
int  temp_size,
SparseRow< number_type > *  row 
)

Definition at line 1050 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  assume(idx<temp_size);
1063  }
1064 }
#define STATISTIC(f)
Definition: numstats.h:16
int * idx_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:12
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:77
number_type * coef_array
Definition: tgb_internal.h:515
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
sorted_pair_node** add_to_basis_ideal_quotient ( poly  h,
slimgb_alg c,
int ip 
)

Definition at line 1428 of file tgb.cc.

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

Definition at line 3925 of file tgb.cc.

3926 {
3927  while((c->pair_top >= 0) && (c->apairs[c->pair_top]->i >= 0)
3928  &&
3929  (!state_is
3930  (UNCALCULATED, c->apairs[c->pair_top]->j, c->apairs[c->pair_top]->i,
3931  c)))
3932  {
3933  free_sorted_pair_node (c->apairs[c->pair_top], c->r);
3934  c->pair_top--;
3935  }
3936 }
sorted_pair_node ** apairs
Definition: tgb_internal.h:241
void free_sorted_pair_node(sorted_pair_node *s, ring r)
Definition: tgb.cc:3958
static BOOLEAN state_is(calc_state state, const int &i, const int &j, slimgb_alg *c)
Definition: tgb.cc:3939
template<class number_type >
SparseRow<number_type>* convert_to_sparse_row ( number_type *  temp_array,
int  temp_size,
int  non_zeros 
)

Definition at line 841 of file tgb_internal.h.

841  {
843 //int pos=0;
844 //Print("denseness:%f\n",((double) non_zeros/(double) temp_size));
845 number_type* it_coef=res->coef_array;
846 int* it_idx=res->idx_array;
847 #if 0
848 for(i=0;i<cache->nIrreducibleMonomials;i++){
849  if (!(0==temp_array[i])){
850 
851  res->idx_array[pos]=i;
852  res->coef_array[pos]=temp_array[i];
853 
854  pos++;
855  non_zeros--;
856  if (non_zeros==0) break;
857  }
858 
859 }
860 #else
861 int64* start=(int64*) ((void*)temp_array);
862 int64* end;
863 const int multiple=sizeof(int64)/sizeof(number_type);
864 if (temp_size==0) end=start;
865 
866 else
867 {
868  int temp_size_rounded=temp_size+(multiple-(temp_size%multiple));
869  assume(temp_size_rounded>=temp_size);
870  assume(temp_size_rounded%multiple==0);
871  assume(temp_size_rounded<temp_size+multiple);
872  number_type* nt_end=temp_array+temp_size_rounded;
873  end=(int64*)((void*)nt_end);
874 }
875 int64* it=start;
876 while(it!=end)
877 {
878  if UNLIKELY((*it)!=0)
879  {
880  int small_i;
881  const int temp_index=((number_type*)((void*) it))-temp_array;
882  const int bound=temp_index+multiple;
883  number_type c;
884  for(small_i=temp_index;small_i<bound;small_i++)
885  {
886  if((c=temp_array[small_i])!=0)
887  {
888  //res->idx_array[pos]=small_i;
889  //res->coef_array[pos]=temp_array[small_i];
890  (*(it_idx++))=small_i;
891  (*(it_coef++))=c;
892  //pos++;
893  non_zeros--;
894 
895  }
896  if UNLIKELY(non_zeros==0) break;
897  }
898 
899  }
900  ++it;
901 }
902 #endif
903 return res;
904 }
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
int * idx_array
Definition: tgb_internal.h:514
long int64
Definition: auxiliary.h:112
#define UNLIKELY(expression)
Definition: tgb_internal.h:838
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
number_type * coef_array
Definition: tgb_internal.h:515
ideal do_t_rep_gb ( ring  r,
ideal  arg_I,
int  syz_comp,
BOOLEAN  F4_mode,
int  deg_pos 
)

Definition at line 3609 of file tgb.cc.

3610 {
3611  // 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)));
3612 
3613  if(TEST_OPT_PROT)
3614  if(F4_mode)
3615  PrintS ("F4 Modus \n");
3616 
3617  //debug_Ideal=arg_debug_Ideal;
3618  //if (debug_Ideal) PrintS("DebugIdeal received\n");
3619  // Print("Idelems %i \n----------\n",IDELEMS(arg_I));
3620  ideal I = arg_I;
3621  id_Compactify (I,currRing);
3622  if(idIs0 (I))
3623  return I;
3624  int i;
3625  for(i = 0; i < IDELEMS (I); i++)
3626  {
3627  assume (I->m[i] != NULL);
3628  simplify_poly (I->m[i], currRing);
3629  }
3630 
3631  qsort (I->m, IDELEMS (I), sizeof (poly), poly_crit);
3632  //Print("Idelems %i \n----------\n",IDELEMS(I));
3633  //slimgb_alg* c=(slimgb_alg*) omalloc(sizeof(slimgb_alg));
3634  //int syz_comp=arg_I->rank;
3635  slimgb_alg *c = new slimgb_alg (I, syz_comp, F4_mode, deg_pos);
3636 
3637  while((c->pair_top >= 0)
3638  && ((!(TEST_OPT_DEGBOUND))
3639  || (c->apairs[c->pair_top]->deg <= Kstd1_deg)))
3640  {
3641 #ifdef HAVE_F4
3642  if(F4_mode)
3643  go_on_F4 (c);
3644  else
3645 #endif
3646  go_on (c);
3647  }
3648  if(c->pair_top < 0)
3649  c->completed = TRUE;
3650  I = c->S;
3651  delete c;
3652  if(TEST_OPT_REDSB)
3653  {
3654  ideal erg = kInterRed (I, NULL);
3655  assume (I != erg);
3656  id_Delete (&I, currRing);
3657  return erg;
3658  }
3659  //qsort(I->m, IDELEMS(I),sizeof(poly),pLmCmp_func);
3660  assume (I->rank >= id_RankFreeModule (I,currRing));
3661  return (I);
3662 }
#define TEST_OPT_DEGBOUND
Definition: options.h:108
sorted_pair_node ** apairs
Definition: tgb_internal.h:241
#define TEST_OPT_PROT
Definition: options.h:98
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
#define TRUE
Definition: auxiliary.h:144
#define TEST_OPT_REDSB
Definition: options.h:99
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
static void go_on(slimgb_alg *c)
Definition: tgb.cc:2716
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3059
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
#define IDELEMS(i)
Definition: simpleideals.h:19
static int poly_crit(const void *ap1, const void *ap2)
Definition: tgb.cc:3124
#define NULL
Definition: omList.c:10
BOOLEAN completed
Definition: tgb_internal.h:277
static void simplify_poly(poly p, ring r)
Definition: tgb.cc:59
int Kstd1_deg
Definition: kutil.cc:228
BOOLEAN idIs0(ideal h)
void id_Compactify(ideal id, const ring r)
void free_sorted_pair_node ( sorted_pair_node s,
ring  r 
)

Definition at line 3958 of file tgb.cc.

3959 {
3960  if(s->i >= 0)
3961  p_Delete (&s->lcm_of_lm, r);
3962  omfree (s);
3963 }
const ring r
Definition: syzextra.cc:208
#define omfree(addr)
Definition: omAllocDecl.h:237
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
int kFindDivisibleByInS_easy ( kStrategy  strat,
const red_object obj 
)

Definition at line 685 of file tgb.cc.

686 {
687  int i;
688  long not_sev = ~obj.sev;
689  poly p = obj.p;
690  for(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 }
return P p
Definition: myNF.cc:203
polyrec * poly
Definition: hilb.h:10
#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:134
int i
Definition: cfEzgcd.cc:123
polyset S
Definition: kutil.h:304
unsigned long * sevS
Definition: kutil.h:320
int sl
Definition: kutil.h:351
unsigned long sev
Definition: tgb_internal.h:311
int kFindDivisibleByInS_easy ( kStrategy  strat,
poly  p,
long  sev 
)

Definition at line 698 of file tgb.cc.

699 {
700  int i;
701  long not_sev = ~sev;
702  for(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 }
return P p
Definition: myNF.cc:203
#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:134
int i
Definition: cfEzgcd.cc:123
polyset S
Definition: kutil.h:304
unsigned long * sevS
Definition: kutil.h:320
int sl
Definition: kutil.h:351
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
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 755 of file tgb_internal.h.

756 {
757  MonRedResNP<number_type> res_holder;
758 
759 
761  if (ref!=NULL)
762  {
763  res_holder.coef=p_GetCoeff(t,c->r);
764 
765  res_holder.ref=ref;
766  p_Delete(&t,c->r);
767  return res_holder;
768  }
769 
770  unsigned long sev=p_GetShortExpVector(t,currRing);
771  int i=kFindDivisibleByInS_easy(c->strat,t,sev);
772  if (i>=0)
773  {
774  number coef_bak=p_GetCoeff(t,c->r);
775 
776  p_SetCoeff(t,npInit(1,c->r->cf),c->r);
777  assume(npIsOne(p_GetCoeff(c->strat->S[i],c->r),c->r->cf));
778  number coefstrat=p_GetCoeff(c->strat->S[i],c->r);
779 
780 
781  poly exp_diff=cache->temp_term;
782  p_ExpVectorDiff(exp_diff,t,c->strat->S[i],c->r);
783  p_SetCoeff(exp_diff,npNeg(npInvers(coefstrat,c->r->cf),c->r->cf),c->r);
784  p_Setm(exp_diff,c->r);
785  assume(c->strat->S[i]!=NULL);
786 
787  poly res;
788  res=pp_Mult_mm(pNext(c->strat->S[i]),exp_diff,c->r);
789 
790  int len=c->strat->lenS[i]-1;
792  srow=noro_red_to_non_poly_t<number_type>(res,len,cache,c);
793  ref=cache->insert(t,srow);
794  p_Delete(&t,c->r);
795 
796 
797  res_holder.coef=coef_bak;
798  res_holder.ref=ref;
799  return res_holder;
800 
801  } else {
802  number coef_bak=p_GetCoeff(t,c->r);
803  number one=npInit(1, c->r->cf);
804  p_SetCoeff(t,one,c->r);
805 
806  res_holder.ref=cache->insertAndTransferOwnerShip(t,c->r);
807  assume(res_holder.ref!=NULL);
808  res_holder.coef=coef_bak;
809 
810  return res_holder;
811 
812  }
813 
814 }
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:962
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define npInvers
Definition: tgb_internal.h:75
int kFindDivisibleByInS_easy(kStrategy strat, const red_object &obj)
Definition: tgb.cc:685
unsigned long p_GetShortExpVector(poly p, const ring r)
Definition: p_polys.cc:4556
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
DataNoroCacheNode< number_type > * getCacheReference(poly term)
kStrategy strat
Definition: tgb_internal.h:232
int i
Definition: cfEzgcd.cc:123
polyset S
Definition: kutil.h:304
intset lenS
Definition: kutil.h:317
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition: p_polys.h:1402
poly temp_term
Definition: tgb_internal.h:590
#define NULL
Definition: omList.c:10
#define npInit
Definition: tgb_internal.h:73
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
#define p_GetCoeff(p, r)
Definition: monomials.h:57
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:149
#define npNeg
Definition: tgb_internal.h:74
#define npIsOne
Definition: tgb_internal.h:77
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 1083 of file tgb_internal.h.

1084 {
1085  size_t temp_size_bytes=cache->nIrreducibleMonomials*sizeof(number_type)+8;//use 8bit int for testing
1086  assume(sizeof(int64)==8);
1087  cache->ensureTempBufferSize(temp_size_bytes);
1088  number_type* temp_array=(number_type*) cache->tempBuffer;//omalloc(cache->nIrreducibleMonomials*sizeof(number_type));
1089  int temp_size=cache->nIrreducibleMonomials;
1090  memset(temp_array,0,temp_size_bytes);
1091  number minus_one=npInit(-1,currRing->cf);
1092  int i;
1093  for(i=0;i<len;i++)
1094  {
1095  MonRedResNP<number_type> red=mon[i];
1096  if ( /*(*/ red.ref /*)*/ )
1097  {
1098  if (red.ref->row)
1099  {
1100  SparseRow<number_type>* row=red.ref->row;
1101  number coef=red.coef;
1102  if (row->idx_array)
1103  {
1104  if (!((coef==(number)(long) 1)||(coef==minus_one)))
1105  {
1106  add_coef_times_sparse(temp_array,temp_size,row,coef);
1107  }
1108  else
1109  {
1110  if (coef==(number)(long) 1)
1111  {
1112  add_sparse(temp_array,temp_size,row);
1113  }
1114  else
1115  {
1116  sub_sparse(temp_array,temp_size,row);
1117  }
1118  }
1119  }
1120  else
1121  //TODO: treat, 1,-1
1122  if (!((coef==(number)(long) 1)||(coef==minus_one)))
1123  {
1124  add_coef_times_dense(temp_array,temp_size,row->coef_array,row->len,coef);
1125  }
1126  else
1127  {
1128  if (coef==(number)(long)1)
1129  add_dense(temp_array,temp_size,row->coef_array,row->len);
1130  else
1131  {
1132  assume(coef==minus_one);
1133  sub_dense(temp_array,temp_size,row->coef_array,row->len);
1134  //add_coef_times_dense(temp_array,temp_size,row->coef_array,row->len,coef);
1135  }
1136  }
1137  }
1138  else
1139  {
1140  if (red.ref->value_len==NoroCache<number_type>::backLinkCode)
1141  {
1142  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));
1143  }
1144  else
1145  {
1146  //PrintS("third case\n");
1147  }
1148  }
1149  }
1150  }
1151  int non_zeros=0;
1152  for(i=0;i<cache->nIrreducibleMonomials;i++)
1153  {
1154  //if (!(temp_array[i]==0)){
1155  // non_zeros++;
1156  //}
1157  assume(((temp_array[i]!=0)==0)|| (((temp_array[i]!=0)==1)));
1158  non_zeros+=(temp_array[i]!=0);
1159  }
1160 
1161  if (non_zeros==0)
1162  {
1163  //omfree(mon);
1164  return NULL;
1165  }
1166  SparseRow<number_type>* res=new SparseRow<number_type>(temp_size,temp_array);//convert_to_sparse_row(temp_array,temp_size, non_zeros);
1167 
1168  //omfree(temp_array);
1169 
1170 
1171  return res;
1172 }
#define STATISTIC(f)
Definition: numstats.h:16
void add_sparse(number_type *const temp_array, int temp_size, SparseRow< number_type > *row)
int * idx_array
Definition: tgb_internal.h:514
long int64
Definition: auxiliary.h:112
void add_coef_times_sparse(number_type *const temp_array, int temp_size, SparseRow< number_type > *row, number coef)
Definition: tgb_internal.h:909
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
void * tempBuffer
Definition: tgb_internal.h:705
void add_dense(number_type *const temp_array, int temp_size, const number_type *row, int len)
void ensureTempBufferSize(size_t size)
Definition: tgb_internal.h:667
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:653
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:77
int i
Definition: cfEzgcd.cc:123
number_type * coef_array
Definition: tgb_internal.h:515
void sub_sparse(number_type *const temp_array, int temp_size, SparseRow< number_type > *row)
void add_coef_times_dense(number_type *const temp_array, int temp_size, const number_type *row, int len, number coef)
Definition: tgb_internal.h:955
#define NULL
Definition: omList.c:10
#define npInit
Definition: tgb_internal.h:73
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
int nIrreducibleMonomials
Definition: tgb_internal.h:703
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:149
void sub_dense(number_type *const temp_array, int temp_size, const number_type *row, int len)
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 1272 of file tgb_internal.h.

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

Definition at line 1400 of file tgb_internal.h.

1400  {
1401  assume(len==pLength(p));
1402  if (p==NULL)
1403  {
1404  len=0;
1405  return NULL;
1406  }
1407 
1409  int i=0;
1410  double max_density=0.0;
1411  while(p!=NULL)
1412  {
1413  poly t=p;
1414  pIter(p);
1415  pNext(t)=NULL;
1416 
1418  if ((red.ref) && (red.ref->row))
1419  {
1420  double act_density=(double) red.ref->row->len;
1421  act_density/=(double) cache->nIrreducibleMonomials;
1422  max_density=std::max(act_density,max_density);
1423  }
1424  mon[i]=red;
1425  i++;
1426  }
1427 
1428  assume(i==len);
1429  len=i;
1430  bool dense=true;
1431  if (max_density<0.3) dense=false;
1432  if (dense){
1434  omfree(mon);
1435  return res;
1436  } else {
1438  omfree(mon);
1439  return res;
1440  }
1441  //in the loop before nIrreducibleMonomials increases, so position here is important
1442 
1443 }
return P p
Definition: myNF.cc:203
static int pLength(poly a)
Definition: p_polys.h:189
#define pIter(p)
Definition: monomials.h:44
poly res
Definition: myNF.cc:322
static int max(int a, int b)
Definition: fast_mult.cc:264
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
#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:755
int i
Definition: cfEzgcd.cc:123
SparseRow< number_type > * noro_red_to_non_poly_dense(MonRedResNP< number_type > *mon, int len, NoroCache< number_type > *cache)
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:703
DataNoroCacheNode< number_type > * ref
Definition: tgb_internal.h:149
template<class number_type >
void noro_step ( poly p,
int pn,
slimgb_alg c 
)

Definition at line 1779 of file tgb_internal.h.

1779  {
1780  //Print("Input rows %d\n",pn);
1781  int j;
1782  if (TEST_OPT_PROT)
1783  {
1784  Print("Input rows %d\n",pn);
1785  }
1786 
1787  NoroCache<number_type> cache;
1788 
1790  int non_zeros=0;
1791  for(j=0;j<pn;j++)
1792  {
1793  poly h=p[j];
1794  int h_len=pLength(h);
1795  //number coef;
1796  srows[non_zeros]=noro_red_to_non_poly_t<number_type>(h,h_len,&cache,c);
1797  if (srows[non_zeros]!=NULL) non_zeros++;
1798  }
1799  std::vector<DataNoroCacheNode<number_type>*> irr_nodes;
1800  cache.collectIrreducibleMonomials(irr_nodes);
1801  //now can build up terms array
1802  //Print("historic irred Mon%d\n",cache.nIrreducibleMonomials);
1803  int n=irr_nodes.size();//cache.countIrreducibleMonomials();
1804  cache.nIrreducibleMonomials=n;
1805  if (TEST_OPT_PROT)
1806  {
1807  Print("Irred Mon:%d\n",n);
1808  Print("red Mon:%d\n",cache.nReducibleMonomials);
1809  }
1811 
1812  for(j=0;j<n;j++)
1813  {
1814  assume(irr_nodes[j]!=NULL);
1815  assume(irr_nodes[j]->value_len==NoroCache<number_type>::backLinkCode);
1816  term_nodes[j].t=irr_nodes[j]->value_poly;
1817  assume(term_nodes[j].t!=NULL);
1818  term_nodes[j].node=irr_nodes[j];
1819  }
1820 
1821  qsort(term_nodes,n,sizeof(TermNoroDataNode<number_type>),term_nodes_sort_crit<number_type>);
1822  poly* terms=(poly*) omalloc(n*sizeof(poly));
1823 
1824  int* old_to_new_indices=(int*) omalloc(cache.nIrreducibleMonomials*sizeof(int));
1825  for(j=0;j<n;j++)
1826  {
1827  old_to_new_indices[term_nodes[j].node->term_index]=j;
1828  term_nodes[j].node->term_index=j;
1829  terms[j]=term_nodes[j].t;
1830  }
1831 
1832  //if (TEST_OPT_PROT)
1833  // Print("Evaluate Rows \n");
1834  pn=non_zeros;
1835  number_type* number_array=(number_type*) omalloc0(n*pn*sizeof(number_type));
1836 
1837  for(j=0;j<pn;j++)
1838  {
1839  int i;
1840  number_type* row=number_array+n*j;
1841  /*for(i=0;i<n;i++)
1842  {
1843  row[i]=zero;
1844  }*/
1845 
1846  SparseRow<number_type>* srow=srows[j];
1847 
1848  if (srow)
1849  {
1850  int* const idx_array=srow->idx_array;
1851  number_type* const coef_array=srow->coef_array;
1852  const int len=srow->len;
1853  if (srow->idx_array)
1854  {
1855  for(i=0;i<len;i++)
1856  {
1857  int idx=old_to_new_indices[idx_array[i]];
1858  row[idx]=F4mat_to_number_type(coef_array[i]);
1859  }
1860  }
1861  else
1862  {
1863  for(i=0;i<len;i++)
1864  {
1865  row[old_to_new_indices[i]]=F4mat_to_number_type(coef_array[i]);
1866  }
1867  }
1868  delete srow;
1869  }
1870  }
1871 
1872  //static int export_n=0;
1873  //export_mat(number_array,pn,n,"mat%i.py",++export_n);
1874  simplest_gauss_modp(number_array,pn,n);
1875 
1876  int p_pos=0;
1877  for(j=0;j<pn;j++){
1878  poly h=row_to_poly(number_array+j*n,terms,n,c->r);
1879  if(h!=NULL){
1880  p[p_pos++]=h;
1881  }
1882  }
1883  pn=p_pos;
1884  omfree(terms);
1885  omfree(term_nodes);
1886  omfree(number_array);
1887  #ifdef NORO_NON_POLY
1888  omfree(srows);
1889  omfree(old_to_new_indices);
1890  #endif
1891  //don't forget the rank
1892 
1893 }
#define Print
Definition: emacs.cc:83
void simplest_gauss_modp(number_type *a, int nrows, int ncols)
#define TEST_OPT_PROT
Definition: options.h:98
return P p
Definition: myNF.cc:203
int * idx_array
Definition: tgb_internal.h:514
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define omAlloc(size)
Definition: omAllocDecl.h:210
static int pLength(poly a)
Definition: p_polys.h:189
poly row_to_poly(number_type *row, poly *terms, int tn, ring r)
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
#define omfree(addr)
Definition: omAllocDecl.h:237
int i
Definition: cfEzgcd.cc:123
number_type * coef_array
Definition: tgb_internal.h:515
#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:583
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
static Poly * h
Definition: janet.cc:978
void now_t_rep ( const int arg_i,
const int arg_j,
slimgb_alg c 
)

Definition at line 3664 of file tgb.cc.

3665 {
3666  int i, j;
3667  if(arg_i == arg_j)
3668  {
3669  return;
3670  }
3671  if(arg_i > arg_j)
3672  {
3673  i = arg_j;
3674  j = arg_i;
3675  }
3676  else
3677  {
3678  i = arg_i;
3679  j = arg_j;
3680  }
3681  c->states[j][i] = HASTREP;
3682 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
char ** states
Definition: tgb_internal.h:221
wlen_type pELength ( poly  p,
ring  r 
)
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 394 of file tgb_internal.h.

395 {
396  //Print("POSHELER:%d",sizeof(wlen_type));
397  int length=strat->sl;
398  int i;
399  int an = 0;
400  int en= length;
401 
402  if ((len>setL[length])
403  || ((len==setL[length]) && (pLmCmp(set[length],p)== -1)))
404  return length+1;
405 
406  loop
407  {
408  if (an >= en-1)
409  {
410  if ((len<setL[an])
411  || ((len==setL[an]) && (pLmCmp(set[an],p) == 1))) return an;
412  return en;
413  }
414  i=(an+en) / 2;
415  if ((len<setL[i])
416  || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i;
417  //else if ((len>setL[i])
418  //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i;
419  else an=i;
420  }
421 
422 }
loop
Definition: myNF.cc:98
return P p
Definition: myNF.cc:203
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p
Definition: polys.h:105
int i
Definition: cfEzgcd.cc:123
int sl
Definition: kutil.h:351
sorted_pair_node* quick_pop_pair ( slimgb_alg c)

Definition at line 3904 of file tgb.cc.

3905 {
3906  if(c->pair_top < 0)
3907  return NULL;
3908  else
3909  return (c->apairs[c->pair_top--]);
3910 }
sorted_pair_node ** apairs
Definition: tgb_internal.h:241
#define NULL
Definition: omList.c:10
template<class number_type >
poly row_to_poly ( number_type *  row,
poly terms,
int  tn,
ring  r 
)

Definition at line 1466 of file tgb_internal.h.

1466  {
1467  poly h=NULL;
1468  int j;
1469  number_type zero=0;//;npInit(0);
1470  for(j=tn-1;j>=0;j--){
1471  if (!(zero==(row[j]))){
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 number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10
#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:1263
static Poly * h
Definition: janet.cc:978
template<class number_type >
void simplest_gauss_modp ( number_type *  a,
int  nrows,
int  ncols 
)

Definition at line 1757 of file tgb_internal.h.

1758 {
1759  //use memmoves for changing rows
1760  //if (TEST_OPT_PROT)
1761  // PrintS("StartGauss\n");
1763 
1764  int c=0;
1765  int r=0;
1766  while(mat.findPivot(r,c)){
1767  //int pivot=find_pivot()
1768  mat.reduceOtherRowsForward(r);
1769  r++;
1770  c++;
1771  }
1773  backmat.backwardSubstitute();
1774  //backward substitutions
1775  //if (TEST_OPT_PROT)
1776  //PrintS("StopGauss\n");
1777 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
int nrows
Definition: cf_linsys.cc:32
int int ncols
Definition: cf_linsys.cc:32
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);
86  }
87 }
static int nlQlogSize(number n, const coeffs r)
only used by slimgb (tgb.cc)
Definition: longrat.h:74
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
const ring r
Definition: syzextra.cc:208
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:452
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:446
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:569
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 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
#define omfree(addr)
Definition: omAllocDecl.h:237
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
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:123
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
template<class number_type >
void sub_dense ( number_type *const  temp_array,
int  temp_size,
const number_type *  row,
int  len 
)

Definition at line 1025 of file tgb_internal.h.

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

Definition at line 1068 of file tgb_internal.h.

1070 {
1071  int j;
1072 
1073  number_type* const coef_array=row->coef_array;
1074  int* const idx_array=row->idx_array;
1075  const int len=row->len;
1076  for(j=0;j<len;j++)
1077  {
1078  int idx=idx_array[j];
1079  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));
1080  assume(idx<temp_size);
1081  }
1082 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:666
#define STATISTIC(f)
Definition: numstats.h:16
int * idx_array
Definition: tgb_internal.h:514
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:82
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
number_type * coef_array
Definition: tgb_internal.h:515
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
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 }
const poly a
Definition: syzextra.cc:212
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p
Definition: polys.h:105
const poly b
Definition: syzextra.cc:213
int terms_sort_crit ( const void *  a,
const void *  b 
)

Definition at line 2068 of file tgb.cc.

2069 {
2070  return -pLmCmp (*((poly *) a), *((poly *) b));
2071 }
const poly a
Definition: syzextra.cc:212
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p
Definition: polys.h:105
polyrec * poly
Definition: hilb.h:10
const poly b
Definition: syzextra.cc:213
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 }
static int tgb_pair_better_gen(const void *ap, const void *bp)
Definition: tgb.cc:3993
sorted_pair_node* top_pair ( slimgb_alg c)

Definition at line 3880 of file tgb.cc.

3881 {
3882  while(c->pair_top >= 0)
3883  {
3884  super_clean_top_of_pair_list (c); //yeah, I know, it's odd that I use a different proc here
3885  if((c->is_homog) && (c->pair_top >= 0)
3886  && (c->apairs[c->pair_top]->deg >= c->lastCleanedDeg + 2))
3887  {
3888  int upper = c->apairs[c->pair_top]->deg - 1;
3889  c->cleanDegs (c->lastCleanedDeg + 1, upper);
3890  c->lastCleanedDeg = upper;
3891  }
3892  else
3893  {
3894  break;
3895  }
3896  }
3897 
3898  if(c->pair_top < 0)
3899  return NULL;
3900  else
3901  return (c->apairs[c->pair_top]);
3902 }
sorted_pair_node ** apairs
Definition: tgb_internal.h:241
void cleanDegs(int lower, int upper)
Definition: tgb.cc:3797
BOOLEAN is_homog
Definition: tgb_internal.h:278
static void super_clean_top_of_pair_list(slimgb_alg *c)
Definition: tgb.cc:3912
int lastCleanedDeg
Definition: tgb_internal.h:272
#define NULL
Definition: omList.c:10
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 1247 of file tgb_internal.h.

1248 {
1249  int j;
1250  for(j=0;j<rlen;j++)
1251  {
1252  assume(coef_array[j]!=0);
1254  ci.coef=coef_array[j];
1255  ci.idx=idx_array[j];
1256  pairs[pos++]=ci;
1257  }
1258 }
number_type coef
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
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 1212 of file tgb_internal.h.

1213 {
1214  int j;
1215 
1216  for(j=0;j<rlen;j++)
1217  {
1218  if (coef_array[j]!=0)
1219  {
1220  assume(coef_array[j]!=0);
1222  ci.coef=coef_array[j];
1223  assume(ci.coef!=0);
1224  ci.idx=j;
1225  pairs[pos++]=ci;
1226  }
1227  }
1228 }
number_type coef
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
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 1183 of file tgb_internal.h.

1184 {
1185  int j;
1186  for(j=0;j<rlen;j++)
1187  {
1188  assume(coef_array[j]!=0);
1190  STATISTIC(n_Mult); ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1191  ci.idx=idx_array[j];
1192  pairs[pos++]=ci;
1193  }
1194 }
#define STATISTIC(f)
Definition: numstats.h:16
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:49
number_type coef
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
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 1195 of file tgb_internal.h.

1196 {
1197  int j;
1198 
1199  for(j=0;j<rlen;j++)
1200  {
1201  if (coef_array[j]!=0)
1202  {
1203  assume(coef_array[j]!=0);
1205  STATISTIC(n_Mult); ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
1206  assume(ci.coef!=0);
1207  ci.idx=j;
1208  pairs[pos++]=ci;
1209  }
1210  }
1211 }
#define STATISTIC(f)
Definition: numstats.h:16
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:49
number_type coef
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
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 1260 of file tgb_internal.h.

1261 {
1262  int j;
1263  for(j=0;j<rlen;j++)
1264  {
1265  assume(coef_array[j]!=0);
1267  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!?
1268  ci.idx=idx_array[j];
1269  pairs[pos++]=ci;
1270  }
1271 }
#define STATISTIC(f)
Definition: numstats.h:16
number_type coef
static number npNegM(number a, const coeffs r)
Definition: modulop.h:111
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
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:556
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
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 1230 of file tgb_internal.h.

1231 {
1232  int j;
1233 
1234  for(j=0;j<rlen;j++)
1235  {
1236  if (coef_array[j]!=0)
1237  {
1238  assume(coef_array[j]!=0);
1240  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!?
1241  assume(ci.coef!=0);
1242  ci.idx=j;
1243  pairs[pos++]=ci;
1244  }
1245  }
1246 }
#define STATISTIC(f)
Definition: numstats.h:16
number_type coef
static number npNegM(number a, const coeffs r)
Definition: modulop.h:111
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
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:556
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:425
template<class number_type >
void write_poly_to_row ( number_type *  row,
poly  h,
poly terms,
int  tn,
ring  r 
)

Definition at line 1453 of file tgb_internal.h.

1453  {
1454  //poly* base=row;
1455  while(h!=NULL){
1456  //Print("h:%i\n",h);
1457  number coef=p_GetCoeff(h,r);
1458  poly* ptr_to_h=(poly*) bsearch(&h,terms,tn,sizeof(poly),terms_sort_crit);
1459  assume(ptr_to_h!=NULL);
1460  int pos=ptr_to_h-terms;
1461  row[pos]=F4mat_to_number_type(coef);
1462  //number_type_array[base+pos]=coef;
1463  pIter(h);
1464  }
1465 }
int terms_sort_crit(const void *a, const void *b)
Definition: tgb.cc:2068
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
#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:425
static Poly * h
Definition: janet.cc:978