HaskellForMaths-0.4.5: Combinatorics, group theory, commutative algebra, non-commutative algebra

Safe Haskell | Safe-Inferred

Math.Core.Utils

Description

A module of simple utility functions which are used throughout the rest of the library

Synopsis

- toSet :: Ord a => [a] -> [a]
- sortDesc :: Ord a => [a] -> [a]
- insertDesc :: Ord a => a -> [a] -> [a]
- setUnionAsc :: Ord a => [a] -> [a] -> [a]
- multisetSumAsc :: Ord a => [a] -> [a] -> [a]
- multisetSumDesc :: Ord a => [a] -> [a] -> [a]
- diffAsc :: Ord a => [a] -> [a] -> [a]
- diffDesc :: Ord a => [a] -> [a] -> [a]
- isSubsetAsc :: Ord a => [a] -> [a] -> Bool
- isSubMultisetAsc :: Ord a => [a] -> [a] -> Bool
- pairs :: [a] -> [(a, a)]
- ordpair :: Ord t => t -> t -> (t, t)
- foldcmpl :: (b -> b -> Bool) -> [b] -> Bool
- isWeaklyIncreasing :: Ord t => [t] -> Bool
- isStrictlyIncreasing :: Ord t => [t] -> Bool
- isWeaklyDecreasing :: Ord t => [t] -> Bool
- isStrictlyDecreasing :: Ord t => [t] -> Bool
- cmpfst :: Ord a => (a, b) -> (a, b1) -> Ordering
- eqfst :: Eq a => (a, b) -> (a, b1) -> Bool
- fromBase :: Num a => a -> [a] -> a
- powersetdfs :: [a] -> [[a]]
- powersetbfs :: [a] -> [[a]]
- combinationsOf :: Int -> [a] -> [[a]]
- choose :: Integral a => a -> a -> a
- class FinSet x where
  - elts :: [x]
- class HasInverses a where
  - inverse :: a -> a
- (^-) :: (Num a, HasInverses a, Integral b) => a -> b -> a

# Documentation

toSet :: Ord a => [a] -> [a]Source

sortDesc :: Ord a => [a] -> [a]Source

insertDesc :: Ord a => a -> [a] -> [a]Source

setUnionAsc :: Ord a => [a] -> [a] -> [a]Source

The set union of two ascending lists. If both inputs are strictly increasing, then the output is their union and is strictly increasing. The code does not check that the lists are strictly increasing.

multisetSumAsc :: Ord a => [a] -> [a] -> [a]Source

The multiset sum of two ascending lists. If xs and ys are ascending, then multisetSumAsc xs ys == sort (xs++ys). The code does not check that the lists are ascending.

multisetSumDesc :: Ord a => [a] -> [a] -> [a]Source

The multiset sum of two descending lists. If xs and ys are descending, then multisetSumDesc xs ys == sort (xs++ys). The code does not check that the lists are descending.

diffAsc :: Ord a => [a] -> [a] -> [a]Source

The multiset or set difference between two ascending lists. If xs and ys are ascending, then diffAsc xs ys == xs \ ys, and diffAsc is more efficient. If xs and ys are sets (that is, have no repetitions), then diffAsc xs ys is the set difference. The code does not check that the lists are ascending.

diffDesc :: Ord a => [a] -> [a] -> [a]Source

The multiset or set difference between two descending lists. If xs and ys are descending, then diffDesc xs ys == xs \ ys, and diffDesc is more efficient. If xs and ys are sets (that is, have no repetitions), then diffDesc xs ys is the set difference. The code does not check that the lists are descending.

isSubsetAsc :: Ord a => [a] -> [a] -> Bool Source

isSubMultisetAsc :: Ord a => [a] -> [a] -> Bool Source

pairs :: [a] -> [(a, a)]Source

ordpair :: Ord t => t -> t -> (t, t)Source

foldcmpl :: (b -> b -> Bool) -> [b] -> Bool Source

isWeaklyIncreasing :: Ord t => [t] -> Bool Source

isStrictlyIncreasing :: Ord t => [t] -> Bool Source

isWeaklyDecreasing :: Ord t => [t] -> Bool Source

isStrictlyDecreasing :: Ord t => [t] -> Bool Source

cmpfst :: Ord a => (a, b) -> (a, b1) -> Ordering Source

eqfst :: Eq a => (a, b) -> (a, b1) -> Bool Source

fromBase :: Num a => a -> [a] -> aSource

powersetdfs :: [a] -> [[a]]Source

Given a set `xs`, represented as an ordered list, `powersetdfs xs` returns the list of all subsets of xs, in lex order

powersetbfs :: [a] -> [[a]]Source

Given a set `xs`, represented as an ordered list, `powersetbfs xs` returns the list of all subsets of xs, in shortlex order

combinationsOf :: Int -> [a] -> [[a]]Source

Given a positive integer `k`, and a set `xs`, represented as a list, `combinationsOf k xs` returns all k-element subsets of xs. The result will be in lex order, relative to the order of the xs.

choose :: Integral a => a -> a -> aSource

`choose n k` is the number of ways of choosing k distinct elements from an n-set

class FinSet x where Source

The class of finite sets

Methods

elts :: [x]Source

Instances

FinSet F25 |
FinSet F16 |
FinSet F9 |
FinSet F8 |
FinSet F4 |
FinSet F23 |
FinSet F19 |
FinSet F17 |
FinSet F13 |
FinSet F11 |
FinSet F7 |
FinSet F5 |
FinSet F3 |
FinSet F2 |
IntegerAsType p => FinSet (Fp p) |
(FinSet fp, Eq fp, Num fp, PolynomialAsType fp poly) => FinSet (ExtensionField fp poly) |

class HasInverses a where Source

A class representing algebraic structures having an inverse operation. Note that in some cases not every element has an inverse.

Methods

inverse :: a -> aSource

Instances

HasInverses SSymF |
(Ord a, Show a) => HasInverses (Permutation a) | The HasInverses instance is what enables us to write `g^-1` for the inverse of a group element.
HasInverses (GroupAlgebra Q) | Note that the inverse of a group algebra element can only be efficiently calculated if the group generated by the non-zero terms is very small (eg <100 elements).
(Eq k, Fractional k, Ord a, Show a) => HasInverses (Vect k (Interval a)) |

(^-) :: (Num a, HasInverses a, Integral b) => a -> b -> aSource

A trick: x^-1 returns the inverse of x