Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Some auxilary functions used internally
Synopsis
- equating :: Eq b => (a -> b) -> a -> a -> Bool
- unique :: Ord a => [a] -> [a]
- count :: Ord b => [b] -> Map b Integer
- histogram :: Ord b => [b] -> Map b Integer
- sum' :: Num a => [a] -> a
- longZipWith :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c]
- longReplaceListElem :: a -> Int -> a -> [a] -> [a]
- deleteLookup :: Ord a => a -> Map a b -> (Maybe b, Map a b)
- unsafeDeleteLookup :: Ord a => a -> Map a b -> (b, Map a b)
- insertMap :: Ord k => (b -> a) -> (b -> a -> a) -> k -> b -> Map k a -> Map k a
- buildMap :: Ord k => (b -> a) -> (b -> a -> a) -> [(k, b)] -> Map k a
- data Sign
- oppositeSign :: Sign -> Sign
- mulSign :: Sign -> Sign -> Sign
- productOfSigns :: [Sign] -> Sign
- negateIfOdd :: (Integral a, Num b) => a -> b -> b
- signValue :: Num a => Sign -> a
- signed :: Num a => Sign -> a -> a
- class IsSigned a where
- signOfNum :: (Ord a, Num a) => a -> Maybe Sign
- fromRat :: Rational -> Integer
- safeDiv :: Integer -> Integer -> Integer
- factorial :: Integral a => a -> Integer
- binomial :: Integral a => a -> a -> Integer
- moebiusMu :: Num c => Int -> c
- divisors :: Int -> [Int]
- squareFreeDivisors :: Int -> [(Int, Sign)]
- primes :: [Integer]
- groupIntegerFactors :: [Integer] -> [(Integer, Int)]
- integerFactorsTrialDivision :: Integer -> [Integer]
- tuples' :: [Int] -> [[Int]]
- sublists :: [a] -> [[a]]
- intCache :: ((Int -> a) -> Int -> a) -> Int -> a
- newtype ITable a = ITable [Array Int a]
- mkITable :: [a] -> ITable a
- lkpITable :: Int -> ITable a -> a
- signedStirling1stArray :: Integral a => a -> Array Int Integer
- stirling2nd :: Integral a => a -> a -> Integer
Documentation
Lists
longZipWith :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c] Source #
longReplaceListElem :: a -> Int -> a -> [a] -> [a] Source #
Maps
insertMap :: Ord k => (b -> a) -> (b -> a -> a) -> k -> b -> Map k a -> Map k a Source #
Example usage: insertMap (:[]) (:) ...
buildMap :: Ord k => (b -> a) -> (b -> a -> a) -> [(k, b)] -> Map k a Source #
Example usage: buildMap (:[]) (:) ...
Signs
oppositeSign :: Sign -> Sign Source #
productOfSigns :: [Sign] -> Sign Source #
negateIfOdd :: (Integral a, Num b) => a -> b -> b Source #
Negate the second argument if the first is odd
class IsSigned a where Source #
Instances
IsSigned Int Source # | |
IsSigned Integer Source # | |
IsSigned Rational Source # | |
IsSigned (Poly c v) Source # | |
IsSigned (Poly c v) Source # | |
IsSigned (Univariate c v) Source # | |
Defined in Math.Algebra.Polynomial.Univariate | |
IsSigned (Poly c v n) Source # | |
IsSigned (Poly c v n) Source # | |
IsSigned (ExtAlg c v n) Source # | |
Numbers
Basic number theory
binomial :: Integral a => a -> a -> Integer Source #
A007318. Note: This is zero for n<0
or k<0
; see also signedBinomial
below.
squareFreeDivisors :: Int -> [(Int, Sign)] Source #
Square-free divisors together with their Mobius mu value
groupIntegerFactors :: [Integer] -> [(Integer, Int)] Source #
Groups integer factors. Example: from [2,2,2,3,3,5] we produce [(2,3),(3,2),(5,1)]
integerFactorsTrialDivision :: Integer -> [Integer] Source #
The naive trial division algorithm.
Basic combinatorics
Integer-indexed cache
Stirling numbers
signedStirling1stArray :: Integral a => a -> Array Int Integer Source #
Rows of (signed) Stirling numbers of the first kind. OEIS:A008275.
Coefficients of the polinomial (x-1)*(x-2)*...*(x-n+1)
.
This function uses the recursion formula.
stirling2nd :: Integral a => a -> a -> Integer Source #
Stirling numbers of the second kind. OEIS:A008277. This function uses an explicit formula.
Argument order: stirling2nd n k