Copyright | (c) 2015-2018 Frederick Schneider |
---|---|
License | MIT |
Maintainer | Frederick Schneider <frederick.schneider2011@gmail.com> |
Stability | Provisional |
Safe Haskell | None |
Language | Haskell2010 |
A Canon is an exponentation-based representation for arbitrarily massive numbers, including prime towers.
- data Canon
- makeCanon :: Integer -> Canon
- data BareStatus
- data CanonValueType
- cMult :: Canon -> Canon -> CycloMap -> (Canon, CycloMap)
- cDiv :: Canon -> Canon -> CycloMap -> (Canon, CycloMap)
- cAdd :: Canon -> Canon -> CycloMap -> (Canon, CycloMap)
- cSubtract :: Canon -> Canon -> CycloMap -> (Canon, CycloMap)
- cExp :: Canon -> Canon -> Bool -> CycloMap -> (Canon, CycloMap)
- cReciprocal :: Canon -> Canon
- cGCD :: Canon -> Canon -> Canon
- cLCM :: Canon -> Canon -> Canon
- cMod :: Canon -> Canon -> Canon
- cOdd :: Canon -> Bool
- cTotient :: Canon -> CycloMap -> (Canon, CycloMap)
- cPhi :: Canon -> CycloMap -> (Canon, CycloMap)
- cLog :: Canon -> Rational
- cLogDouble :: Canon -> Double
- cNegative :: Canon -> Bool
- cPositive :: Canon -> Bool
- cIntegral :: Canon -> Bool
- cRational :: Canon -> Bool
- cIrrational :: Canon -> Bool
- cSimplify :: Canon -> Canon
- cSimplified :: Canon -> Bool
- cDepth :: Canon -> Integer
- cSplit :: Canon -> (Canon, Canon)
- cNumerator :: Canon -> Canon
- cDenominator :: Canon -> Canon
- cCanonical :: Canon -> Bool
- cBare :: Canon -> Bool
- cBareStatus :: Canon -> BareStatus
- cValueType :: Canon -> CanonValueType
- cIsPrimeTower :: Canon -> Bool
- cPrimeTowerLevel :: Canon -> Integer
- cTetration :: Canon -> Integer -> CycloMap -> (Canon, CycloMap)
- cPentation :: Canon -> Integer -> CycloMap -> (Canon, CycloMap)
- cHexation :: Canon -> Integer -> CycloMap -> (Canon, CycloMap)
- cHyperOp :: Integer -> Canon -> Integer -> CycloMap -> (Canon, CycloMap)
- (>^) :: CanonRoot a b c => a -> b -> c
- (<^) :: CanonExpnt a b c => a -> b -> c
- (<^>) :: Canon -> Integer -> Canon
- (<<^>>) :: Canon -> Integer -> Canon
- (<<<^>>>) :: Canon -> Integer -> Canon
- type CanonElement = (Canon, Canon)
- getBase :: CanonElement -> Canon
- getExponent :: CanonElement -> Canon
- getBases :: Canon -> [Canon]
- getExponents :: Canon -> [Canon]
- getElements :: Canon -> [CanonElement]
- cNumDivisors :: Canon -> Either String Canon
- cTau :: Canon -> Either String Canon
- cDivisors :: Canon -> Either String [Canon]
- cNthDivisor :: Canon -> Canon -> Either String Canon
- cWhichDivisor :: Canon -> Canon -> Either String Canon
- data CycloMap
- fromCycloMap :: CycloMap -> CycloMapInternal
- cmLookup :: CR_ -> CycloMap -> Maybe CycloPair
- showCyclo :: CR_ -> CycloMap -> [Char]
- crCycloInitMap :: CycloMap
Documentation
Canon: GADT for either Bare (Integer) or some variation of a canonical form (see CanonValueType).
makeCanon :: Integer -> Canon Source #
Create a Canon from an Integer. This may involve expensive factorization.
data BareStatus Source #
BareStatus: A "Bare Simplified" number means a prime number, +/-1 or 0. The code must set the flag properly A "Bare NotSimplified" number is an Integer that has not been checked (to see if it can be factored).
data CanonValueType Source #
CanonValueType: 3 possibilities for this GADT (integral, non-integral rational, irrational). Imaginary/complex numbers are not supported
cMult :: Canon -> Canon -> CycloMap -> (Canon, CycloMap) Source #
Multiply Function: Generally speaking, this will be much cheaper than addition/subtraction which requires factoring. You are usually just merging lists of prime, exponent pairs and adding exponents where common primes are found. This notion is the crux of the library.
Note: This can be used instead of the *
operator if you want to maintain a CycloMap for performance
reasons.
cDiv :: Canon -> Canon -> CycloMap -> (Canon, CycloMap) Source #
Div function : Multiply by the reciprocal.
cAdd :: Canon -> Canon -> CycloMap -> (Canon, CycloMap) Source #
Addition and subtraction is generally much more expensive because it requires refactorization. There is logic to look for algebraic forms which can greatly reduce simplify factorization. Note: This can be used instead of the +/- operators if you want to maintain a CycloMap for performance reasons.
cSubtract :: Canon -> Canon -> CycloMap -> (Canon, CycloMap) Source #
Addition and subtraction is generally much more expensive because it requires refactorization. There is logic to look for algebraic forms which can greatly reduce simplify factorization. Note: This can be used instead of the +/- operators if you want to maintain a CycloMap for performance reasons.
cExp :: Canon -> Canon -> Bool -> CycloMap -> (Canon, CycloMap) Source #
Exponentiation: This does allow for negative exponentiation if the Bool flag is True. Note: This can be used instead of the exponentiation operator if you want to maintain a CycloMap for performance reasons.
cReciprocal :: Canon -> Canon Source #
Compute reciprocal (by negating exponents).
cOdd :: Canon -> Bool Source #
Check if a Canon is an odd Integer. Note: Return False if the Canon is not integral. See CanonValueType for possible cases.
cLogDouble :: Canon -> Double Source #
Compute log as a Double.
cIntegral :: Canon -> Bool Source #
Functions to check if a Canon is Integral, (Ir)Rational, Simplified or a prime tower
cRational :: Canon -> Bool Source #
Functions to check if a Canon is Integral, (Ir)Rational, Simplified or a prime tower
cIrrational :: Canon -> Bool Source #
Functions to check if a Canon is Integral, (Ir)Rational, Simplified or a prime tower
cSimplify :: Canon -> Canon Source #
Force the expression to be simplified. This could potentially be very expensive.
cSimplified :: Canon -> Bool Source #
Functions to check if a Canon is Integral, (Ir)Rational, Simplified or a prime tower
cNumerator :: Canon -> Canon Source #
cNumerator and cDenominator are for processing "rational" canon reps.
cDenominator :: Canon -> Canon Source #
cNumerator and cDenominator are for processing "rational" canon reps.
cCanonical :: Canon -> Bool Source #
Checks if the Canon is Canonical, a more complex expression.
cBareStatus :: Canon -> BareStatus Source #
Returns the status for Bare numbers.
cValueType :: Canon -> CanonValueType Source #
Return the CanonValueType (Integral, etc).
cIsPrimeTower :: Canon -> Bool Source #
Functions to check if a Canon is Integral, (Ir)Rational, Simplified or a prime tower
cPrimeTowerLevel :: Canon -> Integer Source #
This is used for tetration, etc. It defaults to zero for non-integral reps.
cHyperOp :: Integer -> Canon -> Integer -> CycloMap -> (Canon, CycloMap) Source #
Generalized Hyperoperation Function (https:/en.wikipedia.orgwiki/Hyperoperation)
(<^>) :: Canon -> Integer -> Canon infixr 9 Source #
The thinking around the hyperoperators is that they should look progressively scarier :)
(<<^>>) :: Canon -> Integer -> Canon infixr 9 Source #
The thinking around the hyperoperators is that they should look progressively scarier :)
(<<<^>>>) :: Canon -> Integer -> Canon infixr 9 Source #
The thinking around the hyperoperators is that they should look progressively scarier :)
type CanonElement = (Canon, Canon) Source #
This element is a base, exponent pair. The base is an integer and is generally prime or 0, -1. The exponent is also a Canon (allowing for arbitrary nesting) A Canon conceptually consists of a list of these elements. The first member of the pair will be a Canon raised to the first power. By doing this, we're allow for further generality in the definition of a Canon.
getBase :: CanonElement -> Canon Source #
Return the base b from a Canon Element (equivalent to b^e)
getExponent :: CanonElement -> Canon Source #
Return the exponent e from a Canon Element (equivalent to b^e)
getBases :: Canon -> [Canon] Source #
Return the list of bases from a Canon (conceptually of the form [b^e])>
getExponents :: Canon -> [Canon] Source #
Return the list of exponents from a Canon (conceptually of the form [b^e]).
getElements :: Canon -> [CanonElement] Source #
Return the list of CanonElements from a Canon (conceptually of the form [b^e]).
cNumDivisors :: Canon -> Either String Canon Source #
Divisor functions should be called with integral Canons. Restricted to positive divisors. Returns Either String Canon
cTau :: Canon -> Either String Canon Source #
Divisor functions should be called with integral Canons. Restricted to positive divisors. Returns Either String Canon
cDivisors :: Canon -> Either String [Canon] Source #
Efficiently compute all of the divisors based on the canonical representation. | Returns Either an error message or a list of Canons.
cNthDivisor :: Canon -> Canon -> Either String Canon Source #
Compute the nth divisor of a Canon. It operates on the absolute value of the Canon and is zero based. Note: This is deterministic but it's not ordered by the value of the divisor.
cWhichDivisor :: Canon -> Canon -> Either String Canon Source #
Consider this to be the inverse of the cNthDivisor function. This function ignores signs but both parameters must be integral.
CycloMap is a newtype hiding the details of a map of CR_ to pairs of integers and corresponding cyclotomic polynomials.
fromCycloMap :: CycloMap -> CycloMapInternal Source #
Unwrap the CycloMap newtype.
showCyclo :: CR_ -> CycloMap -> [Char] Source #
This will display the cyclotomic polynomials for a CR.
crCycloInitMap :: CycloMap Source #
This is an initial map with the cyclotomic polynomials for 1 and 2.