Skip to content

Commit

Permalink
RightModule instances
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Apr 22, 2024
1 parent a518e1a commit ffce79e
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/Math/Algebra/Hspray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -509,20 +509,48 @@ instance (Eq a, AlgField.C a) => AlgZT.C (A a) where

instance (Eq a, AlgField.C a) => AlgMod.C (A a) (RatioOfPolynomials a) where
(*>) :: A a -> RatioOfPolynomials a -> RatioOfPolynomials a
r *> rop = NumberRatio.scale (MathPol.const r) rop
lambda *> rop = NumberRatio.scale (MathPol.const lambda) rop

instance (Eq a, AlgField.C a) => AlgRightMod.C (A a) (RatioOfPolynomials a) where
(<*) :: RatioOfPolynomials a -> A a -> RatioOfPolynomials a
rop <* lambda = lambda AlgMod.*> rop

instance (Eq a, AlgField.C a) => AlgMod.C a (RatioOfPolynomials a) where
(*>) :: a -> RatioOfPolynomials a -> RatioOfPolynomials a
lambda *> rop = A lambda AlgMod.*> rop

instance (Eq a, AlgField.C a) => AlgRightMod.C a (RatioOfPolynomials a) where
(<*) :: RatioOfPolynomials a -> a -> RatioOfPolynomials a
rop <* lambda = lambda AlgMod.*> rop

instance (Eq a, AlgField.C a) => AlgMod.C (Polynomial a) (RatioOfPolynomials a) where
(*>) :: Polynomial a -> RatioOfPolynomials a -> RatioOfPolynomials a
p *> r = NumberRatio.scale p r

instance (Eq a, AlgField.C a) => AlgRightMod.C (Polynomial a) (RatioOfPolynomials a) where
(<*) :: RatioOfPolynomials a -> Polynomial a -> RatioOfPolynomials a
r <* p = p AlgMod.*> r

instance (Eq a, AlgField.C a) => AlgMod.C (Polynomial a) (OneParameterSpray a) where
(*>) :: Polynomial a -> OneParameterSpray a -> OneParameterSpray a
p *> r = constantSpray (p NumberRatio.:% AlgRing.one) ^*^ r
p *> spray = (p NumberRatio.:% AlgRing.one) *^ spray

instance (Eq a, AlgField.C a) => AlgRightMod.C (Polynomial a) (OneParameterSpray a) where
(<*) :: OneParameterSpray a -> Polynomial a -> OneParameterSpray a
spray <* p = p AlgMod.*> spray

instance (Eq a, AlgField.C a) => AlgMod.C a (OneParameterSpray a) where
(*>) :: a -> OneParameterSpray a -> OneParameterSpray a
lambda *> spray = MathPol.const (A lambda) AlgMod.*> spray

instance (Eq a, AlgField.C a) => AlgRightMod.C a (OneParameterSpray a) where
(<*) :: OneParameterSpray a -> a -> OneParameterSpray a
lambda <* p = p AlgMod.*> lambda

infixr 7 *.
-- | Scale a ratio of univariate polynomials by a scalar
(*.) :: (Eq a, AlgField.C a) => a -> RatioOfPolynomials a -> RatioOfPolynomials a
(*.) scalar rop = A scalar AlgMod.*> rop
(*.) lambda rop = A lambda AlgMod.*> rop

-- | Constant univariate polynomial
constPoly :: a -> Polynomial a
Expand Down

0 comments on commit ffce79e

Please sign in to comment.