34#define BUCKETS_FOR_NORO_RED 1
35#define SR_HDL(A) ((long)(A))
39#define ADD_LATER_SIZE 500
81 return nlQlogSize (n, r->cf);
85 return n_Size (n, r->cf);
93 for(
i = 1;
i <= rVar (r);
i++)
95 int e = p_GetExp (
m,
i, r);
98 p_SetExp (
m,
i, 1, r);
115 poly
copy = p_Copy (got, r);
127 p_Delete (&div_by, r);
139 return p_Init (r,
lm_bin);
153#define degbound(p) assume(pTotaldegree(p)<10)
200 number coef = pGetCoeff (
p);
203 c = nlQlogSize (coef,
currRing->cf);
230 coef = pGetCoeff (lm);
234 c = nlQlogSize (coef,
currRing->cf);
240 for(
i =
b->buckets_used;
i >= 0;
i--)
243 s +=
b->buckets_length[
i] ;
245#ifdef HAVE_COEF_BUCKETS
247 if(
b->coef[0] !=
NULL)
251 int modifier = nlQlogSize (pGetCoeff (
b->coef[0]),
currRing->cf);
256 int modifier =
nSize (pGetCoeff (
b->coef[0]));
278 number coef = pGetCoeff (
p);
281 c = nlQlogSize (coef,
currRing->cf);
303 coef = pGetCoeff (lm);
307 c = nlQlogSize (coef,
currRing->cf);
313 for(
i =
b->buckets_used;
i >= 0;
i--)
316 s +=
b->buckets_length[
i] ;
318#ifdef HAVE_COEF_BUCKETS
320 if(
b->coef[0] !=
NULL)
324 int modifier = nlQlogSize (pGetCoeff (
b->coef[0]),
currRing->cf);
329 int modifier =
nSize (pGetCoeff (
b->coef[0]));
346 int c =
nSize (pGetCoeff (
p));
381 if(p_GetExp (
p,
i, r) != 0)
409 if(p_GetExp (
p,
i, r) != 0)
434 last_block = rBlocks (r) - 3;
438 last_block = rBlocks (r) - 2;
442 return r->block0[last_block];
493 for(
i =
b->buckets_used;
i >= 0;
i--)
501 s +=
b->buckets_length[
i];
530 number coef = pGetCoeff (
p);
533 cs = nlQlogSize (coef,
currRing->cf);
575 cs = nlQlogSize (coef,
currRing->cf);
579#ifdef HAVE_COEF_BUCKETS
584 int modifier = nlQlogSize (pGetCoeff (
bucket->coef[0]),
currRing->cf);
589 int modifier =
nSize (pGetCoeff (
bucket->coef[0]));
623static int LObject_better_gen (
const void *
ap,
const void *bp)
636static int pLmCmp_func_inverted (
const void *ap1,
const void *ap2)
639 p1 = *((poly *) ap1);
640 p2 = *((poly *) ap2);
654 long not_sev = ~obj.sev;
655 for(
int i = 0;
i <= strat->
sl;
i++)
667 for(
int i = 0;
i <= strat->
sl;
i++)
711 if(
i[top] <
i[top - 1])
720 int *a = (
int *)
omalloc (qn *
sizeof (
int));
735 for(
i = 0;
i < qn;
i++)
737 lastpos =
posInPairs (
p, pn, q[
i], c, si_max (lastpos - 1, 0));
749 for(
i = qn - 1;
i >= 0;
i--)
756 memmove (
p + a[
i] + (1 +
i),
p + a[
i],
size);
766 poly p1 = c->
S->m[pos1];
767 poly p2 = c->
S->m[pos2];
776 if((gcd1 !=
NULL) && (gcd2 !=
NULL))
823 for(
i =
l + 1;
i <= u;
i++)
857 for(
int n = 0; ((n < c->
n) && (i_con[n] >= 0)); n++)
874 for(
i = 0;
i <= strat->
sl;
i++)
876 if(strat->
lenS[
i] != pLength (strat->
S[
i]))
890 P.sev = strat->
sevS[
i];
899 for(
j = 0;
j < c->
n;
j++)
901 if(c->
S->m[
j] == P.p)
920 for(
i = bucket->buckets_used;
i >= 0;
i--)
922 if(bucket->buckets[
i])
923 sum += bucket->buckets_length[
i];
947 P.FDeg = c->
r->pFDeg (P.p, c->
r);
975 for(
i = 0;
i < pos;
i++)
980 for(
i = pos + 1;
i < c->
n;
i++)
992 assume (old_pos >= new_pos);
993 poly
p = strat->
S[old_pos];
994 int ecart = strat->
ecartS[old_pos];
995 long sev = strat->
sevS[old_pos];
996 int s_2_r = strat->
S_2_R[old_pos];
997 int length = strat->
lenS[old_pos];
998 assume (length == (
int)pLength (strat->
S[old_pos]));
1001 length_w = strat->
lenSw[old_pos];
1003 for(
i = old_pos;
i > new_pos;
i--)
1005 strat->
S[
i] = strat->
S[
i - 1];
1011 for(
i = old_pos;
i > new_pos;
i--)
1014 for(
i = old_pos;
i > new_pos;
i--)
1017 strat->
S[new_pos] =
p;
1018 strat->
ecartS[new_pos] = ecart;
1019 strat->
sevS[new_pos] = sev;
1020 strat->
S_2_R[new_pos] = s_2_r;
1021 strat->
lenS[new_pos] = length;
1023 strat->
lenSw[new_pos] = length_w;
1029 assume (old_pos <= new_pos);
1030 poly
p = strat->
S[old_pos];
1031 int ecart = strat->
ecartS[old_pos];
1032 long sev = strat->
sevS[old_pos];
1033 int s_2_r = strat->
S_2_R[old_pos];
1034 int length = strat->
lenS[old_pos];
1035 assume (length == (
int)pLength (strat->
S[old_pos]));
1038 length_w = strat->
lenSw[old_pos];
1040 for(
i = old_pos;
i < new_pos;
i++)
1042 strat->
S[
i] = strat->
S[
i + 1];
1048 for(
i = old_pos;
i < new_pos;
i++)
1051 for(
i = old_pos;
i < new_pos;
i++)
1054 strat->
S[new_pos] =
p;
1055 strat->
ecartS[new_pos] = ecart;
1056 strat->
sevS[new_pos] = sev;
1057 strat->
S_2_R[new_pos] = s_2_r;
1058 strat->
lenS[new_pos] = length;
1060 strat->
lenSw[new_pos] = length_w;
1067 int *cans = (
int *)
omAlloc (c->
n * sizeof (
int));
1068 int *connected = (
int *)
omAlloc (c->
n * sizeof (
int));
1070 int cans_length = 1;
1071 connected[0] = from;
1072 int last_cans_pos = -1;
1073 int connected_length = 1;
1076 int not_yet_found = cans_length;
1077 int con_checked = 0;
1082 if((con_checked < connected_length) && (not_yet_found > 0))
1084 pos = connected[con_checked];
1085 for(
int i = 0;
i < cans_length;
i++)
1091 || ((!rIsPluralRing (c->
r))
1094 connected[connected_length] = cans[
i];
1099 if(connected[connected_length - 1] == to)
1101 if(connected_length < c->n)
1103 connected[connected_length] = -1;
1114 for(last_cans_pos++; last_cans_pos <= c->
n; last_cans_pos++)
1116 if(last_cans_pos == c->
n)
1118 if(connected_length < c->n)
1120 connected[connected_length] = -1;
1125 if((last_cans_pos == from) || (last_cans_pos == to))
1127 if(p_LmShortDivisibleBy
1128 (I->m[last_cans_pos], c->
short_Exps[last_cans_pos], bound,
1129 neg_bounds_short, c->
r))
1131 cans[cans_length] = last_cans_pos;
1137 for(
int i = 0;
i < con_checked;
i++)
1139 if(
has_t_rep (connected[
i], last_cans_pos, c))
1141 connected[connected_length] = last_cans_pos;
1143 cans[cans_length - 1] = -1;
1145 if(connected[connected_length - 1] == to)
1147 if(connected_length < c->n)
1149 connected[connected_length] = -1;
1159 if(connected_length < c->n)
1161 connected[connected_length] = -1;
1180 for(
int n = 0; ((n < c->
n) && (i_con[n] >= 0)); n++)
1186 p_Delete (&lm, c->
r);
1206 p_Delete (&lm, c->
r);
1211 sugar += si_max (t_i, t_j);
1215 for(
int m = 0; ((
m < c->
n) && (i_con[
m] >= 0));
m++)
1226 for(
int m = 0; ((
m < c->
n) && (j_con[
m] >= 0));
m++)
1280 if(
l >= strat->
lenS[*at])
1340 res *= el1 + el2 - 2;
1386 poly
copy = p_Copy (got, c->
r);
1398 p_Delete (&div_by, c->
r);
1401 p_Delete (&
copy, c->
r);
1404#define ENLARGE(pointer, type) pointer=(type*) omreallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type))
1406#define ENLARGE_ALIGN(pointer, type) {if(pointer)\
1407 pointer=(type*)omReallocSize(pointer, old*sizeof(type),c->array_lengths*sizeof(type));\
1408 else pointer=(type*)omAllocAligned(c->array_lengths*sizeof(type));}
1431#ifndef USE_STDVECBOOL
1449 ecart = sugar - c->
T_deg[
i];
1471 c->
states.push_back (dynamic_bitset <> (
i));
1474#ifdef USE_STDVECBOOL
1476 c->
states.push_back (vector < bool > (
i));
1493 for(
j = 0;
j <
i;
j++)
1500 assume (p_LmDivisibleBy (c->
S->m[
i], c->
S->m[
j], c->
r) ==
1514 else if(((!c->
nc) || (c->
is_homog && rIsSCA (c->
r)))
1560 assume (pLength (short_s) == 1);
1603 if (
i>
j) {
s->i=
i;
s->j=
j;}
1604 else {
s->i=
j;
s->j=
i;}
1618 s->deg += si_max (t_i, t_j);
1649 for(upper = lower + 1; upper < spc; upper++)
1651 if(!
pLmEqual (nodes[lower]->lcm_of_lm, nodes[upper]->lcm_of_lm))
1655 if(
has_t_rep (nodes[upper]->
i, nodes[upper]->
j, c))
1661 for(z = 0; z < spc_final; z++)
1664 (nodes_final[z]->lcm_of_lm, nodes[lower]->lcm_of_lm, c->
r))
1673 for(; lower <= upper; lower++)
1677 nodes[lower] =
NULL;
1684 p_Test (nodes[lower]->lcm_of_lm, c->
r);
1688 nodes_final[spc_final] =
1691 *(nodes_final[spc_final++]) = *(nodes[lower]);
1693 nodes[lower] =
NULL;
1694 for(lower = lower + 1; lower <= upper; lower++)
1698 nodes[lower] =
NULL;
1707 assume (spc_final <= spc);
1738 const unsigned int m_iFirstAltVar = scaFirstAltVar (c->
r);
1739 const unsigned int m_iLastAltVar = scaLastAltVar (c->
r);
1742 m_iLastAltVar - m_iFirstAltVar + 1;
1745 poly *array_arg = (poly *)
omalloc (
N *
sizeof (poly));
1749 for(
unsigned short v = m_iFirstAltVar;
v <= m_iLastAltVar;
v++)
1751 if(p_GetExp (
h,
v, c->
r))
1795 assume (len == (
int)pLength (
h));
1804 P.SetShortExpVector ();
1819 if((
j >= 0) && ((!n) ||
1820 ((strat->
lenS[
j] <= n) &&
1837 number m2 =
nMult (
m, coef);
1851 P.SetShortExpVector ();
1866 assume (len == (
int)pLength (P.p));
1881 int len = pLength (
h);
1882 for(
i = 0;
i <= strat->
sl;
i++)
1884 if((strat->
lenS[
i] > 2)
1899 for(
i = 0;
i < fixpos;
i++)
1909 for(
i = fixpos + 1;
i < c->
n;
i++)
1954 while(*node !=
NULL)
1956 int c =
pLmCmp (
p, (*node)->p);
1960 node = &((*node)->r);
1962 node = &((*node)->l);
1977 if((r2.
p != ro.
p) || (r2.
sev != ro.
sev))
1984 return -
pLmCmp (*((poly *) a), *((poly *)
b));
1988static void unify_terms (poly * terms,
int &sum)
1998 terms[++
last] = terms[curr];
2007export_mat (number *
number_array,
int pn,
int tn,
const char *format_str,
2011 snprintf (matname,20, format_str, mat_nr);
2012 FILE *out = fopen (matname,
"w");
2014 fprintf (out,
"mat=[\n");
2015 for(
i = 0;
i < pn;
i++)
2017 fprintf (out,
"[\n");
2018 for(
j = 0;
j < tn;
j++)
2022 fprintf (out,
", ");
2027 fprintf (out,
"],\n");
2029 fprintf (out,
"],\n");
2031 fprintf (out,
"]\n");
2041linalg_step_modp (poly *
p, poly * p_out,
int &pn, poly * terms,
int tn,
2048 const number_type zero = 0;
2049 int array_size = pn * tn;
2051 (number_type *)
omalloc (pn * tn *
sizeof (number_type));
2053 for(
i = 0;
i < array_size;
i++)
2057 for(
i = 0;
i < pn;
i++)
2066 export_mat (
number_array, pn, tn,
"mat%i.py", ++export_n);
2072 for(
i = 0;
i < pn;
i++)
2089 p_out[p_pos++] =
NULL;
2092 export_mat (
number_array, pn, tn,
"mat%i.py", ++export_n);
2100 int *ibuf = (
int *)
omalloc (pn *
sizeof (
int));
2103 for(
j = 0;
j < pn;
j++)
2109 for(
j = 0;
j < pn;
j++)
2116 for(
j = 0;
j < pn;
j++)
2118 memmove (big_sbuf + partsum, sbuf[
j],
2143#ifndef NORO_NON_POLY
2144void NoroCache::evaluateRows ()
2172 DataNoroCacheNode *dn = (DataNoroCacheNode *) node;
2176#ifndef NORO_SPARSE_ROWS_PRE
2178 DenseRow *row = dn->
row;
2206 row->
array = (number *)
omalloc ((len) *
sizeof (number));
2207 memcpy (row->
array, a + row->
begin, len * sizeof (number));
2211 SparseRow *row = dn->
row;
2226 PrintS (
"F4 calc wrong, as poly len was wrong\n");
2235 NoroCache::evaluatePlaceHolder (number * row,
2236 std::vector < NoroPlaceHolder >
2240 int s = place_holders.size ();
2244 for(
i = 0;
i <
s;
i++)
2246 DataNoroCacheNode *ref = place_holders[
i].ref;
2247 number coef = place_holders[
i].coef;
2254 #ifndef NORO_SPARSE_ROWS_PRE
2255 DenseRow *ref_row = ref->
row;
2258 number *ref_begin = ref_row->
array;
2259 number *ref_end = ref_row->
array + (ref_row->
end - ref_row->
begin);
2260 number *my_pos = row + ref_row->
begin;
2262 if(!(npIsOne (coef)))
2264 while(ref_begin != ref_end)
2266 *my_pos = npAddM (*my_pos, npMult (coef, *ref_begin));
2273 while(ref_begin != ref_end)
2276 *my_pos = npAddM (*my_pos, *ref_begin);
2282 SparseRow *ref_row = ref->
row;
2285 int n = ref_row->
len;
2289 if(!(npIsOne (coef)))
2291 for(
j = 0;
j < n;
j++)
2293 int idx = idx_array[
j];
2294 number ref_coef = coef_array[
j];
2295 row[idx] = npAddM (row[idx], npMult (coef, ref_coef));
2300 for(
j = 0;
j < n;
j++)
2302 int idx = idx_array[
j];
2303 number ref_coef = coef_array[
j];
2304 row[idx] = npAddM (row[idx], ref_coef);
2313 for(
i = 0;
i <
s;
i++)
2315 DataNoroCacheNode *ref = place_holders[
i].ref;
2316 number coef = place_holders[
i].coef;
2323 #ifndef NORO_SPARSE_ROWS_PRE
2324 DenseRow *ref_row = ref->
row;
2327 number *ref_begin = ref_row->
array;
2328 number *ref_end = ref_row->
array + (ref_row->
end - ref_row->
begin);
2329 number *my_pos = row + ref_row->
begin;
2331 if(!(npIsOne (coef)))
2333 while(ref_begin != ref_end)
2335 *my_pos = npAddM (*my_pos, nvMult (coef, *ref_begin));
2342 while(ref_begin != ref_end)
2344 *my_pos = npAddM (*my_pos, *ref_begin);
2350 SparseRow *ref_row = ref->
row;
2353 int n = ref_row->
len;
2357 if(!(npIsOne (coef)))
2359 for(
j = 0;
j < n;
j++)
2361 int idx = idx_array[
j];
2362 number ref_coef = coef_array[
j];
2363 row[idx] = npAddM (row[idx], nvMult (coef, ref_coef));
2368 for(
j = 0;
j < n;
j++)
2370 int idx = idx_array[
j];
2371 number ref_coef = coef_array[
j];
2372 row[idx] = npAddM (row[idx], ref_coef);
2384#ifndef NORO_NON_POLY
2388 MonRedRes res_holder;
2391 res_holder.changed =
TRUE;
2404 res_holder.ref = ref;
2405 res_holder.onlyBorrowed =
TRUE;
2406 res_holder.changed =
TRUE;
2407 p_Delete (&t, c->
r);
2414 poly cache_lookup = cache->
lookup (t, succ, res_holder.len);
2417 if(cache_lookup == t)
2422 res_holder.changed =
FALSE;
2424 res_holder.coef = npInit (1);
2426 res_holder.onlyBorrowed =
FALSE;
2431 p_Delete (&t, c->
r);
2433 res_holder.p = cache_lookup;
2435 res_holder.onlyBorrowed =
TRUE;
2447 p_SetCoeff (t, npInit (1), c->
r);
2453 p_ExpVectorDiff (exp_diff, t, c->
strat->
S[
i], c->
r);
2454 p_SetCoeff (exp_diff, npNeg (
nInvers (coefstrat)), c->
r);
2456 p_Setm (exp_diff, c->
r);
2463 res = noro_red_non_unique (
res, res_holder.len, cache, c);
2466 p_Delete (&t, c->
r);
2469 res_holder.changed =
TRUE;
2471 res_holder.coef = coef_bak;
2472 res_holder.onlyBorrowed =
TRUE;
2473 res_holder.ref = ref;
2479 number one = npInit (1);
2480 p_SetCoeff (t, one, c->
r);
2484 res_holder.ref = cache->
insert (t, t, res_holder.len);
2485 p_SetCoeff (t, coef_bak, c->
r);
2489 res_holder.changed =
FALSE;
2492 res_holder.coef = npInit (1);
2493 res_holder.onlyBorrowed =
FALSE;
2499 res_holder.coef = coef_bak;
2500 res_holder.onlyBorrowed =
TRUE;
2501 res_holder.changed =
FALSE;
2510#ifndef NORO_NON_POLY
2523 poly unchanged_head =
NULL;
2524 poly unchanged_tail =
NULL;
2525 int unchanged_size = 0;
2535 MonRedRes red = noro_red_mon (t,
FALSE, cache, c);
2536 if((!(red.changed)) && (!(red.onlyBorrowed)))
2539 assume (npIsOne (red.coef));
2543 pNext (unchanged_tail) = red.p;
2544 pIter (unchanged_tail);
2548 unchanged_tail = red.p;
2549 unchanged_head = red.p;
2554 assume (red.len == pLength (red.p));
2555 if(red.onlyBorrowed)
2557 if(npIsOne (red.coef))
2566 if(npIsOne (red.coef))
2582#ifdef NORO_SPARSE_ROWS_PRE
2605#ifndef NORO_NON_POLY
2606std::vector < NoroPlaceHolder > noro_red (poly
p,
int &len,
NoroCache * cache,
2609 std::vector < NoroPlaceHolder >
res;
2616 MonRedRes red = noro_red_mon (t,
TRUE, cache, c);
2617 assume (red.onlyBorrowed);
2623 assume (!((
h.ref->value_poly ==
NULL) && (
h.ref->value_len != 0)));
2624 if(
h.ref->value_poly)
2636 poly *reduced = (poly *)
omalloc (pn *
sizeof (poly));
2638 int *reduced_len = (
int *)
omalloc (pn *
sizeof (
int));
2645 for(
j = 0;
j < pn;
j++)
2649 int h_len = pLength (
h);
2653 h =
redNF2 (p_Copy (
h, c->
r), c, h_len, coef, 0);
2655 h = noro_red (p_Copy (
h, c->
r), h_len, &cache, c);
2656 assume (pLength (
h) == h_len);
2663 h_len = pLength (
h);
2665 reduced[reduced_c] =
h;
2666 reduced_len[reduced_c] = h_len;
2669 Print (
"%d ", h_len);
2672 int reduced_sum = 0;
2673 for(
j = 0;
j < reduced_c;
j++)
2675 reduced_sum += reduced_len[
j];
2677 poly *terms = (poly *)
omalloc (reduced_sum *
sizeof (poly));
2679 for(
j = 0;
j < reduced_c;
j++)
2681 poly
h = reduced[
j];
2687 assume (tc <= reduced_sum);
2690 assume (tc == reduced_sum);
2692 int nterms = reduced_sum;
2695 unify_terms (terms, nterms);
2698 int rank = reduced_c;
2699 linalg_step_modp (reduced,
p, rank, terms, nterms, c);
2724 for(
i = 0;
i < c->
n;
i++)
2736 poly *
p = (poly *)
omAlloc ((max_pairs + 1) *
sizeof (poly));
2739 while(
i < max_pairs)
2748 if(
s->deg > curr_deg)
2774 h = nc_CreateSpoly (c->
S->m[
s->i], c->
S->m[
s->j] , c->
r);
2802 int mlen = pLength (
h);
2804 if((!c->
nc) & (!(use_noro)))
2832#ifdef TGB_RESORT_PAIRS
2833 c->replaced =
new bool[c->
n];
2857 if(n_GetChar(
currRing->cf) < 65000)
2883 for(
j = 0;
j <
i;
j++)
2890 int len = pLength (
p[
j]);
2892 buf[
j].initial_quality =
buf[
j].guess_quality (c);
2900 Print (
"%dM[%d,", curr_deg,
i);
2904#ifdef TGB_RESORT_PAIRS
2915 if((c->replaced[c->
apairs[e]->
i]) || (c->replaced[c->
apairs[e]->
j]))
2928 for(
k = 0;
k <
i;
k++)
2932 for(k2 = 0; k2 <
i; k2++)
2948 poly *add_those = (poly *)
omalloc0 (
i *
sizeof (poly));
2950 for(
j = 0;
j <
i;
j++)
2978 add_those[num_to_add++] =
p;
2984 mass_add (add_those, num_to_add, c);
2991#ifdef TGB_RESORT_PAIRS
3028 P.SetShortExpVector ();
3053 nc_kBucketPolyRed_Z (P.bucket, strat->
S[
j], &coef,
FALSE);
3073 P.SetShortExpVector ();
3132 poly *set_this = &
p;
3137 (*set_this) =
pLmInit (monoms[monom_index - 1 -
r->
exp]);
3139 set_this = &((*set_this)->next);
3151 p1 = *((poly *) ap1);
3152 p2 = *((poly *) ap2);
3157 int l1 = pLength (p1);
3158 int l2 = pLength (p2);
3173 for(
int i = 0;
i <
s;
i++)
3209 nc = rIsPluralRing (
r);
3215 for(hzz = 0; hzz <
IDELEMS (I); hzz++)
3219 poly t = I->m[hzz]->next;
3241 if(rField_is_Zp (
r))
3286#ifdef USE_STDVECBOOL
3336 poly *array_arg = I->m;
3361 for(
i = 1;
i <
n;
i++)
3371 use_noro = ((!(
nc)) && (
S->rank <= 1) && (rField_is_Zp (
r))
3395 for(piter = 0; piter <=
pair_top; piter++)
3401 if(
s->lcm_of_lm !=
NULL)
3403 add[pos] =
s->lcm_of_lm;
3418 for(piter = 0; piter <=
pair_top; piter++)
3462#ifndef USE_STDVECBOOL
3463 for(
int z = 1 ; z < c->
n; z++)
3473 for(
int z = 0; z < c->
n; z++)
3495 for(
i = 0;
i < c->
n;
i++)
3506 Print (
"\nNF:%i product criterion:%i, ext_product criterion:%i \n",
3515 for(
j = 0;
j < c->
n;
j++)
3545 for(
i = 0;
i < c->
n;
i++)
3550 for(
j = 0;
j < c->
n;
j++)
3552 if((c->
S->m[
j] ==
NULL) || (
i ==
j))
3556 c->
r) == p_LmDivisibleBy (c->
S->m[
j],
3588 if(orig_ring != new_ring)
3605 s_h =
id_Copy (arg_I, orig_ring);
3609 ideal s_result =
do_t_rep_gb (new_ring, s_h, syz_comp, F4_mode, pos);
3611 if(orig_ring != new_ring)
3709 assume (arg_i < state->n);
3710 assume (arg_j < state->n);
3729 for(
int i = 0;
i < c->
n;
i++)
3735 poly tail = c->
S->m[
i]->next;
3736 poly prev = c->
S->m[
i];
3738 while((tail !=
NULL) && (
pLmCmp (tail, monom) >= 0))
3740 if(p_LmDivisibleBy (monom, tail, c->
r))
3742 did_something =
TRUE;
3743 prev->next = tail->next;
3745 p_Delete (&tail, c->
r);
3762 for(
int z = 0; z <= c->
strat->
sl; z++)
3771 for(
int z = new_pos - 1; z >= 0; z--)
3780 assume (new_pos <= old_pos);
3785 if(new_pos < old_pos)
3812 for(deg = lower; deg <= upper; deg++)
3815 for(
i = 0;
i <
n;
i++)
3832 int len = pLength (
h);
3859 new_pos = new_pos - 1;
3871 for(
i = 0;
i < this->n;
i++)
3873 for(
j = 0;
j <
i;
j++)
3958 return (c->
states[arg_i][arg_j] == state);
3961 return (c->
states[arg_j][arg_i] == state);
3967 p_Delete (&
s->lcm_of_lm, r);
3988 if(a->
i + a->
j <
b->i +
b->j)
3990 if(a->
i + a->
j >
b->i +
b->j)
4020 if(a->
i + a->
j <
b->i +
b->j)
4022 if(a->
i + a->
j >
b->i +
b->j)
4051 for(
i = max_g_0;
i;
i--)
4057 if((max_g_0 == 0) && (
pGetExp (
m,
i) > 0))
4111static poly kBucketGcd (
kBucket *
b, ring r)
4119 if(
b->buckets[
i] !=
NULL)
4204 los[best].
p = los[best].
bucket->buckets[b_pos];
4205 qc =
pQuality (los[best].bucket->buckets[b_pos], c);
4227 if((c->
nc) && (!(rIsSCA (c->
r))))
4235 assume (qc == los[best].guess_quality (c));
4240 los[best].
p = los[best].
bucket->buckets[b_pos];
4241 qc =
pQuality (los[best].bucket->buckets[b_pos], c);
4260 PrintS (
"Wrong wlen_type");
4266 los[best].
p = los[best].
bucket->buckets[b_pos];
4267 qc =
pQuality (los[best].bucket->buckets[b_pos], c);
4279 if(qc < quality_a / 2)
4333 while((il > 0) &&
pLmEqual (los[il - 1].
p, los[il].
p))
4355 clear_into = los[bp].
p;
4367 for(z = c->
n; z; z--)
4369 if(
p == c->
S->m[z - 1])
4380#ifdef TGB_RESORT_PAIRS
4382 c->replaced[pos_in_c] =
TRUE;
4385 c->
S->m[pos_in_c] = clear_into;
4386 c->
lengths[pos_in_c] = new_length;
4408 assume ((
int)pLength (clear_into) == new_length);
4418#ifdef FIND_DETERMINISTIC
4447 if (i2 < step) step=i2;
4459 if((!incr) && (step == 1))
4465 step = si_min (
i - i2, step);
4484 step = (step + 1) / 2;
4497 for(
i =
l;
i <= u;
i++)
4517 assume ((startf == losl - 1)
4518 || (
pLmCmp (los[startf].
p, los[startf + 1].
p) == -1));
4535 int i2 =
fwbw (los,
i);
4550 int i2 =
fwbw (los,
i);
4594 memmove (los + (
int) (
last + 1 - deleted), los + (
last + 1),
4602 if((
last >= 0) && (
last != losl - 1))
4603 memmove (los + (
int) (
last + 1 - deleted), los +
last + 1,
4635 int r_size = u -
l + 1;
4638 int *new_indices = (
int *)
omalloc ((r_size) *
sizeof (
int));
4641 for(
i =
l;
i <= u;
i++)
4645 bound = new_indices[
i -
l] =
4652 new_indices[
i -
l] =
l;
4657 for(
int i = 0;
i < r_size;
i++)
4659 new_indices[
i] +=
i;
4660 los_region[
i] = los[
l +
i];
4661 assume ((
i == 0) || (new_indices[
i] > new_indices[
i - 1]));
4669 if(new_indices[
i] ==
j)
4671 los[
j] = los_region[
i];
4691 poly *delay = (poly *)
omAlloc (losl *
sizeof (poly));
4699 for(
i = 0;
i < losl;
i++)
4703 if(los[
i].initial_quality > max_initial_quality)
4710 int curr_pos = losl - 1;
4714 while(curr_pos >= 0)
4719 int pn_noro = curr_pos + 1;
4720 poly *p_noro = (poly *)
omAlloc (pn_noro *
sizeof (poly));
4721 for(
i = 0;
i < pn_noro;
i++)
4735 if(n_GetChar(
currRing->cf) < 65000)
4744 for(
i = 0;
i < pn_noro;
i++)
4746 los[
i].
p = p_noro[
i];
4755 curr_pos -= deleted;
4781 assume (los[
i].initial_quality > 0);
4782 if(los[
i].guess_quality (c)
4788 if(los[
i].guess_quality (c) >
delay_factor * max_initial_quality)
4794 delay[delay_s] = los[
i].
p;
4809 curr_pos -= deleted;
4821#ifdef FIND_DETERMINISTIC
4825 (
i+2)*
sizeof(poly));
4922 for(
i =
l;
i <= u;
i++)
4926 for(
i =
l;
i <= u;
i++)
4961 assume (red_len == (
int)pLength (red));
4981 red_len = pLength (red);
4986 work_on_copy =
TRUE;
5017 red_len = pLength (red);
5021 assume (red_len == (
int)pLength (red));
5023 int reducer_deg = 0;
5036 reducer_deg = lm_deg + ecart;
5040 if((!work_on_copy) && (!erg.
fromS))
5156template class std::vector<DataNoroCacheNode<unsigned char>*>;
5157template class std::vector<DataNoroCacheNode<unsigned int>*>;
5158template class std::vector<DataNoroCacheNode<unsigned short>*>;
5159template class std::vector<PolySimple>;
const CanonicalForm CFMap CFMap & N
template void noro_step< tgb_uint8 >(poly *p, int &pn, slimgb_alg *c)
template void noro_step< tgb_uint32 >(poly *p, int &pn, slimgb_alg *c)
template void noro_step< tgb_uint16 >(poly *p, int &pn, slimgb_alg *c)
SparseRow< number_type > * row
NoroCacheNode ** branches
int nIrreducibleMonomials
DataNoroCacheNode< number_type > * getCacheReference(poly term)
poly lookup(poly term, BOOLEAN &succ, int &len)
DataNoroCacheNode< number_type > * insertAndTransferOwnerShip(poly t, ring)
DataNoroCacheNode< number_type > * insert(poly term, poly nf, int len)
static const int backLinkCode
poly_tree_node * top_level
wlen_type initial_quality
wlen_type guess_quality(slimgb_alg *c)
makes on each red_object in a region a single_step
virtual ~reduction_step()
virtual void reduce(red_object *r, int l, int u)
we assume that all occurring red_objects have same lm, and all occ. lm's in r[l......
KINLINE void Init(ring tailRing=currRing)
virtual void pre_reduce(red_object *r, int l, int u)
simple_reducer(poly pp, int pp_len, int pp_reducer_deg, slimgb_alg *pp_c=NULL)
virtual void reduce(red_object *r, int l, int u)
we assume that all occurring red_objects have same lm, and all occ. lm's in r[l......
virtual void do_reduce(red_object &ro)
void(*) initEcart(TObject *L)
void(*) enterS(LObject *h, int pos, kStrategy strat, int atR)
unsigned long pTotaldegree(poly p)
int_pair_node * soon_free
sorted_pair_node ** apairs
BOOLEAN use_noro_last_block
int extended_product_crit
sorted_pair_node ** tmp_spn
void introduceDelayedPairs(poly *pa, int s)
unsigned int reduction_steps
poly_array_list * F_minus
slimgb_alg(ideal I, int syz_comp, BOOLEAN F4, int deg_pos)
void cleanDegs(int lower, int upper)
int syz_comp
array_lengths should be greater equal n;
int pTotaldegree_full(poly p)
BOOLEAN eliminationProblem
wlen_type * weighted_lengths
poly_list_node * to_destroy
tgb_sparse_matrix(int i, int j, ring rarg)
friend void init_with_mac_poly(tgb_sparse_matrix *mat, int row, mac_poly m)
friend poly free_row_to_poly(tgb_sparse_matrix *mat, int row, poly *monoms, int monom_index)
void bit_reduce(poly &f, ring r)
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
CFArray copy(const CFList &list)
write elements of list into an array
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define idDelete(H)
delete an ideal
ideal id_Copy(ideal h1, const ring r)
copy an ideal
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
void kBucketDeleteAndDestroy(kBucket_pt *bucket_pt)
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
void kBucketDestroy(kBucket_pt *bucket_pt)
void kBucketInit(kBucket_pt bucket, poly lm, int length)
poly kBucketExtractLm(kBucket_pt bucket)
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
void kBucket_Add_q(kBucket_pt bucket, poly q, int *l)
Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.
const poly kBucketGetLm(kBucket_pt bucket)
void kBucketSimpleContent(kBucket_pt bucket)
int kBucketCanonicalize(kBucket_pt bucket)
Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in one bucket: Returns number of bu...
#define MAX_BUCKET
Bucket definition (should be no one elses business, though).
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
ideal kInterRed(ideal F, const ideal Q)
void enterSBba(LObject *p, int atS, kStrategy strat, int atR)
void initBuchMoraPos(kStrategy strat)
void initBuchMoraCrit(kStrategy strat)
void deleteInS(int i, kStrategy strat)
void initEcartBBA(TObject *h)
poly redNFTail(poly h, const int sl, kStrategy strat)
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
poly sca_pp_Mult_xi_pp(short i, const poly pPoly, const ring rRing)
'SR_INT' is the type of those integers small enough to fit into 29 bits.
STATIC_VAR unsigned add[]
long npInt(number &n, const coeffs r)
#define __p_GetComp(p, r)
gmp_float exp(const gmp_float &a)
#define omreallocSize(addr, o_size, size)
#define omGetSpecBin(size)
#define omUnGetSpecBin(bin_ptr)
#define TEST_OPT_INTSTRATEGY
#define TEST_V_UPTORADICAL
#define TEST_OPT_DEGBOUND
#define TEST_OPT_REDTHROUGH
#define TEST_V_MODPSOLVSB
unsigned long p_GetShortExpVector(const poly p, const ring r)
poly p_Cleardenom(poly p, const ring r)
void pEnlargeSet(poly **p, int l, int increment)
#define p_LmEqual(p1, p2, r)
#define __pp_Mult_nn(p, n, r)
#define __p_Mult_nn(p, n, r)
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pHasNotCF(p1, p2)
#define pExpVectorDiff(pr, p1, p2)
#define pGetComp(p)
Component.
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
#define pExpVectorSub(p1, p2)
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
#define pGetExp(p, i)
Exponent.
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
#define pCopy(p)
return a copy of the poly
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
void PrintS(const char *s)
ring rAssure_TDeg(ring r, int &pos)
BOOLEAN rRing_has_CompLastBlock(const ring r)
void rDelete(ring r)
unconditionally deletes fields in r
int status int void * buf
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Compactify(ideal id, const ring r)
static int fwbw(red_object *los, int i)
BOOLEAN is_valid_ro(red_object &ro)
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
static void shorten_tails(slimgb_alg *c, poly monom)
static void go_on(slimgb_alg *c)
static poly gcd_of_terms(poly p, ring r)
BOOLEAN good_has_t_rep(int i, int j, slimgb_alg *c)
int tgb_pair_better_gen2(const void *ap, const void *bp)
static const int bundle_size
static int tgb_pair_better_gen(const void *ap, const void *bp)
static int pELength(poly p, slimgb_alg *c, int l)
sorted_pair_node ** spn_merge(sorted_pair_node **p, int pn, sorted_pair_node **q, int qn, slimgb_alg *c)
static wlen_type pair_weighted_length(int i, int j, slimgb_alg *c)
static void move_forward_in_S(int old_pos, int new_pos, kStrategy strat)
void now_t_rep(const int &arg_i, const int &arg_j, slimgb_alg *c)
void clean_top_of_pair_list(slimgb_alg *c)
#define ENLARGE(pointer, type)
static void mass_add(poly *p, int pn, slimgb_alg *c)
static int get_last_dp_block_start(ring r)
static wlen_type coeff_mult_size_estimate(int s1, int s2, ring r)
int find_best(red_object *r, int l, int u, wlen_type &w, slimgb_alg *c)
returns position sets w as weight
static BOOLEAN monomial_root(poly m, ring r)
int search_red_object_pos(red_object *a, int top, red_object *key)
static int multi_reduction_clear_zeroes(red_object *los, int losl, int l, int u, int syzComp)
static int * make_connections(int from, int to, poly bound, slimgb_alg *c)
sorted_pair_node ** add_to_basis_ideal_quotient(poly h, slimgb_alg *c, int *ip)
static BOOLEAN pair_better(sorted_pair_node *a, sorted_pair_node *b, slimgb_alg *c=NULL)
static poly p_Init_Special(const ring r)
#define ENLARGE_ALIGN(pointer, type)
static void sort_region_down(red_object *los, int l, int u, slimgb_alg *)
int slim_nsize(number n, ring r)
static wlen_type pSLength(poly p, int l)
static BOOLEAN lies_in_last_dp_block(poly p, slimgb_alg *c)
sorted_pair_node * quick_pop_pair(slimgb_alg *c)
wlen_type kEBucketLength(kBucket *b, poly lm, slimgb_alg *ca)
static int posInPairs(sorted_pair_node **p, int pn, sorted_pair_node *qe, slimgb_alg *c, int an=0)
static const int delay_factor
int kFindDivisibleByInS_easy(kStrategy strat, const red_object &obj)
static int poly_crit(const void *ap1, const void *ap2)
static int simple_posInS(kStrategy strat, poly p, int len, wlen_type wlen)
static wlen_type quality_of_pos_in_strat_S(int pos, slimgb_alg *c)
static void c_S_element_changed_hook(int pos, slimgb_alg *c)
sorted_pair_node * top_pair(slimgb_alg *c)
static void replace_pair(int &i, int &j, slimgb_alg *c)
static void multi_reduction_find(red_object *los, int, slimgb_alg *c, int startf, find_erg &erg)
static void line_of_extended_prod(int fixpos, slimgb_alg *c)
static BOOLEAN trivial_syzygie(int pos1, int pos2, poly bound, slimgb_alg *c)
static int iq_crit(const void *ap, const void *bp)
static poly redNF2(poly h, slimgb_alg *c, int &len, number &m, int n=0)
static void simplify_poly(poly p, ring r)
static void multi_reduction(red_object *los, int &losl, slimgb_alg *c)
static void add_later(poly p, const char *prot, slimgb_alg *c)
static poly pOne_Special(const ring r=currRing)
static poly redTailShort(poly h, kStrategy strat)
static void cleanS(kStrategy strat, slimgb_alg *c)
static BOOLEAN ascending(int *i, int top)
static wlen_type quality_of_pos_in_strat_S_mult_high(int pos, poly high, slimgb_alg *c)
static void multi_reduce_step(find_erg &erg, red_object *r, slimgb_alg *c)
static wlen_type do_pELength(poly p, slimgb_alg *c, int dlm=-1)
ideal do_t_rep_gb(ring, ideal arg_I, int syz_comp, BOOLEAN F4_mode, int deg_pos)
static wlen_type pQuality(poly p, slimgb_alg *c, int l=-1)
static void move_backward_in_S(int old_pos, int new_pos, kStrategy strat)
void free_sorted_pair_node(sorted_pair_node *s, const ring r)
BOOLEAN lenS_correct(kStrategy strat)
int terms_sort_crit(const void *a, const void *b)
static void canonicalize_region(red_object *los, int l, int u, slimgb_alg *)
static BOOLEAN polynomial_root(poly h, ring r)
static int bucket_guess(kBucket *bucket)
wlen_type kSBucketLength(kBucket *b, poly lm=NULL)
TODO CoefBuckets bercksichtigen.
static void super_clean_top_of_pair_list(slimgb_alg *c)
static void multi_reduction_lls_trick(red_object *los, int, slimgb_alg *c, find_erg &erg)
static int red_object_better_gen(const void *ap, const void *bp)
static void length_one_crit(slimgb_alg *c, int pos, int len)
static BOOLEAN has_t_rep(const int &arg_i, const int &arg_j, slimgb_alg *state)
static void add_to_reductors(slimgb_alg *c, poly h, int len, int ecart, BOOLEAN simplified=FALSE)
static BOOLEAN pHasNotCFExtended(poly p1, poly p2, poly m)
static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg *c)
static const int bundle_size_noro
static BOOLEAN state_is(calc_state state, const int &i, const int &j, slimgb_alg *c)
static BOOLEAN elength_is_normal_length(poly p, slimgb_alg *c)
void write_minus_coef_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)
void add_dense(number_type *const temp_array, int, const number_type *row, int len)
int tgb_pair_better_gen2(const void *ap, const void *bp)
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)
MonRedResNP< number_type > noro_red_mon_to_non_poly(poly t, NoroCache< number_type > *cache, slimgb_alg *c)
sorted_pair_node ** spn_merge(sorted_pair_node **p, int pn, sorted_pair_node **q, int qn, slimgb_alg *c)
void now_t_rep(const int &arg_i, const int &arg_j, slimgb_alg *c)
void simplest_gauss_modp(number_type *a, int nrows, int ncols)
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)
sorted_pair_node ** add_to_basis_ideal_quotient(poly h, slimgb_alg *c, int *ip)
void write_coef_idx_to_buffer(CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen)
void write_poly_to_row(number_type *row, poly h, poly *terms, int tn)
void sub_dense(number_type *const temp_array, int, const number_type *row, int len)
void add_coef_times_sparse(number_type *const temp_array, int, SparseRow< number_type > *row, number coef)
int pos_helper(kStrategy strat, poly p, len_type len, set_type setL, polyset set)
poly row_to_poly(number_type *row, poly *terms, int tn, ring r)
void sub_sparse(number_type *const temp_array, int, SparseRow< number_type > *row)
SparseRow< number_type > * noro_red_to_non_poly_t(poly p, int &len, NoroCache< number_type > *cache, slimgb_alg *c)
wlen_type expected_length
void write_coef_times_xx_idx_to_buffer(CoefIdx< number_type > *const pairs, int &pos, int *const idx_array, number_type *const coef_array, const int rlen, const number coef)
void add_sparse(number_type *const temp_array, int, SparseRow< number_type > *row)
int modP_lastIndexRow(number_type *row, int ncols)
void add_coef_times_dense(number_type *const temp_array, int, const number_type *row, int len, number coef)
void free_sorted_pair_node(sorted_pair_node *s, const ring r)
void noro_step(poly *p, int &pn, slimgb_alg *c)
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 term_nodes_sort_crit(const void *a, const void *b)
void write_coef_idx_to_buffer_dense(CoefIdx< number_type > *const pairs, int &pos, number_type *const coef_array, const int rlen)