Skip to content

Commit

Permalink
monic denominator
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed May 20, 2024
1 parent 6a2118b commit 18828ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,10 @@ Sturm-Habicht sequence of a spray.
* Functions `numberOfRealRoots`, `numberOfRealRootsInOpenInterval` and
`numberOfRealRootsInClosedInterval`, to compute the total number of real
roots of a suitable univariate spray or its number of real roots in a given
interval. This can be very slow if the degree of the spray is not small.
interval. This can be very slow if the degree of the spray is not small.


## 0.5.3.0 - 2024-05-XX

* Now the denominator of a `RatioOfSprays` is always monic, i.e. it is a
polynomial whose leading coefficient is 1.
2 changes: 1 addition & 1 deletion hspray.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hspray
version: 0.5.2.0
version: 0.5.3.0
synopsis: Multivariate polynomials and fractions of multivariate polynomials.
description: Manipulation of multivariate polynomials over a commutative ring and fractions of multivariate polynomials over a commutative field, Gröbner bases, resultant, subresultants, Sturm-Habicht sequence, and greatest common divisor. It is possible to deal with multivariate polynomials whose coefficients are fractions of multivariate polynomials, and they can be interpreted as parametric polynomials with symbolic parameters.
homepage: https://github.com/stla/hspray#readme
Expand Down
13 changes: 6 additions & 7 deletions src/Math/Algebra/Hspray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2277,7 +2277,7 @@ psPolynomial n k
| k < 0 || n < 0
= error "psPolynomial: both arguments must be positive integers."
| k > n = AlgAdd.zero
| k == 0 = n .^ unitSpray
| k == 0 = unitSpray
| otherwise = spray
where
spray = HM.fromList $ map f [1 .. n]
Expand Down Expand Up @@ -3223,12 +3223,11 @@ quotientsByGCD sprayA sprayB =
exactDivision p q = fst (sprayDivision0 p q)
g = gcdSpray sprayA sprayB
go oldr r olds s oldt t
| isZeroSpray r = (c *^ AlgAdd.negate t, c *^ s) -- monic denominator
| isZeroSpray r = (AlgAdd.negate t, s)
| otherwise =
go r remainder s (olds ^-^ quo ^*^ s) t (oldt ^-^ quo ^*^ t)
where
(quo, remainder) = univariateSprayDivision oldr r
c = AlgField.recip (snd $ leadingTerm s)

-- | irreducible fraction of sprays
irreducibleFraction ::
Expand All @@ -3239,11 +3238,11 @@ irreducibleFraction p q = adjustFraction rOS
then RatioOfSprays p q
else let (a, b) = quotientsByGCD p q in RatioOfSprays a b

-- | set denominator to 1 if it is constant
-- | make monic denominator
adjustFraction :: (Eq a, AlgField.C a) => RatioOfSprays a -> RatioOfSprays a
adjustFraction (RatioOfSprays p q) = if isConstant q
then RatioOfSprays (p /^ getConstantTerm q) unitSpray
else RatioOfSprays p q
adjustFraction (RatioOfSprays p q) =
let leadingCoeff = snd $ leadingTerm q in
RatioOfSprays (p /^ leadingCoeff) (q /^ leadingCoeff)

instance (AlgRing.C a, Eq a) => Eq (RatioOfSprays a) where
(==) :: RatioOfSprays a -> RatioOfSprays a -> Bool
Expand Down

0 comments on commit 18828ff

Please sign in to comment.