24 const int l = L->ncols-1;
26 for (
int j =
R->N;
j > 0;
j--)
30 for (
k =
l;
k >= 0;
k--)
32 if (p_GetExp(L->m[
k],
j,
R) > 0)
59 for (
int j =
R->N;
j > 0;
j--)
83 const unsigned long n_elems = L->ncols;
85 = (
unsigned int *)
omAlloc0((L->rank+1)*
sizeof(
unsigned int));
92 for (
int i = 0;
i <= L->rank;
i++)
103 const poly a = L->m[
k-1];
119 const lt_struct *
const *
const hash_previous_module)
123 unsigned long count =
v[0].comp;
128 const poly q = p_New(r);
132 for(
unsigned long i = 1;
i <
count;
i++)
135 ||
UNLIKELY(!(_p_LmDivisibleByNoComp(
v[
i].lt, q, r))))
139 p_MemAdd_NegWeightAdjust(q, r);
140 p_ExpVectorDiff(q, q,
v[
i].lt, r);
141 p_SetComp(q,
v[
i].
comp, r);
153 const ideal previous_module,
const std::vector<bool> &
variables,
154 const lt_struct *
const *
const hash_previous_module);
157 const ideal previous_module,
const std::vector<bool> &
variables,
158 const lt_struct *
const *
const hash_previous_module,
159 const bool use_cache);
165 const ideal previous_module,
const std::vector<bool> &
variables,
166 const lt_struct *
const *
const hash_previous_module,
167 const bool use_cache)
180 hash_previous_module);
183 hash_previous_module,
false);
185 return p_Add_q(
s, t, r);
193 const ideal previous_module,
const std::vector<bool> &
variables,
194 const lt_struct *
const *
const hash_previous_module,
195 const bool use_cache)
197 const poly tail = previous_module->m[
comp]->next;
206 hash_previous_module, use_cache);
243 for (cache_term::iterator itr =
T->begin(); itr !=
T->end(); ++itr)
245 p_Delete(&(itr->second), r);
246 p_Delete(
const_cast<poly*
>(&(itr->first)), r);
257 T->insert(cache_term::value_type(p_Head(multiplier, r), p_Copy(
p, r)));
261 const poly multiplier)
268 poly
p = p_Copy(itr->second, r);
269 if (
LIKELY(!n_Equal(pGetCoeff(multiplier), pGetCoeff(itr->first), r->cf)))
271 number n = n_Div(pGetCoeff(multiplier), pGetCoeff(itr->first), r->cf);
272 p = p_Mult_nn(
p, n, r);
279 const ideal previous_module,
const std::vector<bool> &
variables,
280 const lt_struct *
const *
const hash_previous_module)
283 cache_term::const_iterator itr =
T->find(multiplier);
289 hash_previous_module,
true);
299 const lt_struct *
const *
const hash_previous_module,
300 const bool use_cache)
305 hash_previous_module, use_cache);
310 previous_module,
variables, hash_previous_module);
313 previous_module,
variables, hash_previous_module,
false);
315 t1 = p_Add_q(t1, t2,
R);
329 const poly f_i =
G->m[
i];
330 const poly f_j =
G->m[
j];
331 poly
head = p_Init(r);
333 long exp_i, exp_j,
lcm;
334 for (
int k = (
int)r->N;
k > 0;
k--)
336 exp_i = p_GetExp(f_i,
k, r);
337 exp_j = p_GetExp(f_j,
k, r);
338 lcm = si_max(exp_i, exp_j);
341 p_SetComp(
head,
i+1, r);
353 const poly f_i =
G->m[
i];
354 const poly f_j =
G->m[
j];
355 poly
head = p_Init(r);
357 poly head_ext = p_Init(r);
358 pSetCoeff0(head_ext, n_InpNeg(n_Div(pGetCoeff(f_i), pGetCoeff(f_j), r->cf),
360 long exp_i, exp_j,
lcm;
361 for (
int k = (
int)r->N;
k > 0;
k--)
363 exp_i = p_GetExp(f_i,
k, r);
364 exp_j = p_GetExp(f_j,
k, r);
365 lcm = si_max(exp_i, exp_j);
367 p_SetExp(head_ext,
k,
lcm-exp_j, r);
369 p_SetComp(
head,
i+1, r);
371 p_SetComp(head_ext,
j+1, r);
373 head->next = head_ext;
391 for (
int j =
i-1;
j >= 0;
j--)
399 for (
int j =
i-1;
j >= 0;
j--)
403 M_i->m[
k] = syzHead(
G,
i,
j);
433 M_i->m[
j] = syzHead(
G,
i,
j+index);
447 for (
int i =
size-1;
i >= 0;
i--)
457 for (
int i =
size-1;
i >= 0;
i--)
476 return (comp_a > comp_b) - (comp_a < comp_b);
482 long deg_a =
p_Deg(p_a, r);
483 long deg_b =
p_Deg(p_b, r);
484 return (deg_a > deg_b) - (deg_a < deg_b);
493 p_GetExpV(p_a, exp_a, r);
494 p_GetExpV(p_b, exp_b, r);
495 for (
int i = r->N;
i > 0;
i--)
497 cmp = (exp_a[
i] > exp_b[
i]) - (exp_a[
i] < exp_b[
i]);
508 poly p_a = *((poly *)a);
509 poly p_b = *((poly *)
b);
527 ideal *
M = (ideal *)
omalloc((
G->ncols-1)*
sizeof(ideal));
528 for (
int i =
G->ncols-2;
i >= 0;
i--)
530 M[
i] = syzM_i(
G,
i+1, syzHead);
533 for (
int i =
G->ncols-2;
i >= 0;
i--)
542 qsort(frame->m, frame->ncols,
sizeof(poly),
compare_Mi);
550 const std::vector<bool> &
variables,
const bool use_cache)
562 res[index-1],
variables, hash_previous_module, use_cache);
564 for (
int i = 0;
i <=
res[index-1]->rank;
i++)
566 omfree(hash_previous_module[
i]);
568 omFree(hash_previous_module);
582 for (
int j =
R->N;
j > 0;
j--)
599 for (
int i = 0;
i <
res[index]->ncols;
i++)
601 poly p_iter =
res[index]->m[
i]->next;
604 while (p_iter->next !=
NULL)
620 for (
int i = 0;
i <
res[index]->ncols;
i++)
635 const bool single_module,
const bool use_cache,
636 const bool use_tensor_trick, std::vector<bool> &
variables)
654 if (use_tensor_trick)
659 if (index >= max_index) {
break; }
672 const bool single_module,
const bool use_cache,
673 const bool use_tensor_trick)
684 if (use_tensor_trick)
694 do_lifting, single_module, use_cache, use_tensor_trick,
702 bool *single_module_ptr,
const char *method)
704 if (strcmp(method,
"complete") == 0)
707 *do_lifting_ptr =
true;
708 *single_module_ptr =
false;
710 else if (strcmp(method,
"frame") == 0)
713 *do_lifting_ptr =
false;
714 *single_module_ptr =
false;
716 else if (strcmp(method,
"extended frame") == 0)
719 *do_lifting_ptr =
false;
720 *single_module_ptr =
false;
722 else if (strcmp(method,
"single module") == 0)
725 *do_lifting_ptr =
true;
726 *single_module_ptr =
true;
730 *do_lifting_ptr =
true;
731 *single_module_ptr =
false;
738#define insert_first_term(r, p, q, R) \
743 if (q != NULL && p_LmCmp(p, q, R) != 1) { \
744 while (q->next != NULL && p_LmCmp(p, q->next, R) == -1) { \
759 const bool single_module)
763 int index = (single_module ? length-1 : 1);
764 while (index < length && !
idIs0(
res[index]))
793 const bool use_cache,
const bool use_tensor_trick)
797 if (strcmp(method,
"frame") != 0)
808 set_options(&syzHead, &do_lifting, &single_module, method);
810 single_module, use_cache, use_tensor_trick);
811 if (new_length < length)
814 (new_length+1)*
sizeof(ideal));
816 if (strcmp(method,
"frame") != 0)
821 result->length = new_length;
822 result->list_length = new_length;
Class Cache is a template-implementation of a cache with arbitrary classes for representing keys and ...
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
ideal id_Copy(ideal h1, const ring r)
copy an ideal
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
#define p_SetCoeff0(p, n, r)
#define __p_GetComp(p, r)
#define omFreeSize(addr, size)
#define omReallocSize(addr, o_size, size)
#define omFreeBin(addr, bin)
#define p_MemSum_LengthGeneral(r, s1, s2, length)
unsigned long p_GetShortExpVector(const poly p, const ring r)
long p_Deg(poly a, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatibility layer for legacy polynomial operations (over currRing).
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
void sBucketDestroy(sBucket_pt *bucket)
sBucket_pt sBucketCreate(const ring r)
void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length)
int status int void size_t count
ideal idInit(int idsize, int rank)
initialise an ideal / module
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
bool operator()(const poly &l, const poly &r) const
static bool check_variables(const std::vector< bool > &variables, const poly m)
static int compare_deg(const poly p_a, const poly p_b)
static ideal syzM_i_sorted(const ideal G, const int i, syzHeadFunction *syzHead)
static void update_variables(std::vector< bool > &variables, const ideal L)
std::map< poly, poly, cache_compare > cache_term
static ideal computeFrame(const ideal G, syzM_i_Function syzM_i, syzHeadFunction *syzHead)
static int compare_comp(const poly p_a, const poly p_b)
static ideal idConcat(const ideal *M, const int size, const int rank)
static poly lift_ext_LT(const poly a, const ideal previous_module, const std::vector< bool > &variables, const lt_struct *const *const hash_previous_module, const bool use_cache)
static void initialize_hash(lt_struct **C, const ideal L)
static poly get_from_cache_term(const cache_term::const_iterator itr, const poly multiplier)
static poly syzHeadExtFrame(const ideal G, const int i, const int j)
static poly traverse_tail(const poly multiplier, const int comp, const ideal previous_module, const std::vector< bool > &variables, const lt_struct *const *const hash_previous_module)
static void computeLiftings(const resolvente res, const int index, const std::vector< bool > &variables, const bool use_cache)
static bool contains_unused_variable(const poly m, const std::vector< bool > &variables)
static int compare_lex(const poly p_a, const poly p_b)
ideal syzM_i_Function(ideal, int, syzHeadFunction)
static void set_options(syzHeadFunction **syzHead_ptr, bool *do_lifting_ptr, bool *single_module_ptr, const char *method)
static void initialize_cache(const int size)
static poly compute_image(const poly multiplier, const int comp, const ideal previous_module, const std::vector< bool > &variables, const lt_struct *const *const hash_previous_module, const bool use_cache)
#define insert_first_term(r, p, q, R)
static poly find_reducer(const poly multiplier, const poly t, const lt_struct *const *const hash_previous_module)
static void delete_tails(resolvente res, const int index)
static int computeResolution(resolvente res, const int max_index, syzHeadFunction *syzHead, const bool do_lifting, const bool single_module, const bool use_cache, const bool use_tensor_trick)
static void insert_into_cache_term(cache_term *T, const poly multiplier, const poly p)
static void delete_cache(const int size)
static poly syzHeadFrame(const ideal G, const int i, const int j)
static void insert_ext_induced_LTs(const resolvente res, const int length, const bool single_module)
static poly reduce_term(const poly multiplier, const poly term, const ideal previous_module, const std::vector< bool > &variables, const lt_struct *const *const hash_previous_module, const bool use_cache)
static int computeResolution_iteration(resolvente res, const int max_index, syzHeadFunction *syzHead, const bool do_lifting, const bool single_module, const bool use_cache, const bool use_tensor_trick, std::vector< bool > &variables)
static ideal syzM_i_unsorted(const ideal G, const int i, syzHeadFunction *syzHead)
static int compare_Mi(const void *a, const void *b)
static void delete_variables(resolvente res, const int index, const std::vector< bool > &variables)
poly syzHeadFunction(ideal, int, int)
syStrategy syFrank(const ideal arg, const int length, const char *method, const bool use_cache=true, const bool use_tensor_trick=false)