Skip to content

Commit

Permalink
fixes to _am ordering
Browse files Browse the repository at this point in the history
add: additional int* weights_m pointer in struct sro_am
fix: rO_WMDegree should not mess around with start/end
fix: rCompose: _am ordering was not treated (fixed also by Hans)
  • Loading branch information
Oleksandr Motsak committed Mar 5, 2012
1 parent 9b1590d commit 3a8a0d9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
1 change: 1 addition & 0 deletions Singular/ipshell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,7 @@ ring rCompose(const lists L)
while((jj>=0)
&& ((R->order[jj]== ringorder_a)
|| (R->order[jj]== ringorder_aa)
|| (R->order[jj]== ringorder_am)
|| (R->order[jj]== ringorder_c)
|| (R->order[jj]== ringorder_C)
|| (R->order[jj]== ringorder_s)
Expand Down
30 changes: 18 additions & 12 deletions libpolys/polys/monomials/p_polys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,38 @@ void p_Setm_General(poly p, const ring r)
}
case ro_am:
{
ord=POLY_NEGWEIGHT_OFFSET;
int a,e;
a=o->data.am.start;
e=o->data.am.end;
int *w=o->data.am.weights;
ord = POLY_NEGWEIGHT_OFFSET;
const short a=o->data.am.start;
const short e=o->data.am.end;
const int * w=o->data.am.weights;
#if 1
for(int i=a;i<=e;i++) ord+=p_GetExp(p,i,r)*w[i-a];
int c=p_GetComp(p,r);
for(short i=a; i<=e; i++, w++)
ord += ((*w) * p_GetExp(p,i,r));
#else
long ai;
int ei,wi;
for(int i=a;i<=e;i++)
for(short i=a;i<=e;i++)
{
ei=p_GetExp(p,i,r);
wi=w[i-a];
ai=ei*wi;
if (ai/ei!=wi) pSetm_error=TRUE;
ord+=ai;
ord += ai;
if (ord<ai) pSetm_error=TRUE;
}
#endif
if ((c>0)&&(c<=o->data.am.len_gen))
const int c = p_GetComp(p,r);

const short len_gen= o->data.am.len_gen;

if ((c > 0) && (c <= len_gen))
{
ord+=w[c-(e-a)+2];
const int * const wm = o->data.am.weights_m;
assume( wm[0] == len_gen );
ord += wm[c];
}
p->exp[o->data.am.place]=ord;

p->exp[o->data.am.place] = ord;
break;
}
case ro_wp64:
Expand Down
12 changes: 8 additions & 4 deletions libpolys/polys/monomials/ring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void rWrite(ring r, BOOLEAN details)
}
if (r->order[l]!=ringorder_M) break;
}
if (r->order[l]==ringorder_am) /*j==0*/
if (r->order[l]==ringorder_am)
{
int m=r->wvhdl[l][i];
Print("\n// : %d module weights ",m);
Expand Down Expand Up @@ -2206,16 +2206,20 @@ static void rO_WDegree(int &place, int &bitplace, int start, int end,
static void rO_WMDegree(int &place, int &bitplace, int start, int end,
long *o, sro_ord &ord_struct, int *weights)
{
assume(weights != NULL);

// weighted degree (aligned) of variables v_start..v_end, ordsgn 1
while((start<end) && (weights[0]==0)) { start++; weights++; }
while((start<end) && (weights[end-start]==0)) { end--; }
// while((start<end) && (weights[0]==0)) { start++; weights++; }
// while((start<end) && (weights[end-start]==0)) { end--; }
rO_Align(place,bitplace);
ord_struct.ord_typ=ro_am;
ord_struct.data.am.start=start;
ord_struct.data.am.end=end;
ord_struct.data.am.place=place;
ord_struct.data.am.len_gen=weights[end-start+1];
ord_struct.data.am.weights=weights;
ord_struct.data.am.weights_m = weights + (end-start+1);
ord_struct.data.am.len_gen=weights[end-start+1];
assume( ord_struct.data.am.weights_m[0] == ord_struct.data.am.len_gen );
o[place]=1;
place++;
rO_Align(place,bitplace);
Expand Down
7 changes: 5 additions & 2 deletions libpolys/polys/monomials/ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ struct sro_am
short start; // bounds of ordering (in E)
short end;
short len_gen; // i>len_gen: weight(gen(i)):=0
int *weights; // pointers into wvhdl field of length (end-start+1) + len_gen
// contents w_1,... w_n, len, mod_w_1, .. mod_w_len, 0
int *weights; // pointers into wvhdl field of length (end-start+1) + len_gen + 1
// contents w_{start},... w_{end}, len, mod_w_1, .. mod_w_len, 0
int *weights_m; // pointers into wvhdl field of length len_gen + 1
// len_gen, mod_w_1, .. mod_w_len, 0

};
typedef struct sro_am sro_am;

Expand Down

0 comments on commit 3a8a0d9

Please sign in to comment.