np-extras-0.3.1.2: NumericPrelude extras

Safe HaskellNone
LanguageHaskell2010

MathObj.Monomial

Contents

Description

Monomials in a countably infinite set of variables x1, x2, x3, ...

Synopsis

Type

data T a Source #

A monomial is a map from variable indices to integer powers, paired with a (polymorphic) coefficient. Note that negative integer powers are handled just fine, so monomials form a field.

Instances are provided for Eq, Ord, ZeroTestable, Additive, Ring, Differential, and Field. Note that adding two monomials only makes sense if they have matching variables and exponents. The Differential instance represents partial differentiation with respect to x1.

The Ord instance for monomials orders them first by permutation degree, then by largest variable index (largest first), then by exponent (largest first). This may seem a bit odd, but in fact reflects the use of these monomials to implement cycle index series, where this ordering corresponds nicely to generation of integer partitions. To make the library more general we could parameterize monomials by the desired ordering.

Constructors

Cons 

Fields

Instances
Eq (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

(==) :: T a -> T a -> Bool #

(/=) :: T a -> T a -> Bool #

Ord (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

compare :: T a -> T a -> Ordering #

(<) :: T a -> T a -> Bool #

(<=) :: T a -> T a -> Bool #

(>) :: T a -> T a -> Bool #

(>=) :: T a -> T a -> Bool #

max :: T a -> T a -> T a #

min :: T a -> T a -> T a #

(C a, C a, Eq a, Show a) => Show (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

showsPrec :: Int -> T a -> ShowS #

show :: T a -> String #

showList :: [T a] -> ShowS #

(C a, C a, Eq a) => C (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

(/) :: T a -> T a -> T a #

recip :: T a -> T a #

fromRational' :: Rational -> T a #

(^-) :: T a -> Integer -> T a #

(C a, C a) => C (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

differentiate :: T a -> T a #

(C a, C a) => C (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

(*) :: T a -> T a -> T a #

one :: T a #

fromInteger :: Integer -> T a #

(^) :: T a -> Integer -> T a #

C a => C (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

isZero :: T a -> Bool #

(C a, C a) => C (T a) Source # 
Instance details

Defined in MathObj.Monomial

Methods

zero :: T a #

(+) :: T a -> T a -> T a #

(-) :: T a -> T a -> T a #

negate :: T a -> T a #

Creating monomials

mkMonomial :: a -> [(Integer, Integer)] -> T a Source #

constant :: a -> T a Source #

Create a constant monomial.

x :: C a => Integer -> T a Source #

Create the monomial xn for a given n.

Utility functions

degree :: T a -> Integer Source #

The degree of a monomial is the sum of its exponents.

pDegree :: T a -> Integer Source #

The "partition degree" of a monomial is the sum of the products of each variable index with its exponent. For example, x1^3 x2^2 x4^3 has partition degree 1*3 + 2*2 + 4*3 = 19. The terminology comes from the fact that, for example, we can view x1^3 x2^2 x4^3 as corresponding to an integer partition of 19 (namely, 1 + 1 + 1 + 2 + 2 + 4 + 4 + 4).

scaleMon :: Integer -> T a -> T a Source #

Scale all the variable subscripts by a constant. Useful for operations like plethyistic substitution or Mobius inversion.