NumericPrelude-0.0: An experimental alternative hierarchy of numeric type classesContentsIndex
Algebra.IntegralDomain
Contents
Class
Derived functions
Algorithms
Properties
Synopsis
class C a => C a where
div :: a -> a -> a
mod :: a -> a -> a
divMod :: a -> a -> (a, a)
div :: C a => a -> a -> a
mod :: C a => a -> a -> a
divMod :: C a => a -> a -> (a, a)
divModZero :: (C a, C a) => a -> a -> (a, a)
divides :: (C a, C a) => a -> a -> Bool
sameResidueClass :: (C a, C a) => a -> a -> a -> Bool
safeDiv :: (C a, C a) => a -> a -> a
even :: (C a, C a) => a -> Bool
odd :: (C a, C a) => a -> Bool
decomposeVarPositional :: (C a, C a) => [a] -> a -> [a]
decomposeVarPositionalInf :: C a => [a] -> a -> [a]
propInverse :: (Eq a, C a, C a) => a -> a -> Property
propMultipleDiv :: (Eq a, C a, C a) => a -> a -> Property
propMultipleMod :: (Eq a, C a, C a) => a -> a -> Property
propProjectAddition :: (Eq a, C a, C a) => a -> a -> a -> Property
propProjectMultiplication :: (Eq a, C a, C a) => a -> a -> a -> Property
propUniqueRepresentative :: (Eq a, C a, C a) => a -> a -> a -> Property
propZeroRepresentative :: (Eq a, C a, C a) => a -> Property
propSameResidueClass :: (Eq a, C a, C a) => a -> a -> a -> Property
Class
class C a => C a where

IntegralDomain corresponds to a commutative ring, where a mod b picks a canonical element of the equivalence class of a in the ideal generated by b. div and mod satisfy the laws

                         a * b === b * a
 (a `div` b) * b + (a `mod` b) === a
               (a+k*b) `mod` b === a `mod` b
                     0 `mod` b === 0

Typical examples of IntegralDomain include integers and polynomials over a field. Note that for a field, there is a canonical instance defined by the above rules; e.g.,

 instance IntegralDomain.C Rational where
     divMod a b =
        if isZero b
          then (undefined,a)
          else (a\/b,0)

It shall be noted, that div, mod, divMod have a parameter order which is unfortunate for partial application. But it is adapted to mathematical conventions, where the operators are used in infix notation.

Minimal definition: divMod or (div and mod)

Methods
div :: a -> a -> a
mod :: a -> a -> a
divMod :: a -> a -> (a, a)
show/hide Instances
C Int
C Integer
(C a, C a) => C (T a)
(C a, C a) => C (T a)
C a => C (T a)
div :: C a => a -> a -> a
mod :: C a => a -> a -> a
divMod :: C a => a -> a -> (a, a)
Derived functions
divModZero :: (C a, C a) => a -> a -> (a, a)
Allows division by zero. If the divisor is zero, then the divident is returned as remainder.
divides :: (C a, C a) => a -> a -> Bool
sameResidueClass :: (C a, C a) => a -> a -> a -> Bool
safeDiv :: (C a, C a) => a -> a -> a
Returns the result of the division, if divisible. Otherwise undefined.
even :: (C a, C a) => a -> Bool
odd :: (C a, C a) => a -> Bool
Algorithms
decomposeVarPositional :: (C a, C a) => [a] -> a -> [a]
decomposeVarPositional [b0,b1,b2,...] x decomposes x into a positional representation with mixed bases x0 + b0*(x1 + b1*(x2 + b2*x3)) E.g. decomposeVarPositional (repeat 10) 123 == [3,2,1]
decomposeVarPositionalInf :: C a => [a] -> a -> [a]
Properties
propInverse :: (Eq a, C a, C a) => a -> a -> Property
propMultipleDiv :: (Eq a, C a, C a) => a -> a -> Property
propMultipleMod :: (Eq a, C a, C a) => a -> a -> Property
propProjectAddition :: (Eq a, C a, C a) => a -> a -> a -> Property
propProjectMultiplication :: (Eq a, C a, C a) => a -> a -> a -> Property
propUniqueRepresentative :: (Eq a, C a, C a) => a -> a -> a -> Property
propZeroRepresentative :: (Eq a, C a, C a) => a -> Property
propSameResidueClass :: (Eq a, C a, C a) => a -> a -> a -> Property
Produced by Haddock version 0.7