np-extras-0.2: NumericPrelude extras

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 Fieldscoeff :: a powers :: Map Integer Integer

Instances

 Eq (T a) Ord (T a) (C a, C a, Eq a, Show a) => Show (T a) (C a, C a, Eq a) => C (T a) C a => C (T a) (C a, C a) => C (T a) (C a, C a) => C (T a) (C a, C a) => C (T a)

# Creating monomials

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

constant :: a -> T aSource

Create a constant monomial.

x :: C a => Integer -> T aSource

Create the monomial xn for a given n.

# Utility functions

degree :: T a -> IntegerSource

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

pDegree :: T a -> IntegerSource

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 aSource

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