Skip to content

Commit

Permalink
minor changes/improvements
Browse files Browse the repository at this point in the history
add: default return value for a missing/wrong attribute of an idhdl object (atGet)
chg: minor cleanup in p_Setm_General
add: output of NegWeightL_* in rDebugPrint
add: some doxygen docs to pGetCoeff
add: more (internal) debug output on the ring/exponent structure: VarL_LowIndex, VarL_Offset
add: doxygen description to id_Sort
  • Loading branch information
Oleksandr Motsak committed May 23, 2012
1 parent a28cb4f commit 5998134
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Singular/attrib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ void * atGet(leftv root,const char * name)
return NULL;
}

void * atGet(idhdl root,const char * name, int t)
void * atGet(idhdl root,const char * name, int t, void *defaultReturnValue)
{
attr temp = root->attribute->get(name);
if ((temp!=NULL) && (temp->atyp==t))
return temp->data;
else
return NULL;
return defaultReturnValue;
}

void * atGet(leftv root,const char * name, int t)
Expand Down
2 changes: 1 addition & 1 deletion Singular/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class sattr

void * atGet(idhdl root,const char * name);
void * atGet(leftv root,const char * name);
void * atGet(idhdl root,const char * name, int t);
void * atGet(idhdl root,const char * name, int t, void *defaultReturnValue = NULL);
void * atGet(leftv root,const char * name, int t);
void atSet(idhdl root,const char * name,void * data,int typ);
void atSet(leftv root,const char * name,void * data,int typ);
Expand Down
6 changes: 3 additions & 3 deletions libpolys/polys/monomials/p_polys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ void p_Setm_General(poly p, const ring r)

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

p->exp[o->data.am.place] = ord;
Expand Down
3 changes: 3 additions & 0 deletions libpolys/polys/monomials/p_polys.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

// coeff
// #define pGetCoeff(p) ((p)->coef)
/// return an alias to the leading coefficient of p
/// assumes that p != NULL
/// NOTE: not copy
static inline number& pGetCoeff(poly p)
{
assume(p != NULL);
Expand Down
21 changes: 19 additions & 2 deletions libpolys/polys/monomials/ring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4032,14 +4032,24 @@ void rDebugPrint(ring r)
Print("CmpL_Size:%d ",r->CmpL_Size);
Print("VarL_Size:%d\n",r->VarL_Size);
Print("bitmask=0x%lx (expbound=%ld) \n",r->bitmask, r->bitmask);
Print("divmask=%lx\n", r->divmask);
Print("BitsPerExp=%d ExpPerLong=%d MinExpPerLong=%d at L[%d]\n", r->BitsPerExp, r->ExpPerLong, r->MinExpPerLong, r->VarL_Offset[0]);
PrintS("varoffset:\n");

Print("VarL_LowIndex: %d\n", r->VarL_LowIndex);
PrintS("VarL_Offset:\n");
if (r->VarL_Offset==NULL) PrintS(" NULL");
else
for(j = 0; j < r->VarL_Size; j++)
Print(" VarL_Offset[%d]: %d ", j, r->VarL_Offset[j]);
PrintLn();


PrintS("VarOffset:\n");
if (r->VarOffset==NULL) PrintS(" NULL\n");
else
for(j=0;j<=r->N;j++)
Print(" v%d at e-pos %d, bit %d\n",
j,r->VarOffset[j] & 0xffffff, r->VarOffset[j] >>24);
Print("divmask=%lx\n", r->divmask);
PrintS("ordsgn:\n");
for(j=0;j<r->CmpL_Size;j++)
Print(" ordsgn %ld at pos %d\n",r->ordsgn[j],j);
Expand Down Expand Up @@ -4164,6 +4174,13 @@ void rDebugPrint(ring r)
}
Print("LexOrder:%d, MixedOrder:%d\n",r->LexOrder, r->MixedOrder);

Print("NegWeightL_Size: %d, NegWeightL_Offset: ", r->NegWeightL_Size);
if (r->NegWeightL_Offset==NULL) PrintS(" NULL");
else
for(j = 0; j < r->NegWeightL_Size; j++)
Print(" [%d]: %d ", j, r->NegWeightL_Offset[j]);
PrintLn();

// p_Procs stuff
p_Procs_s proc_names;
const char* field;
Expand Down
12 changes: 4 additions & 8 deletions libpolys/polys/simpleideals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,7 @@ void id_DBTest(ideal h1, int level, const char *f,const int l, const ring r)
}
#endif

/*3
* for idSort: compare a and b revlex inclusive module comp.
*/
///3 for idSort: compare a and b revlex inclusive module comp.
static int p_Comp_RevLex(poly a, poly b,BOOLEAN nolex, const ring R)
{
if (b==NULL) return 1;
Expand Down Expand Up @@ -468,11 +466,9 @@ static int p_Comp_RevLex(poly a, poly b,BOOLEAN nolex, const ring R)
return -1;
}

/*2
*sorts the ideal w.r.t. the actual ringordering
*uses lex-ordering when nolex = FALSE
*/
intvec *id_Sort(ideal id,BOOLEAN nolex, const ring r)
// sorts the ideal w.r.t. the actual ringordering
// uses lex-ordering when nolex = FALSE
intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
{
intvec * result = new intvec(IDELEMS(id));
int i, j, actpos=0, newpos;
Expand Down
6 changes: 5 additions & 1 deletion libpolys/polys/simpleideals.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ void id_DelEquals(ideal id, const ring r);
void id_DelLmEquals(ideal id, const ring r);
void id_DelDiv(ideal id, const ring r);
BOOLEAN id_IsConstant(ideal id, const ring r);
intvec *id_Sort(ideal id,BOOLEAN nolex, const ring r);

/// sorts the ideal w.r.t. the actual ringordering
/// uses lex-ordering when nolex = FALSE
intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r);

ideal id_Transp(ideal a, const ring rRing);
void id_Compactify(ideal id, const ring r);
ideal id_Mult (ideal h1,ideal h2, const ring r);
Expand Down

0 comments on commit 5998134

Please sign in to comment.