27#define HAVE_MAP_OPTIMIZE 0
35 int n_max_map_monomials, ring map_r,
38 int n =
si_min(pi_r->N, n_max_map_monomials);
40 unsigned long e_i, e_j;
42 poly map_j =
p_Init(map_r);
44 for (
i=1;
i <= n;
i++)
48 m_i = max_map_monomials[
i-1];
51 for (
j = 1;
j<= map_r->N;
j++)
63static unsigned long maGetMaxExp(ideal pi_id, ring pi_r, ideal map_id, ring map_r)
66 poly* max_map_monomials = (poly*)
omAlloc(
IDELEMS(map_id)*
sizeof(poly));
67 poly max_pi_i, max_map_i;
81 if (temp >
max){
max=temp; }
103 p_wrp(monomial->src, src_r);
104 printf(
" ref:%d", monomial->ref);
108 p_wrp(monomial->dest, dest_r);
110 if (monomial->f1!=
NULL) { printf(
" f1:%lx", (
long)monomial->f1->src);
113 if (monomial->f2!=
NULL) { printf(
" f2:%lx",(
long)monomial->f2->src);
122 while (mpoly !=
NULL)
147 mp->coeff->bucket = bucket;
159 if (mp->coeff !=
NULL)
171 if (mp->dest !=
NULL)
220 iter->ref += what->ref;
224 while (coeff->next !=
NULL) coeff = coeff->next;
225 coeff->next =
iter->coeff;
226 iter->coeff = what->coeff;
264 for (
i=0;
i<mideal->n;
i++)
266 if (map_id->m[
i] !=
NULL)
282 ideal image_id, ring image_r,
283 ring &src_r, ring &dest_r,
BOOLEAN &simple)
286 int* weights = (
int*)
omAlloc0(map_r->N*
sizeof(
int));
300 unsigned long maxExp =
maGetMaxExp(map_id, map_r, image_id, image_r);
301 if (maxExp <= 1) maxExp = 2;
302 else if (maxExp > (
unsigned long) image_r->bitmask)
303 maxExp = (
unsigned long) image_r->bitmask;
314 if (image_r != dest_r)
328 for (
int i= 0;
i < m_id->n;
i++)
330 if (m_id->buckets[
i]!=
NULL)
367 if (dest_r != image_r)
382 Print(
"map[%ld:%d]{%d:", dest_r->bitmask, dest_r->ExpL_Size,
length);
386#if HAVE_MAP_OPTIMIZE > 0
405 if (dest_r != image_r)
415 res_image_id = res_dest_id;
463 for(
i=1;
i<=src_r->N;
i++)
502 if ((root!=
NULL) && (root->next!=
NULL))
518 int next_print_cost = total_cost;
533 if (
p->f1->ref>0) f1=
p_Copy(f1,dest_r);
539 if (
p->f2->ref>0) f2=
p_Copy(f2,dest_r);
563 if (cost > next_print_cost)
566 next_print_cost += total_cost;
590static poly
maEggT(
const poly m1,
const poly m2, poly &q1, poly &q2,
const ring r)
599 for (
i=1;
i<=r->N;
i++)
603 if (e1 > 0 && e2 > 0)
605 unsigned long em = (e1 > e2 ? e2 : e1);
660 if ((tmp_deg=
p_Deg(q,r)) > ggt_deg)
static int si_min(const int a, const int b)
void maMonomial_Destroy(mapoly mp, ring src_r, ring dest_r)
ideal fast_map_common_subexp(const ideal map_id, const ring map_r, const ideal image_id, const ring image_r)
void maMap_CreateRings(ideal map_id, ring map_r, ideal image_id, ring image_r, ring &src_r, ring &dest_r, BOOLEAN &simple)
static poly maGetMaxExpP(poly *max_map_monomials, int n_max_map_monomials, ring map_r, poly pi_m, ring pi_r)
STATIC_VAR omBin macoeffBin
static poly maEggT(const poly m1, const poly m2, poly &q1, poly &q2, const ring r)
void maMap_CreatePolyIdeal(ideal map_id, ring map_r, ring src_r, ring dest_r, mapoly &mp, maideal &mideal)
void maPoly_GetLength(mapoly mp, int &length)
mapoly maPoly_InsertMonomial(mapoly &into, mapoly what, ring src_r)
static void maPoly_InsertPoly(mapoly &into, poly what, ring src_r, sBucket_pt bucket)
mapoly maMonomial_Create(poly p, ring, sBucket_pt bucket)
ideal maIdeal_2_Ideal(maideal m_id, ring)
static poly maPoly_EvalMon(poly src, ring src_r, poly *dest_id, ring dest_r)
static int maPoly_Substitute(macoeff c, poly p, ring dest_r)
static mapoly maFindBestggT(mapoly mp, mapoly &choice, mapoly &fp, mapoly &fq, const ring r)
static unsigned long maGetMaxExp(ideal pi_id, ring pi_r, ideal map_id, ring map_r)
void maPoly_Eval(mapoly root, ring src_r, ideal dest_id, ring dest_r, int total_cost)
STATIC_VAR omBin mapolyBin
static void maMap_KillRings(ring map_r, ring image_r, ring src_r, ring dest_r)
void maPoly_Optimize(mapoly mpoly, ring src_r)
class macoeff_s * macoeff
void maMonomial_Out(mapoly monomial, ring src_r, ring dest_r=NULL)
class maideal_s * maideal
void maPoly_Out(mapoly mpoly, ring src_ring, ring dest_r=NULL)
mapoly maMonomial_Free(mapoly monomial, ring src_r, ring dest_r=NULL)
static int max(int a, int b)
static BOOLEAN Equal(number a, number b, const coeffs)
static bool Greater(mono_type m1, mono_type m2)
static BOOLEAN length(leftv result, leftv arg)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
#define omFreeSize(addr, size)
#define omFreeBin(addr, bin)
#define omGetSpecBin(size)
poly p_GetMaxExpP(poly p, const ring r)
return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0,...
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
long p_Deg(poly a, const ring r)
static int pLength(poly a)
static poly p_Mult_q(poly p, poly q, const ring r)
static BOOLEAN p_IsConstantComp(const poly p, const ring r)
like the respective p_LmIs* routines, except that p might be empty
static long p_AddExp(poly p, int v, long ee, ring r)
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
#define __pp_Mult_nn(p, n, r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
static void p_Setm(poly p, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
#define p_LmCmpAction(p, q, r, actionE, actionG, actionS)
static void p_Delete(poly *p, const ring r)
static void p_LmFree(poly p, ring)
static poly p_Init(const ring r, omBin bin)
static poly p_Copy(poly p, const ring r)
returns a copy of p
static long p_Totaldegree(poly p, const ring r)
void p_wrp(poly p, ring lmRing, ring tailRing)
poly prShallowCopyR(poly p, ring r, ring dest_r)
ideal idrShallowCopyR(ideal id, ring src_r, ring dest_r)
poly prShallowCopyR_NoSort(poly p, ring r, ring dest_r)
void PrintS(const char *s)
ring rModifyRing_Wp(ring r, int *weights)
construct Wp, C ring
void rKillModifiedRing(ring r)
void rKillModified_Wp_Ring(ring r)
ring rModifyRing_Simple(ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, unsigned long exp_limit, BOOLEAN &simple)
static BOOLEAN rField_is_Domain(const ring r)
#define rField_is_Ring(R)
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
sBucket_pt sBucketCreate(const ring r)
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_ShallowDelete(ideal *h, ring r)
Shallowdeletes an ideal/matrix.