Portability | non-portable (ScopedTypeVariables, TypeFamilies, BangPatterns, DeriveDataTypeable) |
---|---|
Stability | provisional |
Maintainer | masahiro.sakai@gmail.com |
Safe Haskell | None |
Polynomials
References:
- Monomial order http://en.wikipedia.org/wiki/Monomial_order
- Polynomial class for Ruby http://www.math.kobe-u.ac.jp/~kodama/tips-RubyPoly.html
- constructive-algebra package http://hackage.haskell.org/package/constructive-algebra
- data Polynomial k v
- type UPolynomial r = Polynomial r X
- data X = X
- class Variables f where
- constant :: (Eq k, Num k, Ord v) => k -> Polynomial k v
- terms :: Polynomial k v -> [Monomial k v]
- fromTerms :: (Eq k, Num k, Ord v) => [Monomial k v] -> Polynomial k v
- coeffMap :: Polynomial k v -> Map (MonicMonomial v) k
- fromCoeffMap :: (Eq k, Num k, Ord v) => Map (MonicMonomial v) k -> Polynomial k v
- fromMonomial :: (Eq k, Num k, Ord v) => Monomial k v -> Polynomial k v
- class Degree t where
- leadingTerm :: (Eq k, Num k, Ord v) => MonomialOrder v -> Polynomial k v -> Monomial k v
- coeff :: (Num k, Ord v) => MonicMonomial v -> Polynomial k v -> k
- lookupCoeff :: Ord v => MonicMonomial v -> Polynomial k v -> Maybe k
- isPrimitive :: (Eq k, Num k, ContPP k, Ord v) => Polynomial k v -> Bool
- class ContPP k where
- cont :: Ord v => Polynomial k v -> k
- pp :: Ord v => Polynomial k v -> Polynomial k v
- deriv :: (Eq k, Num k, Ord v) => Polynomial k v -> v -> Polynomial k v
- integral :: (Eq k, Fractional k, Ord v) => Polynomial k v -> v -> Polynomial k v
- eval :: (Num k, Ord v) => (v -> k) -> Polynomial k v -> k
- evalA :: forall k v f. (Num k, Ord v, Applicative f) => (v -> f k) -> Polynomial k v -> f k
- evalM :: (Num k, Ord v, Monad m) => (v -> m k) -> Polynomial k v -> m k
- subst :: (Eq k, Num k, Ord v1, Ord v2) => Polynomial k v1 -> (v1 -> Polynomial k v2) -> Polynomial k v2
- substA :: forall k v1 v2 f. (Eq k, Num k, Ord v1, Ord v2, Applicative f) => Polynomial k v1 -> (v1 -> f (Polynomial k v2)) -> f (Polynomial k v2)
- substM :: (Eq k, Num k, Ord v1, Ord v2, Monad m) => Polynomial k v1 -> (v1 -> m (Polynomial k v2)) -> m (Polynomial k v2)
- isRootOf :: (Eq k, Num k) => k -> UPolynomial k -> Bool
- mapVar :: (Eq k, Num k, Ord v1, Ord v2) => (v1 -> v2) -> Polynomial k v1 -> Polynomial k v2
- mapCoeff :: (Eq k1, Num k1, Ord v) => (k -> k1) -> Polynomial k v -> Polynomial k1 v
- associatedMonicPolynomial :: (Eq r, Fractional r, Ord v) => MonomialOrder v -> Polynomial r v -> Polynomial r v
- toUPolynomialOf :: (Ord k, Num k, Ord v) => Polynomial k v -> v -> UPolynomial (Polynomial k v)
- polyDiv :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial k
- polyMod :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial k
- polyDivMod :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> (UPolynomial k, UPolynomial k)
- polyGCD :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial k
- polyLCM :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial k
- prem :: (Eq r, Integral r) => UPolynomial r -> UPolynomial r -> UPolynomial r
- polyGCD' :: (Eq r, Integral r) => UPolynomial r -> UPolynomial r -> UPolynomial r
- polyMDivMod :: forall k v. (Eq k, Fractional k, Ord v) => MonomialOrder v -> Polynomial k v -> [Polynomial k v] -> ([Polynomial k v], Polynomial k v)
- reduce :: (Eq k, Fractional k, Ord v) => MonomialOrder v -> Polynomial k v -> [Polynomial k v] -> Polynomial k v
- type Monomial k v = (k, MonicMonomial v)
- monomialDegree :: Monomial k v -> Integer
- monomialProd :: (Num k, Ord v) => Monomial k v -> Monomial k v -> Monomial k v
- monomialDivisible :: (Fractional k, Ord v) => Monomial k v -> Monomial k v -> Bool
- monomialDiv :: (Fractional k, Ord v) => Monomial k v -> Monomial k v -> Monomial k v
- monomialDeriv :: (Eq k, Num k, Ord v) => Monomial k v -> v -> Monomial k v
- monomialIntegral :: (Eq k, Fractional k, Ord v) => Monomial k v -> v -> Monomial k v
- data MonicMonomial v
- mmOne :: MonicMonomial v
- mmFromList :: Ord v => [(v, Integer)] -> MonicMonomial v
- mmFromMap :: Ord v => Map v Integer -> MonicMonomial v
- mmFromIntMap :: IntMap Integer -> MonicMonomial Int
- mmToList :: Ord v => MonicMonomial v -> [(v, Integer)]
- mmToMap :: MonicMonomial v -> Map v Integer
- mmToIntMap :: MonicMonomial Int -> IntMap Integer
- mmProd :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial v
- mmDivisible :: Ord v => MonicMonomial v -> MonicMonomial v -> Bool
- mmDiv :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial v
- mmDeriv :: Ord v => MonicMonomial v -> v -> (Integer, MonicMonomial v)
- mmIntegral :: Ord v => MonicMonomial v -> v -> (Rational, MonicMonomial v)
- mmLCM :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial v
- mmGCD :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial v
- mmMapVar :: (Ord v1, Ord v2) => (v1 -> v2) -> MonicMonomial v1 -> MonicMonomial v2
- type MonomialOrder v = MonicMonomial v -> MonicMonomial v -> Ordering
- lex :: Ord v => MonomialOrder v
- revlex :: Ord v => MonicMonomial v -> MonicMonomial v -> Ordering
- grlex :: Ord v => MonomialOrder v
- grevlex :: Ord v => MonomialOrder v
- data PrintOptions k v = PrintOptions {
- pOptPrintVar :: PrettyLevel -> Rational -> v -> Doc
- pOptPrintCoeff :: PrettyLevel -> Rational -> k -> Doc
- pOptIsNegativeCoeff :: k -> Bool
- pOptMonomialOrder :: MonomialOrder v
- defaultPrintOptions :: (PrettyCoeff k, PrettyVar v, Ord v) => PrintOptions k v
- prettyPrint :: (Ord k, Num k, Ord v) => PrintOptions k v -> PrettyLevel -> Rational -> Polynomial k v -> Doc
- class PrettyCoeff a where
- pPrintCoeff :: PrettyLevel -> Rational -> a -> Doc
- isNegativeCoeff :: a -> Bool
- class PrettyVar a where
- pPrintVar :: PrettyLevel -> Rational -> a -> Doc
Polynomial type
data Polynomial k v Source
Polynomial over commutative ring r
Typeable2 Polynomial | |
(Eq k, Num k) => Variables (Polynomial k) | |
(Eq k, Eq v) => Eq (Polynomial k v) | |
(Eq k, Num k, Ord v) => Num (Polynomial k v) | |
(Ord k, Ord v) => Ord (Polynomial k v) | |
(Show v, Ord v, Show k) => Show (Polynomial k v) | |
(NFData k, NFData v) => NFData (Polynomial k v) | |
(Ord k, Num k, Ord v, PrettyCoeff k, PrettyVar v) => Pretty (Polynomial k v) | |
(Eq k, Num k, Ord v) => VectorSpace (Polynomial k v) | |
(Eq k, Num k, Ord v) => AdditiveGroup (Polynomial k v) | |
(Num c, Ord c, PrettyCoeff c, Ord v, PrettyVar v) => PrettyCoeff (Polynomial c v) | |
Degree (Polynomial k v) |
type UPolynomial r = Polynomial r XSource
Univariate polynomials over commutative ring r
Conversion
Variables MonicMonomial | |
(Eq k, Num k) => Variables (Polynomial k) |
terms :: Polynomial k v -> [Monomial k v]Source
list of monomials
fromTerms :: (Eq k, Num k, Ord v) => [Monomial k v] -> Polynomial k vSource
construct a polynomial from a list of monomials
coeffMap :: Polynomial k v -> Map (MonicMonomial v) kSource
fromCoeffMap :: (Eq k, Num k, Ord v) => Map (MonicMonomial v) k -> Polynomial k vSource
fromMonomial :: (Eq k, Num k, Ord v) => Monomial k v -> Polynomial k vSource
construct a polynomial from a monomial
Query
total degree of a given polynomial
Degree AReal | Degree of the algebraic number. If the algebraic number's |
Degree (MonicMonomial v) | |
Degree (Polynomial k v) |
leadingTerm :: (Eq k, Num k, Ord v) => MonomialOrder v -> Polynomial k v -> Monomial k vSource
leading term with respect to a given monomial order
coeff :: (Num k, Ord v) => MonicMonomial v -> Polynomial k v -> kSource
lookupCoeff :: Ord v => MonicMonomial v -> Polynomial k v -> Maybe kSource
isPrimitive :: (Eq k, Num k, ContPP k, Ord v) => Polynomial k v -> BoolSource
Operations
cont :: Ord v => Polynomial k v -> kSource
Content of a polynomial
pp :: Ord v => Polynomial k v -> Polynomial k vSource
Primitive part of a polynomial
deriv :: (Eq k, Num k, Ord v) => Polynomial k v -> v -> Polynomial k vSource
Formal derivative of polynomials
integral :: (Eq k, Fractional k, Ord v) => Polynomial k v -> v -> Polynomial k vSource
Formal integral of polynomials
eval :: (Num k, Ord v) => (v -> k) -> Polynomial k v -> kSource
Evaluation
evalA :: forall k v f. (Num k, Ord v, Applicative f) => (v -> f k) -> Polynomial k v -> f kSource
Evaluation
subst :: (Eq k, Num k, Ord v1, Ord v2) => Polynomial k v1 -> (v1 -> Polynomial k v2) -> Polynomial k v2Source
Substitution or bind
substA :: forall k v1 v2 f. (Eq k, Num k, Ord v1, Ord v2, Applicative f) => Polynomial k v1 -> (v1 -> f (Polynomial k v2)) -> f (Polynomial k v2)Source
Substitution or bind
substM :: (Eq k, Num k, Ord v1, Ord v2, Monad m) => Polynomial k v1 -> (v1 -> m (Polynomial k v2)) -> m (Polynomial k v2)Source
Substitution or bind
mapVar :: (Eq k, Num k, Ord v1, Ord v2) => (v1 -> v2) -> Polynomial k v1 -> Polynomial k v2Source
mapCoeff :: (Eq k1, Num k1, Ord v) => (k -> k1) -> Polynomial k v -> Polynomial k1 vSource
associatedMonicPolynomial :: (Eq r, Fractional r, Ord v) => MonomialOrder v -> Polynomial r v -> Polynomial r vSource
toUPolynomialOf :: (Ord k, Num k, Ord v) => Polynomial k v -> v -> UPolynomial (Polynomial k v)Source
polyDiv :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial kSource
division of univariate polynomials
polyMod :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial kSource
division of univariate polynomials
polyDivMod :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> (UPolynomial k, UPolynomial k)Source
division of univariate polynomials
polyGCD :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial kSource
GCD of univariate polynomials
polyLCM :: (Eq k, Fractional k) => UPolynomial k -> UPolynomial k -> UPolynomial kSource
LCM of univariate polynomials
prem :: (Eq r, Integral r) => UPolynomial r -> UPolynomial r -> UPolynomial rSource
pseudo reminder
polyGCD' :: (Eq r, Integral r) => UPolynomial r -> UPolynomial r -> UPolynomial rSource
GCD of univariate polynomials
polyMDivMod :: forall k v. (Eq k, Fractional k, Ord v) => MonomialOrder v -> Polynomial k v -> [Polynomial k v] -> ([Polynomial k v], Polynomial k v)Source
Multivariate division algorithm
reduce :: (Eq k, Fractional k, Ord v) => MonomialOrder v -> Polynomial k v -> [Polynomial k v] -> Polynomial k vSource
Multivariate division algorithm
Monomial
type Monomial k v = (k, MonicMonomial v)Source
monomialDegree :: Monomial k v -> IntegerSource
monomialDivisible :: (Fractional k, Ord v) => Monomial k v -> Monomial k v -> BoolSource
monomialDiv :: (Fractional k, Ord v) => Monomial k v -> Monomial k v -> Monomial k vSource
monomialIntegral :: (Eq k, Fractional k, Ord v) => Monomial k v -> v -> Monomial k vSource
Monic monomial
data MonicMonomial v Source
Monic monomials
Typeable1 MonicMonomial | |
Variables MonicMonomial | |
Eq v => Eq (MonicMonomial v) | |
Ord v => Ord (MonicMonomial v) | |
(Ord v, Show v) => Show (MonicMonomial v) | |
NFData v => NFData (MonicMonomial v) | |
Degree (MonicMonomial v) |
mmOne :: MonicMonomial vSource
mmFromList :: Ord v => [(v, Integer)] -> MonicMonomial vSource
mmToList :: Ord v => MonicMonomial v -> [(v, Integer)]Source
mmToMap :: MonicMonomial v -> Map v IntegerSource
mmProd :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial vSource
mmDivisible :: Ord v => MonicMonomial v -> MonicMonomial v -> BoolSource
mmDiv :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial vSource
mmDeriv :: Ord v => MonicMonomial v -> v -> (Integer, MonicMonomial v)Source
mmIntegral :: Ord v => MonicMonomial v -> v -> (Rational, MonicMonomial v)Source
mmLCM :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial vSource
mmGCD :: Ord v => MonicMonomial v -> MonicMonomial v -> MonicMonomial vSource
mmMapVar :: (Ord v1, Ord v2) => (v1 -> v2) -> MonicMonomial v1 -> MonicMonomial v2Source
Monomial order
type MonomialOrder v = MonicMonomial v -> MonicMonomial v -> OrderingSource
lex :: Ord v => MonomialOrder vSource
Lexicographic order
revlex :: Ord v => MonicMonomial v -> MonicMonomial v -> OrderingSource
Reverse lexicographic order Note that revlex is NOT a monomial order.
grlex :: Ord v => MonomialOrder vSource
graded lexicographic order
grevlex :: Ord v => MonomialOrder vSource
graded reverse lexicographic order
Pretty Printing
data PrintOptions k v Source
PrintOptions | |
|
defaultPrintOptions :: (PrettyCoeff k, PrettyVar v, Ord v) => PrintOptions k vSource
prettyPrint :: (Ord k, Num k, Ord v) => PrintOptions k v -> PrettyLevel -> Rational -> Polynomial k v -> DocSource
class PrettyCoeff a whereSource
pPrintCoeff :: PrettyLevel -> Rational -> a -> DocSource
isNegativeCoeff :: a -> BoolSource
PrettyCoeff Integer | |
PrettyCoeff AReal | |
(PrettyCoeff a, Integral a) => PrettyCoeff (Ratio a) | |
PrettyCoeff (PrimeField a) | |
(Num c, Ord c, PrettyCoeff c, Ord v, PrettyVar v) => PrettyCoeff (Polynomial c v) |