Skip to content

Commit

Permalink
fix: more fixes to init of Z/*
Browse files Browse the repository at this point in the history
  • Loading branch information
mmklee committed Dec 17, 2012
1 parent 8c6bd4d commit 4880569
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 4 additions & 1 deletion libpolys/coeffs/rmodulo2m.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ BOOLEAN nr2mInitChar (coeffs r, void* p)
r->cfKillChar = ndKillChar; /* dummy*/
r->nCoeffIsEqual = nr2mCoeffIsEqual;

r->modBase = (int_number) omAlloc(sizeof(mpz_t));
r->modBase = (int_number) omAllocBin (gmp_nrz_bin);
mpz_init_set_si (r->modBase, 2L);
r->ringtype = 1;
r->modNumber= (int_number) omAllocBin (gmp_nrz_bin);
mpz_init (r->modNumber);
mpz_pow_ui (r->modNumber, r->modBase, r->modExponent);

/* next cast may yield an overflow as mod2mMask is an unsigned long */
r->ch = (int)r->mod2mMask + 1;
Expand Down
7 changes: 1 addition & 6 deletions libpolys/coeffs/rmodulon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BOOLEAN nrnInitChar (coeffs r, void* p)
{
assume( (getCoeffType(r) == ID) || (getCoeffType (r) == ID2) );
ZnmInfo * info= (ZnmInfo *) p;
r->modBase = (int_number) omAlloc(sizeof(mpz_t));
r->modBase = (int_number) omAllocBin (gmp_nrz_bin);
mpz_init_set (r->modBase, info->base);

nrnInitExp (info->exp, r);
Expand Down Expand Up @@ -577,14 +577,9 @@ nMapFunc nrnSetMap(const coeffs src, const coeffs dst)
void nrnSetExp(unsigned long m, coeffs r)
{
/* clean up former stuff */
//if (r->modBase != NULL) mpz_clear(r->modBase);
if (r->modNumber != NULL) mpz_clear(r->modNumber);

r->modExponent= m;
/* this is Z/m = Z/(m^1), hence set modBase = m, modExponent = 1: */
//r->modBase = (int_number)omAllocBin(gmp_nrz_bin);
//mpz_init(r->modBase);
//mpz_set_ui(r->modBase, (unsigned long)m);
r->modNumber = (int_number)omAllocBin(gmp_nrz_bin);
mpz_init_set (r->modNumber, r->modBase);
mpz_pow_ui (r->modNumber, r->modNumber, m);
Expand Down

0 comments on commit 4880569

Please sign in to comment.