24 const int l = L->ncols-1;
26 for (
int j = R->N;
j > 0;
j--)
30 for (k = l; k >= 0; k--)
39 variables[
j-1] =
false;
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)
128 const poly q =
p_New(r);
132 for(
unsigned long i = 1;
i <
count;
i++)
134 if (
LIKELY(v[
i].sev & q_not_sev)
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)
169 poly
s =
find_reducer(multiplier, term, hash_previous_module);
180 hash_previous_module);
183 hash_previous_module,
false);
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;
205 const poly rt =
reduce_term(multiplier,
p, previous_module, variables,
206 hash_previous_module, use_cache);
243 for (cache_term::iterator itr = T->begin(); itr != T->end(); ++itr)
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);
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);
284 if (
LIKELY(itr != T->end()))
288 poly
p =
compute_image(multiplier, comp, previous_module, variables,
289 hash_previous_module,
true);
297 static poly
lift_ext_LT(
const poly a,
const ideal previous_module,
298 const std::vector<bool> &variables,
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);
331 for (i = k; i >= 0; i--)
333 for (j = k; j >
i; j--)
335 if (id->m[j] !=
NULL)
359 const poly f_i = G->m[
i];
360 const poly f_j = G->m[
j];
363 long exp_i, exp_j,
lcm;
364 for (
int k = (
int)r->N;
k > 0;
k--)
368 lcm =
si_max(exp_i, exp_j);
383 const poly f_i = G->m[
i];
384 const poly f_j = G->m[
j];
387 poly head_ext =
p_Init(r);
390 long exp_i, exp_j,
lcm;
391 for (
int k = (
int)r->N;
k > 0;
k--)
395 lcm =
si_max(exp_i, exp_j);
403 head->next = head_ext;
421 for (
int j = i-1;
j >= 0;
j--)
427 M_i =
idInit(ncols, G->ncols);
429 for (
int j = i-1;
j >= 0;
j--)
433 M_i->m[
k] = syzHead(G, i,
j);
455 while (
__p_GetComp(G->m[index], r) == comp) index--;
460 M_i =
idInit(ncols, G->ncols);
461 for (
int j = ncols-1;
j >= 0;
j--)
463 M_i->m[
j] = syzHead(G, i,
j+index);
477 for (
int i = size-1;
i >= 0;
i--)
481 ncols += M[
i]->ncols;
484 if (ncols == 0)
return idInit(1, rank);
487 for (
int i = size-1;
i >= 0;
i--)
491 for (
int j = M[
i]->ncols-1;
j >= 0;
j--)
493 result->m[
k] = M[
i]->m[
j];
506 return (comp_a > comp_b) - (comp_a < comp_b);
512 long deg_a =
p_Deg(p_a, r);
513 long deg_b =
p_Deg(p_b, r);
514 return (deg_a > deg_b) - (deg_a < deg_b);
525 for (
int i = r->N;
i > 0;
i--)
527 cmp = (exp_a[
i] > exp_b[
i]) - (exp_a[
i] < exp_b[
i]);
538 poly
p_a = *((poly *)a);
539 poly
p_b = *((poly *)b);
557 ideal *
M = (ideal *)
omalloc((G->ncols-1)*
sizeof(ideal));
558 for (
int i = G->ncols-2;
i >= 0;
i--)
560 M[
i] = syzM_i(G,
i+1, syzHead);
562 ideal frame =
idConcat(M, G->ncols-1, G->ncols);
563 for (
int i = G->ncols-2;
i >= 0;
i--)
572 qsort(frame->m, frame->ncols,
sizeof(poly),
compare_Mi);
580 const std::vector<bool> &variables,
const bool use_cache)
589 for (
int j = res[index]->
ncols-1;
j >= 0;
j--)
592 res[index-1], variables, hash_previous_module, use_cache);
594 for (
int i = 0;
i <= res[index-1]->rank;
i++)
596 omfree(hash_previous_module[
i]);
598 omFree(hash_previous_module);
609 const std::vector<bool> &variables)
612 for (
int j = R->N;
j > 0;
j--)
627 const std::vector<bool> &variables)
629 for (
int i = 0;
i < res[
index]->ncols;
i++)
631 poly p_iter = res[
index]->m[
i]->next;
634 while (p_iter->next !=
NULL)
650 for (
int i = 0;
i < res[
index]->ncols;
i++)
652 if (res[index]->
m[
i] !=
NULL)
665 const bool single_module,
const bool use_cache,
666 const bool use_tensor_trick, std::vector<bool> &variables)
669 while (!
idIs0(res[index]))
684 if (use_tensor_trick)
689 if (index >= max_index) {
break; }
702 const bool single_module,
const bool use_cache,
703 const bool use_tensor_trick)
710 variables.resize(
currRing->N+1,
true);
714 if (use_tensor_trick)
724 do_lifting, single_module, use_cache, use_tensor_trick,
732 bool *single_module_ptr,
const char *method)
734 if (strcmp(method,
"complete") == 0)
737 *do_lifting_ptr =
true;
738 *single_module_ptr =
false;
740 else if (strcmp(method,
"frame") == 0)
743 *do_lifting_ptr =
false;
744 *single_module_ptr =
false;
746 else if (strcmp(method,
"extended frame") == 0)
749 *do_lifting_ptr =
false;
750 *single_module_ptr =
false;
752 else if (strcmp(method,
"single module") == 0)
755 *do_lifting_ptr =
true;
756 *single_module_ptr =
true;
760 *do_lifting_ptr =
true;
761 *single_module_ptr =
false;
768 #define insert_first_term(r, p, q, R) \ 773 if (q != NULL && p_LmCmp(p, q, R) != 1) { \ 774 while (q->next != NULL && p_LmCmp(p, q->next, R) == -1) { \ 789 const bool single_module)
793 int index = (single_module ? length-1 : 1);
794 while (index < length && !
idIs0(res[index]))
796 for (
int j = res[index]->
ncols-1;
j >= 0;
j--)
823 const bool use_cache,
const bool use_tensor_trick)
827 if (strcmp(method,
"frame") != 0)
838 set_options(&syzHead, &do_lifting, &single_module, method);
840 single_module, use_cache, use_tensor_trick);
841 if (new_length < length)
844 (new_length+1)*
sizeof(ideal));
846 if (strcmp(method,
"frame") != 0)
851 result->
length = new_length;
int status int void size_t count
static void update_variables(std::vector< bool > &variables, const ideal L)
#define __p_GetComp(p, r)
static void delete_tails(resolvente res, const int index)
#define p_MemSum_LengthGeneral(r, s1, s2, length)
const CanonicalForm int s
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)
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
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 ideal idConcat(const ideal *M, const int size, const int rank)
Compatiblity layer for legacy polynomial operations (over currRing)
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
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)
ideal syzM_i_Function(ideal, int, syzHeadFunction)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static void p_GetExpV(poly p, int *ev, const ring r)
#define omFreeSize(addr, size)
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
BOOLEAN p_New(leftv res, leftv args)
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
static poly syzHeadExtFrame(const ideal G, const int i, const int j)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
static bool check_variables(const std::vector< bool > &variables, const poly m)
ideal p_b(ideal h, poly a)
static void p_LmFree(poly p, ring)
static ideal syzM_i_unsorted(const ideal G, const int i, syzHeadFunction *syzHead)
static poly p_Copy(poly p, const ring r)
returns a copy of p
syStrategy syFrank(const ideal arg, const int length, const char *method, 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 initialize_cache(const int size)
Class Cache is a template-implementation of a cache with arbitrary classes for representing keys and ...
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
static int compare_Mi(const void *a, const void *b)
static BOOLEAN _p_LmDivisibleByNoComp(poly a, poly b, const ring r)
return: FALSE, if there exists i, such that a->exp[i] > b->exp[i] TRUE, otherwise (1) Consider long v...
#define omReallocSize(addr, o_size, size)
static poly p_Head(poly p, const ring r)
static void delete_cache(const int size)
static poly syzHeadFrame(const ideal G, const int i, const int j)
long p_Deg(poly a, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
void sBucketDestroy(sBucket_pt *bucket)
static void insert_ext_induced_LTs(const resolvente res, const int length, const bool single_module)
static ideal syzM_i_sorted(const ideal G, const int i, syzHeadFunction *syzHead)
static bool contains_unused_variable(const poly m, const std::vector< bool > &variables)
sBucket_pt sBucketCreate(const ring r)
static void p_MemAdd_NegWeightAdjust(poly p, const ring r)
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
static int p_LmCmp(poly p, poly q, const ring r)
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)
static int si_max(const int a, const int b)
static poly p_Mult_nn(poly p, number n, const ring r)
static void computeLiftings(const resolvente res, const int index, const std::vector< bool > &variables, const bool use_cache)
poly syzHeadFunction(ideal, int, int)
static unsigned pLength(poly a)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static cache_term * Cache
static int index(p_Length length, p_Ord ord)
static void delete_variables(resolvente res, const int index, const std::vector< bool > &variables)
static void p_Delete(poly *p, const ring r)
static int compare_lex(const poly p_a, const poly p_b)
unsigned long p_GetShortExpVector(const poly p, const ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
const Variable & v
< [in] a sqrfree bivariate poly
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
static void id_DelDiv_no_test(ideal id)
static poly find_reducer(const poly multiplier, const poly t, const lt_struct *const *const hash_previous_module)
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)
static void initialize_hash(lt_struct **C, const ideal L)
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
#define insert_first_term(r, p, q, R)
static BOOLEAN length(leftv result, leftv arg)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
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 int compare_comp(const poly p_a, const poly p_b)
static ideal computeFrame(const ideal G, syzM_i_Function syzM_i, syzHeadFunction *syzHead)
std::map< poly, poly, cache_compare > cache_term
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
static void p_Setm(poly p, const ring r)
static int compare_deg(const poly p_a, const poly p_b)
static poly get_from_cache_term(const cache_term::const_iterator itr, const poly multiplier)
#define p_SetCoeff0(p, n, r)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static void set_options(syzHeadFunction **syzHead_ptr, bool *do_lifting_ptr, bool *single_module_ptr, const char *method)
static poly p_Add_q(poly p, poly q, const ring r)
#define omFreeBin(addr, bin)
bool operator()(const poly &l, const poly &r) const
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static poly p_Init(const ring r, omBin bin)
void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length)
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)