-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Polynomials -- -- A type to represent polynomials with Num and Semiring instances. @package poly @version 0.1.0.0 -- | Polynomials. module Data.Poly -- | Polynomials of one variable. -- --
-- >>> :set -XOverloadedLists
--
-- >>> -- (1 + x) * (-1 + x) = (-1 + x^2)
--
-- >>> toPoly [1,1] * toPoly [-1,1]
-- Poly {unPoly = [-1,0,1]}
--
--
--
-- >>> :set -XOverloadedLists
--
-- >>> -- (1 + x) + (1 - x) = 2
--
-- >>> toPoly [1,1] + toPoly [1,-1]
-- Poly {unPoly = [2]}
--
data Poly a
-- | Convert Poly to a vector of coefficients (first element
-- corresponds to a constant term).
unPoly :: Poly a -> Vector a
-- | Make Poly from a list of coefficients (first element
-- corresponds to a constant term).
--
--
-- >>> :set -XOverloadedLists
--
-- >>> toPoly [1,2,3]
-- Poly {unPoly = [1,2,3]}
--
--
--
-- >>> :set -XOverloadedLists
--
-- >>> toPoly [0,0,0]
-- Poly {unPoly = []}
--
toPoly :: (Eq a, Num a) => Vector a -> Poly a
-- | Make Poly from a vector of coefficients (first element
-- corresponds to a constant term).
--
--
-- >>> :set -XOverloadedLists
--
-- >>> toPoly' [1,2,3]
-- Poly {unPoly = [1,2,3]}
--
--
--
-- >>> :set -XOverloadedLists
--
-- >>> toPoly' [0,0,0]
-- Poly {unPoly = []}
--
toPoly' :: (Eq a, Semiring a) => Vector a -> Poly a