From 90aec7cff5c6f80707df1dab11b76ec197feef31 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Thu, 29 Sep 2011 14:59:11 +0200 Subject: [PATCH] fix: p_Content for alg.ext. fix: p_Monic --- libpolys/polys/monomials/p_polys.cc | 10 ++++++---- libpolys/polys/monomials/p_polys.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libpolys/polys/monomials/p_polys.cc b/libpolys/polys/monomials/p_polys.cc index 310ba795b1..f7e4fa2574 100644 --- a/libpolys/polys/monomials/p_polys.cc +++ b/libpolys/polys/monomials/p_polys.cc @@ -1481,19 +1481,21 @@ poly p_PolyDiv(poly &p, poly divisor, BOOLEAN needResult, ring r) this assumes that we are over a ground field so that division is well-defined; modifies p */ -void p_Monic(poly &p, ring r) +void p_Monic(poly p, const ring r) { if (p == NULL) return; + number n = n_Init(1, r->cf); + if (p->next==NULL) { p_SetCoeff(p,n,r); return; } poly pp = p; number lc = p_GetCoeff(p, r); if (n_IsOne(lc, r->cf)) return; number lcInverse = n_Invers(lc, r->cf); - number n = n_Init(1, r->cf); p_SetCoeff(p, n, r); // destroys old leading coefficient! - p = pIter(p); + pIter(p); while (p != NULL) { number n = n_Mult(p_GetCoeff(p, r), lcInverse, r->cf); + n_Normalize(n,r->cf); p_SetCoeff(p, n, r); // destroys old leading coefficient! p = pIter(p); } @@ -2071,8 +2073,8 @@ void p_Content(poly ph, const ring r) hzz=d; pIter(c_n); } + pIter(p); } - pIter(p); /* hzz contains the 1/lcm of all denominators in c_n_n*/ h=n_Invers(hzz,r->cf->extRing->cf); n_Delete(&hzz,r->cf->extRing->cf); diff --git a/libpolys/polys/monomials/p_polys.h b/libpolys/polys/monomials/p_polys.h index 0836ee070b..14c9e57ef5 100644 --- a/libpolys/polys/monomials/p_polys.h +++ b/libpolys/polys/monomials/p_polys.h @@ -1854,7 +1854,7 @@ poly p_PolyDiv(poly &p, poly divisor, BOOLEAN needResult, ring r); this assumes that we are over a ground field so that division is well-defined; modifies p */ -void p_Monic(poly &p, ring r); +void p_Monic(poly p, const ring r); /* assumes that p and q are univariate polynomials in r, mentioning the same variable;