-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Polynomials -- -- Polynomials backed by Vector. @package poly @version 0.4.0.0 -- | Dense polynomials and a Num-based interface. module Data.Poly -- | Polynomials of one variable with coefficients from a, backed -- by a Vector v (boxed, unboxed, storable, etc.). -- -- Use pattern X for construction: -- --
--   >>> (X + 1) + (X - 1) :: VPoly Integer
--   2 * X + 0
--   
--   >>> (X + 1) * (X - 1) :: UPoly Int
--   1 * X^2 + 0 * X + (-1)
--   
-- -- Polynomials are stored normalized, without leading zero coefficients, -- so 0 * X + 1 equals to 1. -- -- Ord instance does not make much sense mathematically, it is -- defined only for the sake of Set, Map, etc. data Poly v a -- | Polynomials backed by boxed vectors. type VPoly = Poly Vector -- | Polynomials backed by unboxed vectors. type UPoly = Poly Vector -- | Convert Poly to a vector of coefficients (first element -- corresponds to a constant term). unPoly :: Poly v a -> v a -- | Return a leading power and coefficient of a non-zero polynomial. -- --
--   >>> leading ((2 * X + 1) * (2 * X^2 - 1) :: UPoly Int)
--   Just (3,4)
--   
--   >>> leading (0 :: UPoly Int)
--   Nothing
--   
leading :: Vector v a => Poly v a -> Maybe (Word, a) -- | Make Poly from a list of coefficients (first element -- corresponds to a constant term). -- --
--   >>> :set -XOverloadedLists
--   
--   >>> toPoly [1,2,3] :: VPoly Integer
--   3 * X^2 + 2 * X + 1
--   
--   >>> toPoly [0,0,0] :: UPoly Int
--   0
--   
toPoly :: (Eq a, Num a, Vector v a) => v a -> Poly v a -- | Create a monomial from a power and a coefficient. monomial :: (Eq a, Num a, Vector v a) => Word -> a -> Poly v a -- | Multiply a polynomial by a monomial, expressed as a power and a -- coefficient. -- --
--   >>> scale 2 3 (X^2 + 1) :: UPoly Int
--   3 * X^4 + 0 * X^3 + 3 * X^2 + 0 * X + 0
--   
scale :: (Eq a, Num a, Vector v a) => Word -> a -> Poly v a -> Poly v a -- | Create an identity polynomial. pattern X :: (Eq a, Num a, Vector v a, Eq (v a)) => Poly v a -- | Evaluate at a given point. -- --
--   >>> eval (X^2 + 1 :: UPoly Int) 3
--   10
--   
eval :: (Num a, Vector v a) => Poly v a -> a -> a -- | Substitute another polynomial instead of X. -- --
--   >>> subst (X^2 + 1 :: UPoly Int) (X + 1 :: UPoly Int)
--   1 * X^2 + 2 * X + 2
--   
subst :: (Eq a, Num a, Vector v a, Vector w a) => Poly v a -> Poly w a -> Poly w a -- | Take a derivative. -- --
--   >>> deriv (X^3 + 3 * X) :: UPoly Int
--   3 * X^2 + 0 * X + 3
--   
deriv :: (Eq a, Num a, Vector v a) => Poly v a -> Poly v a -- | Compute an indefinite integral of a polynomial, setting constant term -- to zero. -- --
--   >>> integral (3 * X^2 + 3) :: UPoly Double
--   1.0 * X^3 + 0.0 * X^2 + 3.0 * X + 0.0
--   
integral :: (Eq a, Fractional a, Vector v a) => Poly v a -> Poly v a -- | Wrapper for polynomials over Field, providing a faster -- GcdDomain instance. newtype PolyOverField poly PolyOverField :: poly -> PolyOverField poly [unPolyOverField] :: PolyOverField poly -> poly -- | Laurent polynomials. module Data.Poly.Laurent -- | Laurent polynomials of one variable with coefficients from -- a, backed by a Vector v (boxed, unboxed, -- storable, etc.). -- -- Use pattern X and operator ^- for construction: -- --
--   >>> (X + 1) + (X^-1 - 1) :: VLaurent Integer
--   1 * X + 0 + 1 * X^-1
--   
--   >>> (X + 1) * (1 - X^-1) :: ULaurent Int
--   1 * X + 0 + (-1) * X^-1
--   
-- -- Polynomials are stored normalized, without leading and trailing zero -- coefficients, so 0 * X + 1 + 0 * X^-1 equals to 1. -- -- Ord instance does not make much sense mathematically, it is -- defined only for the sake of Set, Map, etc. data Laurent v a -- | Laurent polynomials backed by boxed vectors. type VLaurent = Laurent Vector -- | Laurent polynomials backed by unboxed vectors. type ULaurent = Laurent Vector -- | Deconstruct a Laurent polynomial into an offset (largest -- possible) and a regular polynomial. -- --
--   >>> unLaurent (2 * X + 1 :: ULaurent Int)
--   (0,2 * X + 1)
--   
--   >>> unLaurent (1 + 2 * X^-1 :: ULaurent Int)
--   (-1,1 * X + 2)
--   
--   >>> unLaurent (2 * X^2 + X :: ULaurent Int)
--   (1,2 * X + 1)
--   
--   >>> unLaurent (0 :: ULaurent Int)
--   (0,0)
--   
unLaurent :: Laurent v a -> (Int, Poly v a) -- | Construct Laurent polynomial from an offset and a regular -- polynomial. One can imagine it as scale', but allowing negative -- offsets. -- --
--   >>> toLaurent 2 (2 * Data.Poly.X + 1) :: ULaurent Int
--   2 * X^3 + 1 * X^2
--   
--   >>> toLaurent (-2) (2 * Data.Poly.X + 1) :: ULaurent Int
--   2 * X^-1 + 1 * X^-2
--   
toLaurent :: (Eq a, Semiring a, Vector v a) => Int -> Poly v a -> Laurent v a -- | Return a leading power and coefficient of a non-zero polynomial. -- --
--   >>> leading ((2 * X + 1) * (2 * X^2 - 1) :: ULaurent Int)
--   Just (3,4)
--   
--   >>> leading (0 :: ULaurent Int)
--   Nothing
--   
leading :: Vector v a => Laurent v a -> Maybe (Int, a) -- | Create a monomial from a power and a coefficient. monomial :: (Eq a, Semiring a, Vector v a) => Int -> a -> Laurent v a -- | Multiply a polynomial by a monomial, expressed as a power and a -- coefficient. -- --
--   >>> scale 2 3 (X^2 + 1) :: ULaurent Int
--   3 * X^4 + 0 * X^3 + 3 * X^2 + 0 * X + 0
--   
scale :: (Eq a, Semiring a, Vector v a) => Int -> a -> Laurent v a -> Laurent v a -- | Create an identity polynomial. pattern X :: (Eq a, Semiring a, Vector v a, Eq (v a)) => Laurent v a -- | This operator can be applied only to X, but is instrumental to -- express Laurent polynomials in mathematical fashion: -- --
--   >>> X + 2 + 3 * X^-1 :: ULaurent Int
--   1 * X + 2 + 3 * X^(-1)
--   
(^-) :: (Eq a, Semiring a, Vector v a, Eq (v a)) => Laurent v a -> Int -> Laurent v a -- | Evaluate at a given point. -- --
--   >>> eval (X^2 + 1 :: ULaurent Int) 3
--   10
--   
eval :: (Field a, Vector v a) => Laurent v a -> a -> a -- | Substitute another polynomial instead of X. -- --
--   >>> subst (X^2 + 1 :: UPoly Int) (X + 1 :: ULaurent Int)
--   1 * X^2 + 2 * X + 2
--   
subst :: (Eq a, Semiring a, Vector v a, Vector w a) => Poly v a -> Laurent w a -> Laurent w a -- | Take a derivative. -- --
--   >>> deriv (X^3 + 3 * X) :: ULaurent Int
--   3 * X^2 + 0 * X + 3
--   
deriv :: (Eq a, Ring a, Vector v a) => Laurent v a -> Laurent v a -- | Wrapper for Laurent polynomials over Field, providing a faster -- GcdDomain instance. newtype LaurentOverField laurent LaurentOverField :: laurent -> LaurentOverField laurent [unLaurentOverField] :: LaurentOverField laurent -> laurent instance GHC.Show.Show laurent => GHC.Show.Show (Data.Poly.Laurent.LaurentOverField laurent) instance Data.Semiring.Semiring laurent => Data.Semiring.Semiring (Data.Poly.Laurent.LaurentOverField laurent) instance Data.Semiring.Ring laurent => Data.Semiring.Ring (Data.Poly.Laurent.LaurentOverField laurent) instance GHC.Classes.Ord laurent => GHC.Classes.Ord (Data.Poly.Laurent.LaurentOverField laurent) instance GHC.Num.Num laurent => GHC.Num.Num (Data.Poly.Laurent.LaurentOverField laurent) instance Control.DeepSeq.NFData laurent => Control.DeepSeq.NFData (Data.Poly.Laurent.LaurentOverField laurent) instance GHC.Classes.Eq laurent => GHC.Classes.Eq (Data.Poly.Laurent.LaurentOverField laurent) instance GHC.Classes.Ord (v a) => GHC.Classes.Ord (Data.Poly.Laurent.Laurent v a) instance GHC.Classes.Eq (v a) => GHC.Classes.Eq (Data.Poly.Laurent.Laurent v a) instance (GHC.Classes.Eq a, GHC.Classes.Eq (v a), Data.Euclidean.Field a, Data.Vector.Generic.Base.Vector v a) => Data.Euclidean.GcdDomain (Data.Poly.Laurent.LaurentOverField (Data.Poly.Laurent.Laurent v a)) instance Control.DeepSeq.NFData (v a) => Control.DeepSeq.NFData (Data.Poly.Laurent.Laurent v a) instance (GHC.Show.Show a, Data.Vector.Generic.Base.Vector v a) => GHC.Show.Show (Data.Poly.Laurent.Laurent v a) instance (GHC.Classes.Eq a, GHC.Num.Num a, Data.Vector.Generic.Base.Vector v a) => GHC.Num.Num (Data.Poly.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Semiring a, Data.Vector.Generic.Base.Vector v a) => Data.Semiring.Semiring (Data.Poly.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Ring a, Data.Vector.Generic.Base.Vector v a) => Data.Semiring.Ring (Data.Poly.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Ring a, Data.Euclidean.GcdDomain a, GHC.Classes.Eq (v a), Data.Vector.Generic.Base.Vector v a) => Data.Euclidean.GcdDomain (Data.Poly.Laurent.Laurent v a) -- | Dense polynomials and a Semiring-based interface. module Data.Poly.Semiring -- | Polynomials of one variable with coefficients from a, backed -- by a Vector v (boxed, unboxed, storable, etc.). -- -- Use pattern X for construction: -- --
--   >>> (X + 1) + (X - 1) :: VPoly Integer
--   2 * X + 0
--   
--   >>> (X + 1) * (X - 1) :: UPoly Int
--   1 * X^2 + 0 * X + (-1)
--   
-- -- Polynomials are stored normalized, without leading zero coefficients, -- so 0 * X + 1 equals to 1. -- -- Ord instance does not make much sense mathematically, it is -- defined only for the sake of Set, Map, etc. data Poly v a -- | Polynomials backed by boxed vectors. type VPoly = Poly Vector -- | Polynomials backed by unboxed vectors. type UPoly = Poly Vector -- | Convert Poly to a vector of coefficients (first element -- corresponds to a constant term). unPoly :: Poly v a -> v a -- | Return a leading power and coefficient of a non-zero polynomial. -- --
--   >>> leading ((2 * X + 1) * (2 * X^2 - 1) :: UPoly Int)
--   Just (3,4)
--   
--   >>> leading (0 :: UPoly Int)
--   Nothing
--   
leading :: Vector v a => Poly v a -> Maybe (Word, a) -- | Make Poly from a vector of coefficients (first element -- corresponds to a constant term). -- --
--   >>> :set -XOverloadedLists
--   
--   >>> toPoly [1,2,3] :: VPoly Integer
--   3 * X^2 + 2 * X + 1
--   
--   >>> toPoly [0,0,0] :: UPoly Int
--   0
--   
toPoly :: (Eq a, Semiring a, Vector v a) => v a -> Poly v a -- | Create a monomial from a power and a coefficient. monomial :: (Eq a, Semiring a, Vector v a) => Word -> a -> Poly v a -- | Multiply a polynomial by a monomial, expressed as a power and a -- coefficient. -- --
--   >>> scale 2 3 (X^2 + 1) :: UPoly Int
--   3 * X^4 + 0 * X^3 + 3 * X^2 + 0 * X + 0
--   
scale :: (Eq a, Semiring a, Vector v a) => Word -> a -> Poly v a -> Poly v a -- | Create an identity polynomial. pattern X :: (Eq a, Semiring a, Vector v a, Eq (v a)) => Poly v a -- | Evaluate at a given point. -- --
--   >>> eval (X^2 + 1 :: UPoly Int) 3
--   10
--   
eval :: (Semiring a, Vector v a) => Poly v a -> a -> a -- | Substitute another polynomial instead of X. -- --
--   >>> subst (X^2 + 1 :: UPoly Int) (X + 1 :: UPoly Int)
--   1 * X^2 + 2 * X + 2
--   
subst :: (Eq a, Semiring a, Vector v a, Vector w a) => Poly v a -> Poly w a -> Poly w a -- | Take a derivative. -- --
--   >>> deriv (X^3 + 3 * X) :: UPoly Int
--   3 * X^2 + 0 * X + 3
--   
deriv :: (Eq a, Semiring a, Vector v a) => Poly v a -> Poly v a -- | Compute an indefinite integral of a polynomial, setting constant term -- to zero. -- --
--   >>> integral (3 * X^2 + 3) :: UPoly Double
--   1.0 * X^3 + 0.0 * X^2 + 3.0 * X + 0.0
--   
integral :: (Eq a, Field a, Vector v a) => Poly v a -> Poly v a -- | Wrapper for polynomials over Field, providing a faster -- GcdDomain instance. newtype PolyOverField poly PolyOverField :: poly -> PolyOverField poly [unPolyOverField] :: PolyOverField poly -> poly -- | Classical orthogonal polynomials. module Data.Poly.Orthogonal -- | Legendre polynomials. -- --
--   >>> take 3 legendre :: [Data.Poly.VPoly Double]
--   [1.0,1.0 * X + 0.0,1.5 * X^2 + 0.0 * X + (-0.5)]
--   
legendre :: (Eq a, Field a, Vector v a) => [Poly v a] -- | Shifted Legendre polynomials. -- --
--   >>> take 3 legendreShifted :: [Data.Poly.VPoly Integer]
--   [1,2 * X + (-1),6 * X^2 + (-6) * X + 1]
--   
legendreShifted :: (Eq a, Euclidean a, Ring a, Vector v a) => [Poly v a] -- | Gegenbauer polynomials. gegenbauer :: (Eq a, Field a, Vector v a) => a -> [Poly v a] -- | Jacobi polynomials. jacobi :: (Eq a, Field a, Vector v a) => a -> a -> [Poly v a] -- | Chebyshev polynomials of the first kind. -- --
--   >>> take 3 chebyshev1 :: [VPoly Integer]
--   [1,1 * X + 0,2 * X^2 + 0 * X + (-1)]
--   
chebyshev1 :: (Eq a, Ring a, Vector v a) => [Poly v a] -- | Chebyshev polynomials of the second kind. -- --
--   >>> take 3 chebyshev2 :: [VPoly Integer]
--   [1,2 * X + 0,4 * X^2 + 0 * X + (-1)]
--   
chebyshev2 :: (Eq a, Ring a, Vector v a) => [Poly v a] -- | Probabilists' Hermite polynomials. -- --
--   >>> take 3 hermiteProb :: [VPoly Integer]
--   [1,1 * X + 0,1 * X^2 + 0 * X + (-1)]
--   
hermiteProb :: (Eq a, Ring a, Vector v a) => [Poly v a] -- | Physicists' Hermite polynomials. -- --
--   >>> take 3 hermitePhys :: [VPoly Double]
--   [1,2 * X + 0,4 * X^2 + 0 * X + (-2)]
--   
hermitePhys :: (Eq a, Ring a, Vector v a) => [Poly v a] -- | Laguerre polynomials. -- --
--   >>> take 3 laguerre :: [VPoly Double]
--   [1.0,(-1.0) * X + 1.0,0.5 * X^2 + (-2.0) * X + 1.0]
--   
laguerre :: (Eq a, Field a, Vector v a) => [Poly v a] -- | Generalized Laguerre polynomials laguerreGen :: (Eq a, Field a, Vector v a) => a -> [Poly v a] -- | Sparse polynomials with Num instance. module Data.Poly.Sparse -- | Polynomials of one variable with coefficients from a, backed -- by a Vector v (boxed, unboxed, storable, etc.). -- -- Use pattern X for construction: -- --
--   >>> (X + 1) + (X - 1) :: VPoly Integer
--   2 * X
--   
--   >>> (X + 1) * (X - 1) :: UPoly Int
--   1 * X^2 + (-1)
--   
-- -- Polynomials are stored normalized, without zero coefficients, so 0 * -- X + 1 equals to 1. -- -- Ord instance does not make much sense mathematically, it is -- defined only for the sake of Set, Map, etc. data Poly v a -- | Polynomials backed by boxed vectors. type VPoly = Poly Vector -- | Polynomials backed by unboxed vectors. type UPoly = Poly Vector -- | Convert Poly to a vector of coefficients (first element -- corresponds to a constant term). unPoly :: Poly v a -> v (Word, a) -- | Return a leading power and coefficient of a non-zero polynomial. -- --
--   >>> leading ((2 * X + 1) * (2 * X^2 - 1) :: UPoly Int)
--   Just (3,4)
--   
--   >>> leading (0 :: UPoly Int)
--   Nothing
--   
leading :: Vector v (Word, a) => Poly v a -> Maybe (Word, a) -- | Make Poly from a list of (power, coefficient) pairs. (first -- element corresponds to a constant term). -- --
--   >>> :set -XOverloadedLists
--   
--   >>> toPoly [(0,1),(1,2),(2,3)] :: VPoly Integer
--   3 * X^2 + 2 * X + 1
--   
--   >>> S.toPoly [(0,0),(1,0),(2,0)] :: UPoly Int
--   0
--   
toPoly :: (Eq a, Num a, Vector v (Word, a)) => v (Word, a) -> Poly v a -- | Create a monomial from a power and a coefficient. monomial :: (Eq a, Num a, Vector v (Word, a)) => Word -> a -> Poly v a -- | Multiply a polynomial by a monomial, expressed as a power and a -- coefficient. -- --
--   >>> scale 2 3 (X^2 + 1) :: UPoly Int
--   3 * X^4 + 3 * X^2
--   
scale :: (Eq a, Num a, Vector v (Word, a)) => Word -> a -> Poly v a -> Poly v a -- | Create an identity polynomial. pattern X :: (Eq a, Num a, Vector v (Word, a), Eq (v (Word, a))) => Poly v a -- | Evaluate at a given point. -- --
--   >>> eval (X^2 + 1 :: UPoly Int) 3
--   10
--   
eval :: (Num a, Vector v (Word, a)) => Poly v a -> a -> a -- | Substitute another polynomial instead of X. -- --
--   >>> subst (X^2 + 1 :: UPoly Int) (X + 1 :: UPoly Int)
--   1 * X^2 + 2 * X + 2
--   
subst :: (Eq a, Num a, Vector v (Word, a), Vector w (Word, a)) => Poly v a -> Poly w a -> Poly w a -- | Take a derivative. -- --
--   >>> deriv (X^3 + 3 * X) :: UPoly Int
--   3 * X^2 + 3
--   
deriv :: (Eq a, Num a, Vector v (Word, a)) => Poly v a -> Poly v a -- | Compute an indefinite integral of a polynomial, setting constant term -- to zero. -- --
--   >>> integral (3 * X^2 + 3) :: UPoly Double
--   1.0 * X^3 + 3.0 * X
--   
integral :: (Eq a, Fractional a, Vector v (Word, a)) => Poly v a -> Poly v a -- | Sparse Laurent polynomials. module Data.Poly.Sparse.Laurent -- | Laurent polynomials of one variable with coefficients from -- a, backed by a Vector v (boxed, unboxed, -- storable, etc.). -- -- Use pattern X and operator ^- for construction: -- --
--   >>> (X + 1) + (X^-1 - 1) :: VLaurent Integer
--   1 * X + 1 * X^-1
--   
--   >>> (X + 1) * (1 - X^-1) :: ULaurent Int
--   1 * X + (-1) * X^-1
--   
-- -- Polynomials are stored normalized, without zero coefficients, so 0 * X -- + 1 + 0 * X^-1 equals to 1. -- -- Ord instance does not make much sense mathematically, it is -- defined only for the sake of Set, Map, etc. data Laurent v a -- | Laurent polynomials backed by boxed vectors. type VLaurent = Laurent Vector -- | Laurent polynomials backed by unboxed vectors. type ULaurent = Laurent Vector -- | Deconstruct a Laurent polynomial into an offset (largest -- possible) and a regular polynomial. -- --
--   >>> unLaurent (2 * X + 1 :: ULaurent Int)
--   (0,2 * X + 1)
--   
--   >>> unLaurent (1 + 2 * X^-1 :: ULaurent Int)
--   (-1,1 * X + 2)
--   
--   >>> unLaurent (2 * X^2 + X :: ULaurent Int)
--   (1,2 * X + 1)
--   
--   >>> unLaurent (0 :: ULaurent Int)
--   (0,0)
--   
unLaurent :: Laurent v a -> (Int, Poly v a) -- | Construct Laurent polynomial from an offset and a regular -- polynomial. One can imagine it as scale', but allowing negative -- offsets. -- --
--   >>> toLaurent 2 (2 * Data.Poly.Sparse.X + 1) :: ULaurent Int
--   2 * X^3 + 1 * X^2
--   
--   >>> toLaurent (-2) (2 * Data.Poly.Sparse.X + 1) :: ULaurent Int
--   2 * X^-1 + 1 * X^-2
--   
toLaurent :: (Eq a, Semiring a, Vector v (Word, a)) => Int -> Poly v a -> Laurent v a -- | Return a leading power and coefficient of a non-zero polynomial. -- --
--   >>> leading ((2 * X + 1) * (2 * X^2 - 1) :: ULaurent Int)
--   Just (3,4)
--   
--   >>> leading (0 :: ULaurent Int)
--   Nothing
--   
leading :: Vector v (Word, a) => Laurent v a -> Maybe (Int, a) -- | Create a monomial from a power and a coefficient. monomial :: (Eq a, Semiring a, Vector v (Word, a)) => Int -> a -> Laurent v a -- | Multiply a polynomial by a monomial, expressed as a power and a -- coefficient. -- --
--   >>> scale 2 3 (X^2 + 1) :: ULaurent Int
--   3 * X^4 + 3 * X^2
--   
scale :: (Eq a, Semiring a, Vector v (Word, a)) => Int -> a -> Laurent v a -> Laurent v a -- | Create an identity polynomial. pattern X :: (Eq a, Semiring a, Vector v (Word, a), Eq (v (Word, a))) => Laurent v a -- | This operator can be applied only to X, but is instrumental to -- express Laurent polynomials in mathematical fashion: -- --
--   >>> X + 2 + 3 * X^-1 :: ULaurent Int
--   1 * X + 2 + 3 * X^(-1)
--   
(^-) :: (Eq a, Semiring a, Vector v (Word, a), Eq (v (Word, a))) => Laurent v a -> Int -> Laurent v a -- | Evaluate at a given point. -- --
--   >>> eval (X^2 + 1 :: ULaurent Int) 3
--   10
--   
eval :: (Field a, Vector v (Word, a)) => Laurent v a -> a -> a -- | Substitute another polynomial instead of X. -- --
--   >>> subst (X^2 + 1 :: UPoly Int) (X + 1 :: ULaurent Int)
--   1 * X^2 + 2 * X + 2
--   
subst :: (Eq a, Semiring a, Vector v (Word, a), Vector w (Word, a)) => Poly v a -> Laurent w a -> Laurent w a -- | Take a derivative. -- --
--   >>> deriv (X^3 + 3 * X) :: ULaurent Int
--   3 * X^2 + 3
--   
deriv :: (Eq a, Ring a, Vector v (Word, a)) => Laurent v a -> Laurent v a instance GHC.Classes.Eq (v (GHC.Types.Word, a)) => GHC.Classes.Eq (Data.Poly.Sparse.Laurent.Laurent v a) instance GHC.Classes.Ord (v (GHC.Types.Word, a)) => GHC.Classes.Ord (Data.Poly.Sparse.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Semiring a, Data.Vector.Generic.Base.Vector v (GHC.Types.Word, a)) => GHC.Exts.IsList (Data.Poly.Sparse.Laurent.Laurent v a) instance Control.DeepSeq.NFData (v (GHC.Types.Word, a)) => Control.DeepSeq.NFData (Data.Poly.Sparse.Laurent.Laurent v a) instance (GHC.Show.Show a, Data.Vector.Generic.Base.Vector v (GHC.Types.Word, a)) => GHC.Show.Show (Data.Poly.Sparse.Laurent.Laurent v a) instance (GHC.Classes.Eq a, GHC.Num.Num a, Data.Vector.Generic.Base.Vector v (GHC.Types.Word, a)) => GHC.Num.Num (Data.Poly.Sparse.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Semiring a, Data.Vector.Generic.Base.Vector v (GHC.Types.Word, a)) => Data.Semiring.Semiring (Data.Poly.Sparse.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Ring a, Data.Vector.Generic.Base.Vector v (GHC.Types.Word, a)) => Data.Semiring.Ring (Data.Poly.Sparse.Laurent.Laurent v a) instance (GHC.Classes.Eq a, Data.Semiring.Ring a, Data.Euclidean.GcdDomain a, GHC.Classes.Eq (v (GHC.Types.Word, a)), Data.Vector.Generic.Base.Vector v (GHC.Types.Word, a)) => Data.Euclidean.GcdDomain (Data.Poly.Sparse.Laurent.Laurent v a) -- | Sparse polynomials with Semiring instance. module Data.Poly.Sparse.Semiring -- | Polynomials of one variable with coefficients from a, backed -- by a Vector v (boxed, unboxed, storable, etc.). -- -- Use pattern X for construction: -- --
--   >>> (X + 1) + (X - 1) :: VPoly Integer
--   2 * X
--   
--   >>> (X + 1) * (X - 1) :: UPoly Int
--   1 * X^2 + (-1)
--   
-- -- Polynomials are stored normalized, without zero coefficients, so 0 * -- X + 1 equals to 1. -- -- Ord instance does not make much sense mathematically, it is -- defined only for the sake of Set, Map, etc. data Poly v a -- | Polynomials backed by boxed vectors. type VPoly = Poly Vector -- | Polynomials backed by unboxed vectors. type UPoly = Poly Vector -- | Convert Poly to a vector of coefficients (first element -- corresponds to a constant term). unPoly :: Poly v a -> v (Word, a) -- | Return a leading power and coefficient of a non-zero polynomial. -- --
--   >>> leading ((2 * X + 1) * (2 * X^2 - 1) :: UPoly Int)
--   Just (3,4)
--   
--   >>> leading (0 :: UPoly Int)
--   Nothing
--   
leading :: Vector v (Word, a) => Poly v a -> Maybe (Word, a) -- | Make Poly from a list of (power, coefficient) pairs. (first -- element corresponds to a constant term). -- --
--   >>> :set -XOverloadedLists
--   
--   >>> toPoly [(0,1),(1,2),(2,3)] :: VPoly Integer
--   3 * X^2 + 2 * X + 1
--   
--   >>> S.toPoly [(0,0),(1,0),(2,0)] :: UPoly Int
--   0
--   
toPoly :: (Eq a, Semiring a, Vector v (Word, a)) => v (Word, a) -> Poly v a -- | Create a monomial from a power and a coefficient. monomial :: (Eq a, Semiring a, Vector v (Word, a)) => Word -> a -> Poly v a -- | Multiply a polynomial by a monomial, expressed as a power and a -- coefficient. -- --
--   >>> scale 2 3 (X^2 + 1) :: UPoly Int
--   3 * X^4 + 3 * X^2
--   
scale :: (Eq a, Semiring a, Vector v (Word, a)) => Word -> a -> Poly v a -> Poly v a -- | Create an identity polynomial. pattern X :: (Eq a, Semiring a, Vector v (Word, a), Eq (v (Word, a))) => Poly v a -- | Evaluate at a given point. -- --
--   >>> eval (X^2 + 1 :: UPoly Int) 3
--   10
--   
eval :: (Semiring a, Vector v (Word, a)) => Poly v a -> a -> a -- | Substitute another polynomial instead of X. -- --
--   >>> subst (X^2 + 1 :: UPoly Int) (X + 1 :: UPoly Int)
--   1 * X^2 + 2 * X + 2
--   
subst :: (Eq a, Semiring a, Vector v (Word, a), Vector w (Word, a)) => Poly v a -> Poly w a -> Poly w a -- | Take a derivative. -- --
--   >>> deriv (X^3 + 3 * X) :: UPoly Int
--   3 * X^2 + 3
--   
deriv :: (Eq a, Semiring a, Vector v (Word, a)) => Poly v a -> Poly v a -- | Compute an indefinite integral of a polynomial, setting constant term -- to zero. -- --
--   >>> integral (3 * X^2 + 3) :: UPoly Double
--   1.0 * X^3 + 3.0 * X
--   
integral :: (Eq a, Field a, Vector v (Word, a)) => Poly v a -> Poly v a