| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
NumericPrelude.Numeric
Synopsis
- (+), (-) :: C a => a -> a -> a
- (+), (-) :: C a => a -> a -> a
- negate :: C a => a -> a
- zero :: C a => a
- subtract :: C a => a -> a -> a
- sum :: C a => [a] -> a
- sum1 :: C a => [a] -> a
- isZero :: C a => a -> Bool
- (*) :: C a => a -> a -> a
- one :: C a => a
- fromInteger :: C a => Integer -> a
- (^) :: C a => a -> Integer -> a
- ringPower :: (C a, C b) => b -> a -> a
- sqr :: C a => a -> a
- product :: C a => [a] -> a
- product1 :: C a => [a] -> a
- div, mod :: C a => a -> a -> a
- div, mod :: C a => a -> a -> a
- divMod :: C a => a -> a -> (a, a)
- divides :: (C a, C a) => a -> a -> Bool
- even :: (C a, C a) => a -> Bool
- odd :: (C a, C a) => a -> Bool
- (/) :: C a => a -> a -> a
- recip :: C a => a -> a
- fromRational' :: C a => Rational -> a
- (^-) :: C a => a -> Integer -> a
- fieldPower :: (C a, C b) => b -> a -> a
- fromRational :: C a => Rational -> a
- (^/) :: C a => a -> Rational -> a
- sqrt :: C a => a -> a
- pi :: C a => a
- exp, log :: C a => a -> a
- exp, log :: C a => a -> a
- logBase, (**) :: C a => a -> a -> a
- logBase, (**) :: C a => a -> a -> a
- (^?) :: C a => a -> a -> a
- sin, cos, tan :: C a => a -> a
- sin, cos, tan :: C a => a -> a
- sin, cos, tan :: C a => a -> a
- asin, acos, atan :: C a => a -> a
- asin, acos, atan :: C a => a -> a
- asin, acos, atan :: C a => a -> a
- sinh, cosh, tanh :: C a => a -> a
- sinh, cosh, tanh :: C a => a -> a
- sinh, cosh, tanh :: C a => a -> a
- asinh, acosh, atanh :: C a => a -> a
- asinh, acosh, atanh :: C a => a -> a
- asinh, acosh, atanh :: C a => a -> a
- abs :: C a => a -> a
- signum :: C a => a -> a
- quot, rem :: C a => a -> a -> a
- quot, rem :: C a => a -> a -> a
- quotRem :: C a => a -> a -> (a, a)
- splitFraction :: (C a, C b) => a -> (b, a)
- fraction :: C a => a -> a
- truncate :: (C a, C b) => a -> b
- round :: (C a, C b) => a -> b
- ceiling, floor :: (C a, C b) => a -> b
- ceiling, floor :: (C a, C b) => a -> b
- approxRational :: (C a, C a) => a -> a -> Rational
- atan2 :: C a => a -> a -> a
- toRational :: C a => a -> Rational
- toInteger :: C a => a -> Integer
- fromIntegral :: (C a, C b) => a -> b
- isUnit :: C a => a -> Bool
- stdAssociate, stdUnit, stdUnitInv :: C a => a -> a
- stdAssociate, stdUnit, stdUnitInv :: C a => a -> a
- stdAssociate, stdUnit, stdUnitInv :: C a => a -> a
- extendedGCD :: C a => a -> a -> (a, (a, a))
- gcd :: C a => a -> a -> a
- lcm :: C a => a -> a -> a
- euclid :: (C a, C a) => (a -> a -> a) -> a -> a -> a
- extendedEuclid :: (C a, C a) => (a -> a -> (a, a)) -> a -> a -> (a, (a, a))
- type Rational = T Integer
- (%) :: C a => a -> a -> T a
- numerator :: T a -> a
- denominator :: T a -> a
- data Integer
- data Int
- data Float
- data Double
- (*>) :: C a v => a -> v -> v
Documentation
subtract :: C a => a -> a -> a #
subtract is (-) with swapped operand order.
This is the operand order which will be needed in most cases
of partial application.
Sum up all elements of a list. An empty list yields zero.
This function is inappropriate for number types like Peano.
Maybe we should make sum a method of Additive.
This would also make lengthLeft and lengthRight superfluous.
Sum up all elements of a non-empty list. This avoids including a zero which is useful for types where no universal zero is available. ToDo: Should have NonEmpty type.
fromInteger :: C a => Integer -> a #
(^) :: C a => a -> Integer -> a infixr 8 #
The exponent has fixed type Integer in order
to avoid an arbitrarily limitted range of exponents,
but to reduce the need for the compiler to guess the type (default type).
In practice the exponent is most oftenly fixed, and is most oftenly 2.
Fixed exponents can be optimized away and
thus the expensive computation of Integers doesn't matter.
The previous solution used a C constrained type
and the exponent was converted to Integer before computation.
So the current solution is not less efficient.
A variant of ^ with more flexibility is provided by ringPower.
ringPower :: (C a, C b) => b -> a -> a #
A prefix function of '(Algebra.Ring.^)' with a parameter order that fits the needs of partial application and function composition. It has generalised exponent.
See: Argument order of expNat on
http://www.haskell.org/pipermail/haskell-cafe/2006-September/018022.html
fromRational' :: C a => Rational -> a #
fieldPower :: (C a, C b) => b -> a -> a #
A prefix function of '(Algebra.Field.^-)'. It has a generalised exponent.
fromRational :: C a => Rational -> a #
Needed to work around shortcomings in GHC.
splitFraction :: (C a, C b) => a -> (b, a) #
approxRational :: (C a, C a) => a -> a -> Rational #
TODO: Should be moved to a continued fraction module.
toRational :: C a => a -> Rational #
Lossless conversion from any representation of a rational to Rational
fromIntegral :: (C a, C b) => a -> b #
stdAssociate, stdUnit, stdUnitInv :: C a => a -> a #
stdAssociate, stdUnit, stdUnitInv :: C a => a -> a #
stdAssociate, stdUnit, stdUnitInv :: C a => a -> a #
extendedGCD :: C a => a -> a -> (a, (a, a)) #
Compute the greatest common divisor and solve a respective Diophantine equation.
(g,(a,b)) = extendedGCD x y ==>
g==a*x+b*y && g == gcd x yTODO: This method is not appropriate for the PID class, because there are rings like the one of the multivariate polynomials, where for all x and y greatest common divisors of x and y exist, but they cannot be represented as a linear combination of x and y. TODO: The definition of extendedGCD does not return the canonical associate.
The Greatest Common Divisor is defined by:
gcd x y == gcd y x divides z x && divides z y ==> divides z (gcd x y) (specification) divides (gcd x y) x
extendedEuclid :: (C a, C a) => (a -> a -> (a, a)) -> a -> a -> (a, (a, a)) #
denominator :: T a -> a #
Invariant: Jn# and Jp# are used iff value doesn't fit in S#
Useful properties resulting from the invariants:
Instances
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1].
The exact range for a given implementation can be determined by using
minBound and maxBound from the Bounded class.
Instances
| Bounded Int | Since: base-2.1 |
| Enum Int | Since: base-2.1 |
| Eq Int | |
| Integral Int | Since: base-2.0.1 |
| Num Int | Since: base-2.1 |
| Ord Int | |
| Read Int | Since: base-2.1 |
| Real Int | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Int -> Rational # | |
| Show Int | Since: base-2.1 |
| Ix Int | Since: base-2.1 |
| Lift Int | |
| Arbitrary Int | |
| CoArbitrary Int | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Int -> Gen b -> Gen b # | |
| Storable Int | Since: base-2.1 |
Defined in Foreign.Storable | |
| NFData Int | |
Defined in Control.DeepSeq | |
| Random Int | |
| C Int # | |
| C Int # | |
Defined in Algebra.ZeroTestable | |
| C Int # | |
| C Int # | |
| C Int # | |
| C Int # | |
| C Int # | |
| C Int # | |
Defined in Algebra.ToRational Methods toRational :: Int -> Rational # | |
| C Int # | |
| C Int # | |
Defined in Algebra.ToInteger | |
| C Int # | |
| C Int Int # | |
| C Int Int # | |
| C Int Int # | |
Defined in Algebra.NormedSpace.Sum | |
| C Int Int # | |
Defined in Algebra.NormedSpace.Maximum | |
| C Int Int # | |
Defined in Algebra.NormedSpace.Euclidean | |
| Sqr Int Int # | |
Defined in Algebra.NormedSpace.Euclidean | |
| Generic1 (URec Int :: k -> Type) | |
| Functor (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
| Foldable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => URec Int m -> m # foldMap :: Monoid m => (a -> m) -> URec Int a -> m # foldr :: (a -> b -> b) -> b -> URec Int a -> b # foldr' :: (a -> b -> b) -> b -> URec Int a -> b # foldl :: (b -> a -> b) -> b -> URec Int a -> b # foldl' :: (b -> a -> b) -> b -> URec Int a -> b # foldr1 :: (a -> a -> a) -> URec Int a -> a # foldl1 :: (a -> a -> a) -> URec Int a -> a # elem :: Eq a => a -> URec Int a -> Bool # maximum :: Ord a => URec Int a -> a # minimum :: Ord a => URec Int a -> a # | |
| Traversable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
| Eq (URec Int p) | Since: base-4.9.0.0 |
| Ord (URec Int p) | Since: base-4.9.0.0 |
| Show (URec Int p) | Since: base-4.9.0.0 |
| Generic (URec Int p) | |
| data URec Int (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Int :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Int p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
| Eq Float | Note that due to the presence of
Also note that
|
| Floating Float | Since: base-2.1 |
| Ord Float | Note that due to the presence of
Also note that, due to the same,
|
| Read Float | Since: base-2.1 |
| RealFloat Float | Since: base-2.1 |
Defined in GHC.Float Methods floatRadix :: Float -> Integer # floatDigits :: Float -> Int # floatRange :: Float -> (Int, Int) # decodeFloat :: Float -> (Integer, Int) # encodeFloat :: Integer -> Int -> Float # significand :: Float -> Float # scaleFloat :: Int -> Float -> Float # isInfinite :: Float -> Bool # isDenormalized :: Float -> Bool # isNegativeZero :: Float -> Bool # | |
| Lift Float | |
| Arbitrary Float | |
| CoArbitrary Float | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Float -> Gen b -> Gen b # | |
| Storable Float | Since: base-2.1 |
| NFData Float | |
Defined in Control.DeepSeq | |
| Random Float | |
| C Float # | |
| C Float # | |
Defined in Algebra.ZeroTestable | |
| C Float # | |
| C Float # | |
| C Float # | |
| C Float # | |
Defined in Algebra.ToRational Methods toRational :: Float -> Rational # | |
| C Float # | |
| C Float # | |
| C Float # | |
| C Float # | |
Defined in Algebra.RealField | |
| C Float # | |
| C Float # | |
| Power Float # | |
| C Float Float # | |
| C Float Float # | |
Defined in Algebra.VectorSpace | |
| C Float Float # | |
| C Float Float # | |
Defined in Algebra.OccasionallyScalar | |
| C Float Float # | |
Defined in Algebra.NormedSpace.Sum | |
| C Float Float # | |
Defined in Algebra.NormedSpace.Maximum | |
| C Float Float # | |
Defined in Algebra.NormedSpace.Euclidean | |
| Sqr Float Float # | |
Defined in Algebra.NormedSpace.Euclidean | |
| Generic1 (URec Float :: k -> Type) | |
| Functor (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
| Foldable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => URec Float m -> m # foldMap :: Monoid m => (a -> m) -> URec Float a -> m # foldr :: (a -> b -> b) -> b -> URec Float a -> b # foldr' :: (a -> b -> b) -> b -> URec Float a -> b # foldl :: (b -> a -> b) -> b -> URec Float a -> b # foldl' :: (b -> a -> b) -> b -> URec Float a -> b # foldr1 :: (a -> a -> a) -> URec Float a -> a # foldl1 :: (a -> a -> a) -> URec Float a -> a # toList :: URec Float a -> [a] # null :: URec Float a -> Bool # length :: URec Float a -> Int # elem :: Eq a => a -> URec Float a -> Bool # maximum :: Ord a => URec Float a -> a # minimum :: Ord a => URec Float a -> a # | |
| Traversable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Eq (URec Float p) | |
| Ord (URec Float p) | |
Defined in GHC.Generics | |
| Show (URec Float p) | |
| Generic (URec Float p) | |
| data URec Float (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Float :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Float p) | |
Defined in GHC.Generics | |
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
| Eq Double | Note that due to the presence of
Also note that
|
| Floating Double | Since: base-2.1 |
| Ord Double | Note that due to the presence of
Also note that, due to the same,
|
| Read Double | Since: base-2.1 |
| RealFloat Double | Since: base-2.1 |
Defined in GHC.Float Methods floatRadix :: Double -> Integer # floatDigits :: Double -> Int # floatRange :: Double -> (Int, Int) # decodeFloat :: Double -> (Integer, Int) # encodeFloat :: Integer -> Int -> Double # significand :: Double -> Double # scaleFloat :: Int -> Double -> Double # isInfinite :: Double -> Bool # isDenormalized :: Double -> Bool # isNegativeZero :: Double -> Bool # | |
| Lift Double | |
| Arbitrary Double | |
| CoArbitrary Double | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Double -> Gen b -> Gen b # | |
| Storable Double | Since: base-2.1 |
| NFData Double | |
Defined in Control.DeepSeq | |
| Random Double | |
Defined in System.Random | |
| C Double # | |
| C Double # | |
Defined in Algebra.ZeroTestable | |
| C Double # | |
| C Double # | |
| C Double # | |
| C Double # | |
Defined in Algebra.ToRational Methods toRational :: Double -> Rational # | |
| C Double # | |
| C Double # | |
| C Double # | |
| C Double # | |
Defined in Algebra.RealField | |
| C Double # | |
| C Double # | |
Defined in Algebra.FloatingPoint | |
| Power Double # | |
| C Double Double # | |
| C Double Double # | |
Defined in Algebra.VectorSpace | |
| C Double Double # | |
| C Double Double # | |
Defined in Algebra.OccasionallyScalar | |
| C Double Double # | |
Defined in Algebra.NormedSpace.Sum | |
| C Double Double # | |
Defined in Algebra.NormedSpace.Maximum | |
| C Double Double # | |
Defined in Algebra.NormedSpace.Euclidean | |
| Sqr Double Double # | |
Defined in Algebra.NormedSpace.Euclidean | |
| Generic1 (URec Double :: k -> Type) | |
| Functor (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
| Foldable (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => URec Double m -> m # foldMap :: Monoid m => (a -> m) -> URec Double a -> m # foldr :: (a -> b -> b) -> b -> URec Double a -> b # foldr' :: (a -> b -> b) -> b -> URec Double a -> b # foldl :: (b -> a -> b) -> b -> URec Double a -> b # foldl' :: (b -> a -> b) -> b -> URec Double a -> b # foldr1 :: (a -> a -> a) -> URec Double a -> a # foldl1 :: (a -> a -> a) -> URec Double a -> a # toList :: URec Double a -> [a] # null :: URec Double a -> Bool # length :: URec Double a -> Int # elem :: Eq a => a -> URec Double a -> Bool # maximum :: Ord a => URec Double a -> a # minimum :: Ord a => URec Double a -> a # | |
| Traversable (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
| Eq (URec Double p) | Since: base-4.9.0.0 |
| Ord (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: URec Double p -> URec Double p -> Ordering # (<) :: URec Double p -> URec Double p -> Bool # (<=) :: URec Double p -> URec Double p -> Bool # (>) :: URec Double p -> URec Double p -> Bool # (>=) :: URec Double p -> URec Double p -> Bool # | |
| Show (URec Double p) | Since: base-4.9.0.0 |
| Generic (URec Double p) | |
| data URec Double (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Double :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |