Skip to content

HMath.Numeric

Module index · Numerical conventions

Description

Numeric representations and deterministic IEEE utilities. Standard integer, rational, binary32/64 and complex types are re-exported. Conversions never silently promote precision: BigFloat operations explicitly select the larger operand precision, decimal/fixed operations the larger scale. The host IEEE rounding environment is not modified. Explicit rounding returns software flags.

On this page

API Purpose
Int8 8-bit signed integer type
Int16 16-bit signed integer type
Int32 32-bit signed integer type
Int64 64-bit signed integer type
Word8 8-bit unsigned integer type
Word16 16-bit unsigned integer type
Word32 32-bit unsigned integer type
Word64 64-bit unsigned integer type
Float32 Alias for Haskell Float (IEEE binary32 on supported targets).
Float64 Alias for Haskell Double (IEEE binary64 on supported targets).
Complex A data type representing complex numbers.
:+ forms a complex number from its real and imaginary rectangular components.
Rational Arbitrary-precision rational numbers, represented as a ratio of two Integer values.
RoundingMode Software rounding direction: nearest-even,toward zero,toward positive infinity,or toward negative infinity.
NearestEven Declaration and type contract below.
TowardZero Declaration and type contract below.
TowardPositive Declaration and type contract below.
TowardNegative Declaration and type contract below.
NumericException Software operation flags: invalid operation,division by zero,overflow,underflow,or inexact conversion.
InvalidOperation Declaration and type contract below.
DivisionByZero Declaration and type contract below.
NumericOverflow Declaration and type contract below.
NumericUnderflow Declaration and type contract below.
Inexact Declaration and type contract below.
Rounded Rounded numeric result paired with software exception flags.
Rounded Declaration and type contract below.
roundedValue Value produced by the explicitly selected software rounding operation.
numericalExceptions Software rounding flags; these do not modify the host IEEE exception environment.
roundRational Given software rounding mode then exact Rational, return Integer rounded by nearest-even, toward zero, toward positive infinity, or toward negative infinity.
IEEEClass IEEE classification distinguishing NaN,signed infinity,signed zero,subnormal,and normal finite values.
NotANumber Declaration and type contract below.
PositiveInfinity Declaration and type contract below.
NegativeInfinity Declaration and type contract below.
PositiveZero Declaration and type contract below.
NegativeZero Declaration and type contract below.
Subnormal Declaration and type contract below.
Normal Declaration and type contract below.
classify Classify a RealFloat value as NaN, signed infinity, signed zero, subnormal, or normal.
NumericLimits Format limits and precision metadata derived from RealFloat or the explicit 16-bit format definition.
NumericLimits Declaration and type contract below.
minimumNormal Smallest positive normal value of the represented floating format.
minimumSubnormal Smallest positive subnormal value of the represented floating format.
maximumFinite Largest finite positive value of the represented floating format.
machineEpsilon Gap between one and its next larger representable value.
significandDigits Number of radix digits in the floating significand.
minimumExponent Lower exponent bound returned by RealFloat.floatRange.
maximumExponent Upper exponent bound returned by RealFloat.floatRange.
numericLimits Derived from RealFloat radixdigitsrange, not hardcoded for Double.
integerLimits Given a bounded integral type witness, return its exact (minimum,maximum) as Integers.
float16Limits Limits returned as exact binary64 values for the two 16-bit storage formats.
bfloat16Limits Limits returned as exact binary64 values for the two 16-bit storage formats.
nextAfter Adjacent representable value toward target, including gradual underflow.
frexp x=m*2^e, with abs m in [1/2,1) for nonzero finite binary inputs.
ldexp Given real value then Int exponent, scale by the numeric radix to that power using scaleFloat (binary types use powers of two).
ulpDistance IEEE binary64 distance.
withinULPs Given nonnegative allowed ULP distance then two Doubles, test their binary64 representable-value distance.
safeIntegralCast Convert an integral value to a bounded integral destination only if in range.
saturatingCast Convert an integral value to a bounded integral destination, clamping to minBound/maxBound when out of range.
realToIntegral Given software rounding mode then finite real value, round exactly through Rational then range-check the bounded integral destination.
narrowFloat A narrowing conversion must be finite and exact; choose explicit quantized Float16/BigFloat rounding APIs when loss of precision is intentional.
Float16 IEEE binary16 and bfloat16 storage.
float16 Given rounding mode then Double, round directly to IEEE binary16 and return Rounded storage plus software flags.
fromFloat16 Decode binary16 storage to Double, preserving finite values, signed zero, infinity and NaN classification.
float16Bits Return raw IEEE binary16 storage bits, including sign, exponent and fraction, as Word16.
float16FromBits Construct binary16 storage from raw Word16 without validation or rounding; all bit patterns, including NaNs, are representable.
BFloat16 Opaque bfloat16 storage with 8 exponent and 7 explicit fraction bits.
bfloat16 Given rounding mode then Double, round directly to bfloat16 without an intermediate binary32 rounding.
fromBFloat16 Decode bfloat16 storage to Double, preserving finite values, signed zero and non-finite classification.
bfloat16Bits Return raw bfloat16 storage bits as Word16.
bfloat16FromBits Construct bfloat16 storage from raw Word16 without conversion; all bit patterns are retained.
BigFloat An unbounded-exponent binary floating value backed by an exact Rational, rounded to a runtime number of significant bits (2..1,000,000).
bigFloat Given precision in [2,1000000] bits, rounding mode, then Rational, construct configurable-precision BigFloat plus Inexact flag if rounded.
bigPrecision Return the runtime number of significant binary bits retained by a BigFloat.
bigRational Return the exact Rational value of the already-rounded BigFloat, without another conversion or rounding.
bigToDouble Round BigFloat to host Double through fromRational.
bigAdd Add two BigFloats exactly then round once to the larger operand precision, nearest-even.
bigSubtract Subtract the second BigFloat from the first, rounding once nearest-even at the larger operand precision.
bigMultiply Multiply two BigFloats exactly then round once nearest-even to the larger operand precision.
bigDivide Divide two BigFloats and round once nearest-even to the larger precision.
bigSqrt Compute nonnegative BigFloat square root using integer/rational guard precision then round to the input precision.
bigExp Absolute tail controlled rational series; final rounding is accurate to the requested precision up to one final ulp, not a correctly-rounded promise.
bigLog Compute natural logarithm at the BigFloat precision using rational series and guard bits.
extended Software extended precision: 64 significant bits, unbounded exponent.
mixedAdd Given BigFloat then finite Double, add via exact Rational intermediates at max(BigFloat precision,53) bits, nearest-even.
mixedMultiply Given BigFloat then finite Double, multiply at max(BigFloat precision,53) bits using exact intermediates and nearest-even.
Fixed Runtime-scale base-ten fixed point: coefficient * 10^(-scale).
fixed Given decimal scale in [0,10000], rounding mode, then Rational, return Rounded Fixed and Inexact when required.
fixedScale Return nonnegative decimal scale s of a Fixed value; its exact value is coefficient / 10^s.
fixedCoefficient Return exact stored Integer coefficient of a Fixed value, before division by 10^fixedScale.
fixedRational Return exact coefficient/10^scale represented by a Fixed value, without rounding.
fixedAdd Add two Fixed values using the larger decimal scale, nearest-even, returning Rounded result and software flags.
fixedMultiply Given rounding mode then two Fixed values, multiply and round to their larger scale, returning Rounded result and flags.
fixedDivide Given rounding mode then Fixed numerator and denominator, divide and round to their larger scale.
Decimal Opaque decimal fixed-point value with fractional-place scale, built through decimal with explicit rounding.
decimal Given decimal fractional-place scale, rounding mode, then Rational, construct Rounded Decimal through fixed.
decimalRational Return exact Rational value stored in a Decimal without further rounding.
decimalAdd Add two Decimals at their larger decimal scale, nearest-even, returning Rounded result and software flags.
decimalMultiply Given rounding mode then two Decimals, multiply at the larger fractional-place scale and return Rounded result with flags.
decimalDivide Given rounding mode then two Decimals, divide at their larger scale and return Rounded result.
Interval Finite closed binary64 intervals.
interval Given finite lower and upper bounds in increasing order, construct a closed binary64 Interval.
intervalBounds Return (lower,upper) binary64 endpoints of a validated closed interval.
intervalAdd Add finite intervals with exact Rational endpoint arithmetic rounded outward, enclosing the exact sum.
intervalSubtract Subtract intervals with endpoints [a-d,b-c], rounding outward.
intervalMultiply Multiply intervals using the minimum/maximum of all four endpoint products and outward rounding.
intervalDivide Divide intervals using endpoint quotients with outward rounding.
intervalContains Given interval then Double, test closed-bound membership lower<=x<=upper.
Dual Forward-mode automatic differentiation, f(a+b epsilon), epsilon^2=0.
Dual Declaration and type contract below.
primal Primal component of a forward-mode Dual number.
tangent Directional derivative component of a forward-mode Dual number.
derivative Given a function on Dual numbers then primal input x, seed Dual x 1 and extract the output tangent.
Quaternion Hamilton quaternion (real, i, j, k); multiplication is noncommutative.
Quaternion Declaration and type contract below.
quaternionConjugate For Quaternion real i j k, negate the three imaginary components and preserve the real part.
quaternionNorm Return scaled Euclidean norm of four quaternion components, reducing avoidable intermediate overflow.
quaternionInverse Invert a finite nonzero quaternion using scaled norm arithmetic.
rotateVector Given nonzero finite quaternion q then (x,y,z), return imaginary part of q(0,x,y,z)inverse(q).
DualQuaternion Real and dual quaternion pair, commonly representing a rigid rotation/translation.
DualQuaternion Declaration and type contract below.
dualQuaternionMultiply Multiply real/dual quaternion pairs as (a,b)(c,d)=(ac,ad+bc).
dualQuaternionInverse Invert the real quaternion a, returning (inverse(a), -inverse(a)binverse(a)).
rigidTransform Construct a rigid transform from a nonzero rotation quaternion and translation.
transformPoint Given dual-quaternion transform then point tuple, rotate by its real part and add translation from twice the dual part times the real inverse.
kahanSum Sum a finite list using Kahan compensation; empty input yields zero.
neumaierSum Sum a finite list with Neumaier compensation, correcting for differing term magnitudes.
pairwiseSum Recursively split and sum a finite list to reduce sequential rounding accumulation.
logsumexp Empty input is -infinity; +infinity dominates finite/-infinite inputs.
sumErrorBound Conservative sequential sum bound gamma_(n-1) * sum abs x.

Documentation

Int8

data Int8 #

8-bit signed integer type

Instances

Instances details
PrintfArg Int8

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

FiniteBits Int8

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Int

Bounded Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Enum Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

succ :: Int8 -> Int8 #

pred :: Int8 -> Int8 #

toEnum :: Int -> Int8 #

fromEnum :: Int8 -> Int #

enumFrom :: Int8 -> [Int8] #

enumFromThen :: Int8 -> Int8 -> [Int8] #

enumFromTo :: Int8 -> Int8 -> [Int8] #

enumFromThenTo :: Int8 -> Int8 -> Int8 -> [Int8] #

Storable Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Int8 -> Int #

alignment :: Int8 -> Int #

peekElemOff :: Ptr Int8 -> Int -> IO Int8 #

pokeElemOff :: Ptr Int8 -> Int -> Int8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int8 #

pokeByteOff :: Ptr b -> Int -> Int8 -> IO () #

peek :: Ptr Int8 -> IO Int8 #

poke :: Ptr Int8 -> Int8 -> IO () #

Ix Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

range :: (Int8, Int8) -> [Int8] #

index :: (Int8, Int8) -> Int8 -> Int #

unsafeIndex :: (Int8, Int8) -> Int8 -> Int #

inRange :: (Int8, Int8) -> Int8 -> Bool #

rangeSize :: (Int8, Int8) -> Int #

unsafeRangeSize :: (Int8, Int8) -> Int #

Num Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

(+) :: Int8 -> Int8 -> Int8 #

(-) :: Int8 -> Int8 -> Int8 #

(*) :: Int8 -> Int8 -> Int8 #

negate :: Int8 -> Int8 #

abs :: Int8 -> Int8 #

signum :: Int8 -> Int8 #

fromInteger :: Integer -> Int8 #

Read Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Integral Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

quot :: Int8 -> Int8 -> Int8 #

rem :: Int8 -> Int8 -> Int8 #

div :: Int8 -> Int8 -> Int8 #

mod :: Int8 -> Int8 -> Int8 #

quotRem :: Int8 -> Int8 -> (Int8, Int8) #

divMod :: Int8 -> Int8 -> (Int8, Int8) #

toInteger :: Int8 -> Integer #

Real Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

toRational :: Int8 -> Rational #

Show Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

showsPrec :: Int -> Int8 -> ShowS #

show :: Int8 -> String #

showList :: [Int8] -> ShowS #

Eq Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

(==) :: Int8 -> Int8 -> Bool #

(/=) :: Int8 -> Int8 -> Bool #

Ord Int8

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

compare :: Int8 -> Int8 -> Ordering #

(<) :: Int8 -> Int8 -> Bool #

(<=) :: Int8 -> Int8 -> Bool #

(>) :: Int8 -> Int8 -> Bool #

(>=) :: Int8 -> Int8 -> Bool #

max :: Int8 -> Int8 -> Int8 #

min :: Int8 -> Int8 -> Int8 #

Element Int8 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Int8 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Int8 -> (i, i) #

numElements :: Ix i => UArray i Int8 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Int8)] -> UArray i Int8 #

unsafeAt :: Ix i => UArray i Int8 -> Int -> Int8 #

unsafeReplace :: Ix i => UArray i Int8 -> [(Int, Int8)] -> UArray i Int8 #

unsafeAccum :: Ix i => (Int8 -> e' -> Int8) -> UArray i Int8 -> [(Int, e')] -> UArray i Int8 #

unsafeAccumArray :: Ix i => (Int8 -> e' -> Int8) -> Int8 -> (i, i) -> [(Int, e')] -> UArray i Int8 #

MArray IOUArray Int8 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Int8 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Int8 -> IO Int #

newArray :: Ix i => (i, i) -> Int8 -> IO (IOUArray i Int8) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int8) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int8) #

unsafeRead :: Ix i => IOUArray i Int8 -> Int -> IO Int8 #

unsafeWrite :: Ix i => IOUArray i Int8 -> Int -> Int8 -> IO () #

MArray (STUArray s) Int8 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Int8 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Int8 -> ST s Int #

newArray :: Ix i => (i, i) -> Int8 -> ST s (STUArray s i Int8) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int8) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int8) #

unsafeRead :: Ix i => STUArray s i Int8 -> Int -> ST s Int8 #

unsafeWrite :: Ix i => STUArray s i Int8 -> Int -> Int8 -> ST s () #

Int16

data Int16 #

16-bit signed integer type

Instances

Instances details
PrintfArg Int16

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

FiniteBits Int16

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Int

Bounded Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Enum Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Storable Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Int16 -> Int #

alignment :: Int16 -> Int #

peekElemOff :: Ptr Int16 -> Int -> IO Int16 #

pokeElemOff :: Ptr Int16 -> Int -> Int16 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int16 #

pokeByteOff :: Ptr b -> Int -> Int16 -> IO () #

peek :: Ptr Int16 -> IO Int16 #

poke :: Ptr Int16 -> Int16 -> IO () #

Ix Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Num Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Read Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Integral Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Real Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

toRational :: Int16 -> Rational #

Show Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

showsPrec :: Int -> Int16 -> ShowS #

show :: Int16 -> String #

showList :: [Int16] -> ShowS #

Eq Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

(==) :: Int16 -> Int16 -> Bool #

(/=) :: Int16 -> Int16 -> Bool #

Ord Int16

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

compare :: Int16 -> Int16 -> Ordering #

(<) :: Int16 -> Int16 -> Bool #

(<=) :: Int16 -> Int16 -> Bool #

(>) :: Int16 -> Int16 -> Bool #

(>=) :: Int16 -> Int16 -> Bool #

max :: Int16 -> Int16 -> Int16 #

min :: Int16 -> Int16 -> Int16 #

Element Int16 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Int16 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Int16 -> (i, i) #

numElements :: Ix i => UArray i Int16 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Int16)] -> UArray i Int16 #

unsafeAt :: Ix i => UArray i Int16 -> Int -> Int16 #

unsafeReplace :: Ix i => UArray i Int16 -> [(Int, Int16)] -> UArray i Int16 #

unsafeAccum :: Ix i => (Int16 -> e' -> Int16) -> UArray i Int16 -> [(Int, e')] -> UArray i Int16 #

unsafeAccumArray :: Ix i => (Int16 -> e' -> Int16) -> Int16 -> (i, i) -> [(Int, e')] -> UArray i Int16 #

MArray IOUArray Int16 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Int16 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Int16 -> IO Int #

newArray :: Ix i => (i, i) -> Int16 -> IO (IOUArray i Int16) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int16) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int16) #

unsafeRead :: Ix i => IOUArray i Int16 -> Int -> IO Int16 #

unsafeWrite :: Ix i => IOUArray i Int16 -> Int -> Int16 -> IO () #

MArray (STUArray s) Int16 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Int16 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Int16 -> ST s Int #

newArray :: Ix i => (i, i) -> Int16 -> ST s (STUArray s i Int16) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int16) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int16) #

unsafeRead :: Ix i => STUArray s i Int16 -> Int -> ST s Int16 #

unsafeWrite :: Ix i => STUArray s i Int16 -> Int -> Int16 -> ST s () #

Int32

data Int32 #

32-bit signed integer type

Instances

Instances details
PrintfArg Int32

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

FiniteBits Int32

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Int

Bounded Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Enum Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Storable Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Int32 -> Int #

alignment :: Int32 -> Int #

peekElemOff :: Ptr Int32 -> Int -> IO Int32 #

pokeElemOff :: Ptr Int32 -> Int -> Int32 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int32 #

pokeByteOff :: Ptr b -> Int -> Int32 -> IO () #

peek :: Ptr Int32 -> IO Int32 #

poke :: Ptr Int32 -> Int32 -> IO () #

Ix Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Num Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Read Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Integral Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Real Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

toRational :: Int32 -> Rational #

Show Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

showsPrec :: Int -> Int32 -> ShowS #

show :: Int32 -> String #

showList :: [Int32] -> ShowS #

Eq Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

(==) :: Int32 -> Int32 -> Bool #

(/=) :: Int32 -> Int32 -> Bool #

Ord Int32

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

compare :: Int32 -> Int32 -> Ordering #

(<) :: Int32 -> Int32 -> Bool #

(<=) :: Int32 -> Int32 -> Bool #

(>) :: Int32 -> Int32 -> Bool #

(>=) :: Int32 -> Int32 -> Bool #

max :: Int32 -> Int32 -> Int32 #

min :: Int32 -> Int32 -> Int32 #

Element Int32 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Int32 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Int32 -> (i, i) #

numElements :: Ix i => UArray i Int32 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Int32)] -> UArray i Int32 #

unsafeAt :: Ix i => UArray i Int32 -> Int -> Int32 #

unsafeReplace :: Ix i => UArray i Int32 -> [(Int, Int32)] -> UArray i Int32 #

unsafeAccum :: Ix i => (Int32 -> e' -> Int32) -> UArray i Int32 -> [(Int, e')] -> UArray i Int32 #

unsafeAccumArray :: Ix i => (Int32 -> e' -> Int32) -> Int32 -> (i, i) -> [(Int, e')] -> UArray i Int32 #

MArray IOUArray Int32 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Int32 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Int32 -> IO Int #

newArray :: Ix i => (i, i) -> Int32 -> IO (IOUArray i Int32) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int32) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int32) #

unsafeRead :: Ix i => IOUArray i Int32 -> Int -> IO Int32 #

unsafeWrite :: Ix i => IOUArray i Int32 -> Int -> Int32 -> IO () #

MArray (STUArray s) Int32 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Int32 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Int32 -> ST s Int #

newArray :: Ix i => (i, i) -> Int32 -> ST s (STUArray s i Int32) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int32) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int32) #

unsafeRead :: Ix i => STUArray s i Int32 -> Int -> ST s Int32 #

unsafeWrite :: Ix i => STUArray s i Int32 -> Int -> Int32 -> ST s () #

Int64

data Int64 #

64-bit signed integer type

Instances

Instances details
PrintfArg Int64

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

FiniteBits Int64

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Int

Bounded Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Enum Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Storable Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Int64 -> Int #

alignment :: Int64 -> Int #

peekElemOff :: Ptr Int64 -> Int -> IO Int64 #

pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int64 #

pokeByteOff :: Ptr b -> Int -> Int64 -> IO () #

peek :: Ptr Int64 -> IO Int64 #

poke :: Ptr Int64 -> Int64 -> IO () #

Ix Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Num Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Read Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Integral Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Real Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

toRational :: Int64 -> Rational #

Show Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

showsPrec :: Int -> Int64 -> ShowS #

show :: Int64 -> String #

showList :: [Int64] -> ShowS #

Eq Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

(==) :: Int64 -> Int64 -> Bool #

(/=) :: Int64 -> Int64 -> Bool #

Ord Int64

Since: base-2.1

Instance details

Defined in GHC.Internal.Int

Methods

compare :: Int64 -> Int64 -> Ordering #

(<) :: Int64 -> Int64 -> Bool #

(<=) :: Int64 -> Int64 -> Bool #

(>) :: Int64 -> Int64 -> Bool #

(>=) :: Int64 -> Int64 -> Bool #

max :: Int64 -> Int64 -> Int64 #

min :: Int64 -> Int64 -> Int64 #

Element Int64 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Int64 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Int64 -> (i, i) #

numElements :: Ix i => UArray i Int64 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Int64)] -> UArray i Int64 #

unsafeAt :: Ix i => UArray i Int64 -> Int -> Int64 #

unsafeReplace :: Ix i => UArray i Int64 -> [(Int, Int64)] -> UArray i Int64 #

unsafeAccum :: Ix i => (Int64 -> e' -> Int64) -> UArray i Int64 -> [(Int, e')] -> UArray i Int64 #

unsafeAccumArray :: Ix i => (Int64 -> e' -> Int64) -> Int64 -> (i, i) -> [(Int, e')] -> UArray i Int64 #

MArray IOUArray Int64 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Int64 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Int64 -> IO Int #

newArray :: Ix i => (i, i) -> Int64 -> IO (IOUArray i Int64) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int64) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int64) #

unsafeRead :: Ix i => IOUArray i Int64 -> Int -> IO Int64 #

unsafeWrite :: Ix i => IOUArray i Int64 -> Int -> Int64 -> IO () #

MArray (STUArray s) Int64 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Int64 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Int64 -> ST s Int #

newArray :: Ix i => (i, i) -> Int64 -> ST s (STUArray s i Int64) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int64) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int64) #

unsafeRead :: Ix i => STUArray s i Int64 -> Int -> ST s Int64 #

unsafeWrite :: Ix i => STUArray s i Int64 -> Int -> Int64 -> ST s () #

Word8

data Word8 #

8-bit unsigned integer type

Instances

Instances details
PrintfArg Word8

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

FiniteBits Word8

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Word

Bounded Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Enum Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Storable Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Methods

sizeOf :: Word8 -> Int #

alignment :: Word8 -> Int #

peekElemOff :: Ptr Word8 -> Int -> IO Word8 #

pokeElemOff :: Ptr Word8 -> Int -> Word8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Word8 #

pokeByteOff :: Ptr b -> Int -> Word8 -> IO () #

peek :: Ptr Word8 -> IO Word8 #

poke :: Ptr Word8 -> Word8 -> IO () #

Ix Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Num Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Read Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Read

Integral Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Real Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

toRational :: Word8 -> Rational #

Show Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

showsPrec :: Int -> Word8 -> ShowS #

show :: Word8 -> String #

showList :: [Word8] -> ShowS #

Eq Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(==) :: Word8 -> Word8 -> Bool #

(/=) :: Word8 -> Word8 -> Bool #

Ord Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

compare :: Word8 -> Word8 -> Ordering #

(<) :: Word8 -> Word8 -> Bool #

(<=) :: Word8 -> Word8 -> Bool #

(>) :: Word8 -> Word8 -> Bool #

(>=) :: Word8 -> Word8 -> Bool #

max :: Word8 -> Word8 -> Word8 #

min :: Word8 -> Word8 -> Word8 #

Element Word8 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Word8 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Word8 -> (i, i) #

numElements :: Ix i => UArray i Word8 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Word8)] -> UArray i Word8 #

unsafeAt :: Ix i => UArray i Word8 -> Int -> Word8 #

unsafeReplace :: Ix i => UArray i Word8 -> [(Int, Word8)] -> UArray i Word8 #

unsafeAccum :: Ix i => (Word8 -> e' -> Word8) -> UArray i Word8 -> [(Int, e')] -> UArray i Word8 #

unsafeAccumArray :: Ix i => (Word8 -> e' -> Word8) -> Word8 -> (i, i) -> [(Int, e')] -> UArray i Word8 #

MArray IOUArray Word8 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Word8 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Word8 -> IO Int #

newArray :: Ix i => (i, i) -> Word8 -> IO (IOUArray i Word8) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word8) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word8) #

unsafeRead :: Ix i => IOUArray i Word8 -> Int -> IO Word8 #

unsafeWrite :: Ix i => IOUArray i Word8 -> Int -> Word8 -> IO () #

MArray (STUArray s) Word8 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Word8 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Word8 -> ST s Int #

newArray :: Ix i => (i, i) -> Word8 -> ST s (STUArray s i Word8) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word8) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word8) #

unsafeRead :: Ix i => STUArray s i Word8 -> Int -> ST s Word8 #

unsafeWrite :: Ix i => STUArray s i Word8 -> Int -> Word8 -> ST s () #

Word16

data Word16 #

16-bit unsigned integer type

Instances

Instances details
PrintfArg Word16

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

FiniteBits Word16

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Word

Bounded Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Enum Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Storable Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Ix Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Num Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Read Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Read

Integral Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Real Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Show Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Eq Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(==) :: Word16 -> Word16 -> Bool #

(/=) :: Word16 -> Word16 -> Bool #

Ord Word16

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Element Word16 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Word16 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Word16 -> (i, i) #

numElements :: Ix i => UArray i Word16 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Word16)] -> UArray i Word16 #

unsafeAt :: Ix i => UArray i Word16 -> Int -> Word16 #

unsafeReplace :: Ix i => UArray i Word16 -> [(Int, Word16)] -> UArray i Word16 #

unsafeAccum :: Ix i => (Word16 -> e' -> Word16) -> UArray i Word16 -> [(Int, e')] -> UArray i Word16 #

unsafeAccumArray :: Ix i => (Word16 -> e' -> Word16) -> Word16 -> (i, i) -> [(Int, e')] -> UArray i Word16 #

MArray IOUArray Word16 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Word16 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Word16 -> IO Int #

newArray :: Ix i => (i, i) -> Word16 -> IO (IOUArray i Word16) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word16) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word16) #

unsafeRead :: Ix i => IOUArray i Word16 -> Int -> IO Word16 #

unsafeWrite :: Ix i => IOUArray i Word16 -> Int -> Word16 -> IO () #

MArray (STUArray s) Word16 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Word16 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Word16 -> ST s Int #

newArray :: Ix i => (i, i) -> Word16 -> ST s (STUArray s i Word16) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word16) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word16) #

unsafeRead :: Ix i => STUArray s i Word16 -> Int -> ST s Word16 #

unsafeWrite :: Ix i => STUArray s i Word16 -> Int -> Word16 -> ST s () #

Word32

data Word32 #

32-bit unsigned integer type

Instances

Instances details
PrintfArg Word32

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

FiniteBits Word32

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Word

Bounded Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Enum Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Storable Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Ix Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Num Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Read Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Read

Integral Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Real Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Show Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Eq Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(==) :: Word32 -> Word32 -> Bool #

(/=) :: Word32 -> Word32 -> Bool #

Ord Word32

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Element Word32 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Word32 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Word32 -> (i, i) #

numElements :: Ix i => UArray i Word32 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Word32)] -> UArray i Word32 #

unsafeAt :: Ix i => UArray i Word32 -> Int -> Word32 #

unsafeReplace :: Ix i => UArray i Word32 -> [(Int, Word32)] -> UArray i Word32 #

unsafeAccum :: Ix i => (Word32 -> e' -> Word32) -> UArray i Word32 -> [(Int, e')] -> UArray i Word32 #

unsafeAccumArray :: Ix i => (Word32 -> e' -> Word32) -> Word32 -> (i, i) -> [(Int, e')] -> UArray i Word32 #

MArray IOUArray Word32 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Word32 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Word32 -> IO Int #

newArray :: Ix i => (i, i) -> Word32 -> IO (IOUArray i Word32) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word32) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word32) #

unsafeRead :: Ix i => IOUArray i Word32 -> Int -> IO Word32 #

unsafeWrite :: Ix i => IOUArray i Word32 -> Int -> Word32 -> IO () #

MArray (STUArray s) Word32 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Word32 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Word32 -> ST s Int #

newArray :: Ix i => (i, i) -> Word32 -> ST s (STUArray s i Word32) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word32) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word32) #

unsafeRead :: Ix i => STUArray s i Word32 -> Int -> ST s Word32 #

unsafeWrite :: Ix i => STUArray s i Word32 -> Int -> Word32 -> ST s () #

Word64

data Word64 #

64-bit unsigned integer type

Instances

Instances details
PrintfArg Word64

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

FiniteBits Word64

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Word

Bounded Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Enum Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Storable Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Foreign.Storable

Ix Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Num Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Read Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Read

Integral Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Real Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Show Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Eq Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(==) :: Word64 -> Word64 -> Bool #

(/=) :: Word64 -> Word64 -> Bool #

Ord Word64

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Element Word64 Source # 
Instance details

Defined in HMath.Interchange.Array

IArray UArray Word64 
Instance details

Defined in Data.Array.Base

Methods

bounds :: Ix i => UArray i Word64 -> (i, i) #

numElements :: Ix i => UArray i Word64 -> Int #

unsafeArray :: Ix i => (i, i) -> [(Int, Word64)] -> UArray i Word64 #

unsafeAt :: Ix i => UArray i Word64 -> Int -> Word64 #

unsafeReplace :: Ix i => UArray i Word64 -> [(Int, Word64)] -> UArray i Word64 #

unsafeAccum :: Ix i => (Word64 -> e' -> Word64) -> UArray i Word64 -> [(Int, e')] -> UArray i Word64 #

unsafeAccumArray :: Ix i => (Word64 -> e' -> Word64) -> Word64 -> (i, i) -> [(Int, e')] -> UArray i Word64 #

MArray IOUArray Word64 IO 
Instance details

Defined in Data.Array.IO.Internals

Methods

getBounds :: Ix i => IOUArray i Word64 -> IO (i, i) #

getNumElements :: Ix i => IOUArray i Word64 -> IO Int #

newArray :: Ix i => (i, i) -> Word64 -> IO (IOUArray i Word64) #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word64) #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word64) #

unsafeRead :: Ix i => IOUArray i Word64 -> Int -> IO Word64 #

unsafeWrite :: Ix i => IOUArray i Word64 -> Int -> Word64 -> IO () #

MArray (STUArray s) Word64 (ST s) 
Instance details

Defined in Data.Array.Base

Methods

getBounds :: Ix i => STUArray s i Word64 -> ST s (i, i) #

getNumElements :: Ix i => STUArray s i Word64 -> ST s Int #

newArray :: Ix i => (i, i) -> Word64 -> ST s (STUArray s i Word64) #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word64) #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word64) #

unsafeRead :: Ix i => STUArray s i Word64 -> Int -> ST s Word64 #

unsafeWrite :: Ix i => STUArray s i Word64 -> Int -> Word64 -> ST s () #

Float32

type Float32 = Float Source #

Alias for Haskell Float (IEEE binary32 on supported targets).

Float64

type Float64 = Double Source #

Alias for Haskell Double (IEEE binary64 on supported targets).

Complex

data Complex a #

A data type representing complex numbers.

You can read about complex numbers on wikipedia.

In haskell, complex numbers are represented as a :+ b which can be thought of as representing \(a + bi\). For a complex number z, abs z is a number with the magnitude of z, but oriented in the positive real direction, whereas signum z has the phase of z, but unit magnitude. Apart from the loss of precision due to IEEE754 floating point numbers, it holds that z == abs z * signum z.

Note that Complex's instances inherit the deficiencies from the type parameter's. For example, Complex Float's Ord instance has similar problems to Float's.

As can be seen in the examples, the Foldable and Traversable instances traverse the real part first.

Examples

Expand
>>> (5.0 :+ 2.5) + 6.5
11.5 :+ 2.5
>>> abs (1.0 :+ 1.0) - sqrt 2.0
0.0 :+ 0.0
>>> abs (signum (4.0 :+ 3.0))
1.0 :+ 0.0
>>> foldr (:) [] (1 :+ 2)
[1,2]
>>> mapM print (1 :+ 2)
1
2

Constructors

!a :+ !a infix 6

forms a complex number from its real and imaginary rectangular components.

Instances

Instances details
MonadZip Complex

Since: base-4.15.0.0

Instance details

Defined in Data.Complex

Methods

mzip :: Complex a -> Complex b -> Complex (a, b) #

mzipWith :: (a -> b -> c) -> Complex a -> Complex b -> Complex c #

munzip :: Complex (a, b) -> (Complex a, Complex b) #

Foldable1 Complex

Since: base-4.18.0.0

Instance details

Defined in Data.Foldable1

Methods

fold1 :: Semigroup m => Complex m -> m #

foldMap1 :: Semigroup m => (a -> m) -> Complex a -> m #

foldMap1' :: Semigroup m => (a -> m) -> Complex a -> m #

toNonEmpty :: Complex a -> NonEmpty a #

maximum :: Ord a => Complex a -> a #

minimum :: Ord a => Complex a -> a #

head :: Complex a -> a #

last :: Complex a -> a #

foldrMap1 :: (a -> b) -> (a -> b -> b) -> Complex a -> b #

foldlMap1' :: (a -> b) -> (b -> a -> b) -> Complex a -> b #

foldlMap1 :: (a -> b) -> (b -> a -> b) -> Complex a -> b #

foldrMap1' :: (a -> b) -> (a -> b -> b) -> Complex a -> b #

Eq1 Complex
>>> eq1 (1 :+ 2) (1 :+ 2)
True
>>> eq1 (1 :+ 2) (1 :+ 3)
False

Since: base-4.16.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Complex a -> Complex b -> Bool #

Read1 Complex
>>> readPrec_to_S readPrec1 0 "(2 % 3) :+ (3 % 4)" :: [(Complex Rational, String)]
[(2 % 3 :+ 3 % 4,"")]

Since: base-4.16.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Complex a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Complex a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Complex a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Complex a] #

Show1 Complex
>>> showsPrec1 0 (2 :+ 3) ""
"2 :+ 3"

Since: base-4.16.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Complex a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Complex a] -> ShowS #

Applicative Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

pure :: a -> Complex a #

(<*>) :: Complex (a -> b) -> Complex a -> Complex b #

liftA2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c #

(*>) :: Complex a -> Complex b -> Complex b #

(<*) :: Complex a -> Complex b -> Complex a #

Functor Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

fmap :: (a -> b) -> Complex a -> Complex b #

(<$) :: a -> Complex b -> Complex a #

Monad Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

(>>=) :: Complex a -> (a -> Complex b) -> Complex b #

(>>) :: Complex a -> Complex b -> Complex b #

return :: a -> Complex a #

MonadFix Complex

Since: base-4.15.0.0

Instance details

Defined in Data.Complex

Methods

mfix :: (a -> Complex a) -> Complex a #

Foldable Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

fold :: Monoid m => Complex m -> m #

foldMap :: Monoid m => (a -> m) -> Complex a -> m #

foldMap' :: Monoid m => (a -> m) -> Complex a -> m #

foldr :: (a -> b -> b) -> b -> Complex a -> b #

foldr' :: (a -> b -> b) -> b -> Complex a -> b #

foldl :: (b -> a -> b) -> b -> Complex a -> b #

foldl' :: (b -> a -> b) -> b -> Complex a -> b #

foldr1 :: (a -> a -> a) -> Complex a -> a #

foldl1 :: (a -> a -> a) -> Complex a -> a #

toList :: Complex a -> [a] #

null :: Complex a -> Bool #

length :: Complex a -> Int #

elem :: Eq a => a -> Complex a -> Bool #

maximum :: Ord a => Complex a -> a #

minimum :: Ord a => Complex a -> a #

sum :: Num a => Complex a -> a #

product :: Num a => Complex a -> a #

Traversable Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

traverse :: Applicative f => (a -> f b) -> Complex a -> f (Complex b) #

sequenceA :: Applicative f => Complex (f a) -> f (Complex a) #

mapM :: Monad m => (a -> m b) -> Complex a -> m (Complex b) #

sequence :: Monad m => Complex (m a) -> m (Complex a) #

Generic1 Complex 
Instance details

Defined in Data.Complex

Associated Types

type Rep1 Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

from1 :: Complex a -> Rep1 Complex a #

to1 :: Rep1 Complex a -> Complex a #

Data a => Data (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Complex a -> c (Complex a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Complex a) #

toConstr :: Complex a -> Constr #

dataTypeOf :: Complex a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Complex a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Complex a)) #

gmapT :: (forall b. Data b => b -> b) -> Complex a -> Complex a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Complex a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Complex a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) #

RealFloat a => Floating (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

Methods

pi :: Complex a #

exp :: Complex a -> Complex a #

log :: Complex a -> Complex a #

sqrt :: Complex a -> Complex a #

(**) :: Complex a -> Complex a -> Complex a #

logBase :: Complex a -> Complex a -> Complex a #

sin :: Complex a -> Complex a #

cos :: Complex a -> Complex a #

tan :: Complex a -> Complex a #

asin :: Complex a -> Complex a #

acos :: Complex a -> Complex a #

atan :: Complex a -> Complex a #

sinh :: Complex a -> Complex a #

cosh :: Complex a -> Complex a #

tanh :: Complex a -> Complex a #

asinh :: Complex a -> Complex a #

acosh :: Complex a -> Complex a #

atanh :: Complex a -> Complex a #

log1p :: Complex a -> Complex a #

expm1 :: Complex a -> Complex a #

log1pexp :: Complex a -> Complex a #

log1mexp :: Complex a -> Complex a #

Storable a => Storable (Complex a)

Since: base-4.8.0.0

Instance details

Defined in Data.Complex

Methods

sizeOf :: Complex a -> Int #

alignment :: Complex a -> Int #

peekElemOff :: Ptr (Complex a) -> Int -> IO (Complex a) #

pokeElemOff :: Ptr (Complex a) -> Int -> Complex a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Complex a) #

pokeByteOff :: Ptr b -> Int -> Complex a -> IO () #

peek :: Ptr (Complex a) -> IO (Complex a) #

poke :: Ptr (Complex a) -> Complex a -> IO () #

Generic (Complex a) 
Instance details

Defined in Data.Complex

Associated Types

type Rep (Complex a)

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Methods

from :: Complex a -> Rep (Complex a) x #

to :: Rep (Complex a) x -> Complex a #

RealFloat a => Num (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

Methods

(+) :: Complex a -> Complex a -> Complex a #

(-) :: Complex a -> Complex a -> Complex a #

(*) :: Complex a -> Complex a -> Complex a #

negate :: Complex a -> Complex a #

abs :: Complex a -> Complex a #

signum :: Complex a -> Complex a #

fromInteger :: Integer -> Complex a #

Read a => Read (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

RealFloat a => Fractional (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

Methods

(/) :: Complex a -> Complex a -> Complex a #

recip :: Complex a -> Complex a #

fromRational :: Rational -> Complex a #

Show a => Show (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

Methods

showsPrec :: Int -> Complex a -> ShowS #

show :: Complex a -> String #

showList :: [Complex a] -> ShowS #

Eq a => Eq (Complex a)

Since: base-2.1

Instance details

Defined in Data.Complex

Methods

(==) :: Complex a -> Complex a -> Bool #

(/=) :: Complex a -> Complex a -> Bool #

Field (Complex Double) Source # 
Instance details

Defined in HMath.API.Algebra

FloatingPoint (Complex Double) Source # 
Instance details

Defined in HMath.API.Algebra

Numeric (Complex Double) Source # 
Instance details

Defined in HMath.API.Algebra

Ring (Complex Double) Source # 
Instance details

Defined in HMath.API.Algebra

Scalar (Complex Double) Source # 
Instance details

Defined in HMath.API.Algebra

Element (Complex Double) Source # 
Instance details

Defined in HMath.Interchange.Array

Element (Complex Float) Source # 
Instance details

Defined in HMath.Interchange.Array

type Rep1 Complex

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

type Rep (Complex a)

Since: base-4.9.0.0

Instance details

Defined in Data.Complex

Rational

type Rational = Ratio Integer #

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.

RoundingMode

data RoundingMode Source #

Software rounding direction: nearest-even,toward zero,toward positive infinity,or toward negative infinity. Host CPU rounding mode is unchanged.

Instances

Instances details
Show RoundingMode Source # 
Instance details

Defined in HMath.Numeric

Eq RoundingMode Source # 
Instance details

Defined in HMath.Numeric

NumericException

data NumericException Source #

Software operation flags: invalid operation,division by zero,overflow,underflow,or inexact conversion.

Rounded

data Rounded a Source #

Rounded numeric result paired with software exception flags. Inspect flags when intentional precision loss matters.

Constructors

Rounded 

Fields

Instances

Instances details
Show a => Show (Rounded a) Source # 
Instance details

Defined in HMath.Numeric

Methods

showsPrec :: Int -> Rounded a -> ShowS #

show :: Rounded a -> String #

showList :: [Rounded a] -> ShowS #

Eq a => Eq (Rounded a) Source # 
Instance details

Defined in HMath.Numeric

Methods

(==) :: Rounded a -> Rounded a -> Bool #

(/=) :: Rounded a -> Rounded a -> Bool #

roundRational

roundRational :: RoundingMode -> Rational -> Integer Source #

Given software rounding mode then exact Rational, return Integer rounded by nearest-even, toward zero, toward positive infinity, or toward negative infinity. No host rounding flags are changed.

IEEEClass

data IEEEClass Source #

IEEE classification distinguishing NaN,signed infinity,signed zero,subnormal,and normal finite values.

Instances

Instances details
Show IEEEClass Source # 
Instance details

Defined in HMath.Numeric

Eq IEEEClass Source # 
Instance details

Defined in HMath.Numeric

classify

classify :: RealFloat a => a -> IEEEClass Source #

Classify a RealFloat value as NaN, signed infinity, signed zero, subnormal, or normal. Signed zero is distinguished with isNegativeZero.

NumericLimits

data NumericLimits a Source #

Format limits and precision metadata derived from RealFloat or the explicit 16-bit format definition.

Constructors

NumericLimits 

Fields

Instances

Instances details
Show a => Show (NumericLimits a) Source # 
Instance details

Defined in HMath.Numeric

Eq a => Eq (NumericLimits a) Source # 
Instance details

Defined in HMath.Numeric

numericLimits

numericLimits :: RealFloat a => a -> NumericLimits a Source #

Derived from RealFloat radixdigitsrange, not hardcoded for Double.

integerLimits

integerLimits :: (Integral a, Bounded a) => a -> (Integer, Integer) Source #

Given a bounded integral type witness, return its exact (minimum,maximum) as Integers. The witness value is used only to select the type.

float16Limits

float16Limits :: NumericLimits Double Source #

Limits returned as exact binary64 values for the two 16-bit storage formats.

bfloat16Limits

bfloat16Limits :: NumericLimits Double Source #

Limits returned as exact binary64 values for the two 16-bit storage formats.

nextAfter

nextAfter :: RealFloat a => a -> a -> a Source #

Adjacent representable value toward target, including gradual underflow. Equal signed zeros return the target; NaN propagates. Supports binary formats.

frexp

frexp :: RealFloat a => a -> (a, Int) Source #

x=m*2^e, with abs m in [1/2,1) for nonzero finite binary inputs.

ldexp

ldexp :: RealFloat a => a -> Int -> a Source #

Given real value then Int exponent, scale by the numeric radix to that power using scaleFloat (binary types use powers of two). IEEE overflow/underflow follows the host type; no Either check is added.

ulpDistance

ulpDistance :: Double -> Double -> Either MathError Integer Source #

IEEE binary64 distance. Signed zeros compare equal; NaN is rejected.

withinULPs

withinULPs :: Integer -> Double -> Double -> Bool Source #

Given nonnegative allowed ULP distance then two Doubles, test their binary64 representable-value distance. Signed zeros compare equal. Negative tolerance or NaN gives False.

safeIntegralCast

safeIntegralCast :: (Integral a, Integral b, Bounded b) => a -> Either MathError b Source #

Convert an integral value to a bounded integral destination only if in range. Return Left DomainError rather than wrap or truncate out-of-range input.

saturatingCast

saturatingCast :: (Integral a, Integral b, Bounded b) => a -> b Source #

Convert an integral value to a bounded integral destination, clamping to minBound/maxBound when out of range. No error result is produced.

realToIntegral

realToIntegral :: (RealFloat a, Integral b, Bounded b) => RoundingMode -> a -> Either MathError b Source #

Given software rounding mode then finite real value, round exactly through Rational then range-check the bounded integral destination. Non-finite or out-of-range input returns Left DomainError.

narrowFloat

narrowFloat :: (RealFloat a, RealFloat b) => a -> Either MathError b Source #

A narrowing conversion must be finite and exact; choose explicit quantized Float16/BigFloat rounding APIs when loss of precision is intentional.

Float16

data Float16 Source #

IEEE binary16 and bfloat16 storage. Conversion rounds directly from the exact binary64 value (no intermediate binary32 rounding), preserving signed zero and infinity. NaNs are canonical quiet NaNs. All four rounding modes report inexact, overflow and tininess-after-rounding underflow flags.

Instances

Instances details
Show Float16 Source # 
Instance details

Defined in HMath.Numeric

Eq Float16 Source # 
Instance details

Defined in HMath.Numeric

Methods

(==) :: Float16 -> Float16 -> Bool #

(/=) :: Float16 -> Float16 -> Bool #

float16

float16 :: RoundingMode -> Double -> Rounded Float16 Source #

Given rounding mode then Double, round directly to IEEE binary16 and return Rounded storage plus software flags. Preserve signed zero/infinity; canonicalize NaN. Flags report inexact, overflow, and tininess-after-rounding underflow.

fromFloat16

fromFloat16 :: Float16 -> Double Source #

Decode binary16 storage to Double, preserving finite values, signed zero, infinity and NaN classification. Every finite binary16 value is exactly representable as Double.

float16Bits

float16Bits :: Float16 -> Word16 Source #

Return raw IEEE binary16 storage bits, including sign, exponent and fraction, as Word16.

float16FromBits

float16FromBits :: Word16 -> Float16 Source #

Construct binary16 storage from raw Word16 without validation or rounding; all bit patterns, including NaNs, are representable.

BFloat16

data BFloat16 Source #

Opaque bfloat16 storage with 8 exponent and 7 explicit fraction bits. Use bfloat16 for rounded conversion or bfloat16FromBits for exact storage construction.

Instances

Instances details
Show BFloat16 Source # 
Instance details

Defined in HMath.Numeric

Eq BFloat16 Source # 
Instance details

Defined in HMath.Numeric

bfloat16

bfloat16 :: RoundingMode -> Double -> Rounded BFloat16 Source #

Given rounding mode then Double, round directly to bfloat16 without an intermediate binary32 rounding. Return Rounded storage and software flags, preserving signed zero/infinity and canonicalizing NaN.

fromBFloat16

fromBFloat16 :: BFloat16 -> Double Source #

Decode bfloat16 storage to Double, preserving finite values, signed zero and non-finite classification.

bfloat16Bits

bfloat16Bits :: BFloat16 -> Word16 Source #

Return raw bfloat16 storage bits as Word16.

bfloat16FromBits

bfloat16FromBits :: Word16 -> BFloat16 Source #

Construct bfloat16 storage from raw Word16 without conversion; all bit patterns are retained.

BigFloat

data BigFloat Source #

An unbounded-exponent binary floating value backed by an exact Rational, rounded to a runtime number of significant bits (2..1,000,000). Unlike Double, this is genuinely configurable precision. No NaN/infinity or hidden CPU flags. Algebraic operations round once, nearest-even; explicit construction can select any RoundingMode. Transcendentals use guard bits and rational series.

Instances

Instances details
Show BigFloat Source # 
Instance details

Defined in HMath.Numeric

Eq BigFloat Source # 
Instance details

Defined in HMath.Numeric

bigFloat

bigFloat :: Int -> RoundingMode -> Rational -> Either MathError (Rounded BigFloat) Source #

Given precision in [2,1000000] bits, rounding mode, then Rational, construct configurable-precision BigFloat plus Inexact flag if rounded. Invalid precision returns Left InvalidArgument. Exponents are unbounded; no IEEE NaN/infinity is stored.

bigPrecision

bigPrecision :: BigFloat -> Int Source #

Return the runtime number of significant binary bits retained by a BigFloat.

bigRational

bigRational :: BigFloat -> Rational Source #

Return the exact Rational value of the already-rounded BigFloat, without another conversion or rounding.

bigToDouble

bigToDouble :: BigFloat -> Double Source #

Round BigFloat to host Double through fromRational. This may overflow/underflow or lose precision; it returns no software flags or Either validation.

bigAdd

bigAdd :: BigFloat -> BigFloat -> Either MathError BigFloat Source #

Add two BigFloats exactly then round once to the larger operand precision, nearest-even. Return the new BigFloat in Either.

bigSubtract

bigSubtract :: BigFloat -> BigFloat -> Either MathError BigFloat Source #

Subtract the second BigFloat from the first, rounding once nearest-even at the larger operand precision.

bigMultiply

bigMultiply :: BigFloat -> BigFloat -> Either MathError BigFloat Source #

Multiply two BigFloats exactly then round once nearest-even to the larger operand precision.

bigDivide

bigDivide :: BigFloat -> BigFloat -> Either MathError BigFloat Source #

Divide two BigFloats and round once nearest-even to the larger precision. Zero divisor returns Left DomainError.

bigSqrt

bigSqrt :: BigFloat -> Either MathError BigFloat Source #

Compute nonnegative BigFloat square root using integer/rational guard precision then round to the input precision. Negative input returns Left DomainError; zero succeeds.

bigExp

bigExp :: BigFloat -> Either MathError BigFloat Source #

Absolute tail controlled rational series; final rounding is accurate to the requested precision up to one final ulp, not a correctly-rounded promise.

bigLog

bigLog :: BigFloat -> Either MathError BigFloat Source #

Compute natural logarithm at the BigFloat precision using rational series and guard bits. Require positive input; invalid domain/resource limits return Left MathError. Final rounding has the module's documented accuracy limits.

extended

extended :: Rational -> Either MathError BigFloat Source #

Software extended precision: 64 significant bits, unbounded exponent.

mixedAdd

mixedAdd :: BigFloat -> Double -> Either MathError BigFloat Source #

Given BigFloat then finite Double, add via exact Rational intermediates at max(BigFloat precision,53) bits, nearest-even. Non-finite Double fails.

mixedMultiply

mixedMultiply :: BigFloat -> Double -> Either MathError BigFloat Source #

Given BigFloat then finite Double, multiply at max(BigFloat precision,53) bits using exact intermediates and nearest-even. Non-finite Double fails.

Fixed

data Fixed Source #

Runtime-scale base-ten fixed point: coefficient * 10^(-scale). All constructors and arithmetic use explicit rounding and report inexactness.

Instances

Instances details
Show Fixed Source # 
Instance details

Defined in HMath.Numeric

Methods

showsPrec :: Int -> Fixed -> ShowS #

show :: Fixed -> String #

showList :: [Fixed] -> ShowS #

Eq Fixed Source # 
Instance details

Defined in HMath.Numeric

Methods

(==) :: Fixed -> Fixed -> Bool #

(/=) :: Fixed -> Fixed -> Bool #

fixed

fixed :: Int -> RoundingMode -> Rational -> Either MathError (Rounded Fixed) Source #

Given decimal scale in [0,10000], rounding mode, then Rational, return Rounded Fixed and Inexact when required. Invalid scale fails. This scale counts decimal fractional places, not significant digits.

fixedScale

fixedScale :: Fixed -> Int Source #

Return nonnegative decimal scale s of a Fixed value; its exact value is coefficient / 10^s.

fixedCoefficient

fixedCoefficient :: Fixed -> Integer Source #

Return exact stored Integer coefficient of a Fixed value, before division by 10^fixedScale.

fixedRational

fixedRational :: Fixed -> Rational Source #

Return exact coefficient/10^scale represented by a Fixed value, without rounding.

fixedAdd

fixedAdd :: Fixed -> Fixed -> Either MathError (Rounded Fixed) Source #

Add two Fixed values using the larger decimal scale, nearest-even, returning Rounded result and software flags.

fixedMultiply

fixedMultiply :: RoundingMode -> Fixed -> Fixed -> Either MathError (Rounded Fixed) Source #

Given rounding mode then two Fixed values, multiply and round to their larger scale, returning Rounded result and flags.

fixedDivide

fixedDivide :: RoundingMode -> Fixed -> Fixed -> Either MathError (Rounded Fixed) Source #

Given rounding mode then Fixed numerator and denominator, divide and round to their larger scale. Zero divisor returns Left DomainError; successful rounding flags are retained.

Decimal

data Decimal Source #

Opaque decimal fixed-point value with fractional-place scale, built through decimal with explicit rounding. This is not an implicit significant-digit decimal context.

Instances

Instances details
Show Decimal Source # 
Instance details

Defined in HMath.Numeric

Eq Decimal Source # 
Instance details

Defined in HMath.Numeric

Methods

(==) :: Decimal -> Decimal -> Bool #

(/=) :: Decimal -> Decimal -> Bool #

decimal

decimal :: Int -> RoundingMode -> Rational -> Either MathError (Rounded Decimal) Source #

Given decimal fractional-place scale, rounding mode, then Rational, construct Rounded Decimal through fixed. Scale must lie in [0,10000]; no significant-digit interpretation is implied.

decimalRational

decimalRational :: Decimal -> Rational Source #

Return exact Rational value stored in a Decimal without further rounding.

decimalAdd

decimalAdd :: Decimal -> Decimal -> Either MathError (Rounded Decimal) Source #

Add two Decimals at their larger decimal scale, nearest-even, returning Rounded result and software flags.

decimalMultiply

decimalMultiply :: RoundingMode -> Decimal -> Decimal -> Either MathError (Rounded Decimal) Source #

Given rounding mode then two Decimals, multiply at the larger fractional-place scale and return Rounded result with flags.

decimalDivide

decimalDivide :: RoundingMode -> Decimal -> Decimal -> Either MathError (Rounded Decimal) Source #

Given rounding mode then two Decimals, divide at their larger scale and return Rounded result. Zero divisor returns Left DomainError.

Interval

data Interval Source #

Finite closed binary64 intervals. Arithmetic endpoints are rounded outward using exact rationals, so results enclose exact real arithmetic. Unbounded output is rejected; division rejects denominators containing zero.

Instances

Instances details
Show Interval Source # 
Instance details

Defined in HMath.Numeric

Eq Interval Source # 
Instance details

Defined in HMath.Numeric

interval

interval :: Double -> Double -> Either MathError Interval Source #

Given finite lower and upper bounds in increasing order, construct a closed binary64 Interval. Reversed or non-finite bounds fail. Equal endpoints are valid.

intervalBounds

intervalBounds :: Interval -> (Double, Double) Source #

Return (lower,upper) binary64 endpoints of a validated closed interval.

intervalAdd

intervalAdd :: Interval -> Interval -> Either MathError Interval Source #

Add finite intervals with exact Rational endpoint arithmetic rounded outward, enclosing the exact sum. Results requiring unbounded endpoints fail.

intervalSubtract

intervalSubtract :: Interval -> Interval -> Either MathError Interval Source #

Subtract intervals with endpoints [a-d,b-c], rounding outward. Non-finite/unbounded resulting endpoints return Left MathError.

intervalMultiply

intervalMultiply :: Interval -> Interval -> Either MathError Interval Source #

Multiply intervals using the minimum/maximum of all four endpoint products and outward rounding. Reject unbounded output.

intervalDivide

intervalDivide :: Interval -> Interval -> Either MathError Interval Source #

Divide intervals using endpoint quotients with outward rounding. A divisor interval containing zero returns Left DomainError; unbounded output also fails.

intervalContains

intervalContains :: Interval -> Double -> Bool Source #

Given interval then Double, test closed-bound membership lower<=x<=upper. NaN comparisons give False.

Dual

data Dual a Source #

Forward-mode automatic differentiation, f(a+b epsilon), epsilon^2=0. Elementary functions follow host IEEE domains; checked algorithms can inspect both components. abs at zero uses derivative zero (a chosen subgradient).

Constructors

Dual 

Fields

  • primal :: a

    Primal component of a forward-mode Dual number.

  • tangent :: a

    Directional derivative component of a forward-mode Dual number.

Instances

Instances details
Floating a => Floating (Dual a) Source # 
Instance details

Defined in HMath.Numeric

Methods

pi :: Dual a #

exp :: Dual a -> Dual a #

log :: Dual a -> Dual a #

sqrt :: Dual a -> Dual a #

(**) :: Dual a -> Dual a -> Dual a #

logBase :: Dual a -> Dual a -> Dual a #

sin :: Dual a -> Dual a #

cos :: Dual a -> Dual a #

tan :: Dual a -> Dual a #

asin :: Dual a -> Dual a #

acos :: Dual a -> Dual a #

atan :: Dual a -> Dual a #

sinh :: Dual a -> Dual a #

cosh :: Dual a -> Dual a #

tanh :: Dual a -> Dual a #

asinh :: Dual a -> Dual a #

acosh :: Dual a -> Dual a #

atanh :: Dual a -> Dual a #

log1p :: Dual a -> Dual a #

expm1 :: Dual a -> Dual a #

log1pexp :: Dual a -> Dual a #

log1mexp :: Dual a -> Dual a #

Num a => Num (Dual a) Source # 
Instance details

Defined in HMath.Numeric

Methods

(+) :: Dual a -> Dual a -> Dual a #

(-) :: Dual a -> Dual a -> Dual a #

(*) :: Dual a -> Dual a -> Dual a #

negate :: Dual a -> Dual a #

abs :: Dual a -> Dual a #

signum :: Dual a -> Dual a #

fromInteger :: Integer -> Dual a #

Fractional a => Fractional (Dual a) Source # 
Instance details

Defined in HMath.Numeric

Methods

(/) :: Dual a -> Dual a -> Dual a #

recip :: Dual a -> Dual a #

fromRational :: Rational -> Dual a #

Show a => Show (Dual a) Source # 
Instance details

Defined in HMath.Numeric

Methods

showsPrec :: Int -> Dual a -> ShowS #

show :: Dual a -> String #

showList :: [Dual a] -> ShowS #

Eq a => Eq (Dual a) Source # 
Instance details

Defined in HMath.Numeric

Methods

(==) :: Dual a -> Dual a -> Bool #

(/=) :: Dual a -> Dual a -> Bool #

derivative

derivative :: Num a => (Dual a -> Dual a) -> a -> a Source #

Given a function on Dual numbers then primal input x, seed Dual x 1 and extract the output tangent. Arithmeticdomains follow Dual's NumFloating instances; no Either validation is added.

Quaternion

data Quaternion a Source #

Hamilton quaternion (real, i, j, k); multiplication is noncommutative.

Constructors

Quaternion a a a a 

Instances

Instances details
RealFloat a => Num (Quaternion a) Source # 
Instance details

Defined in HMath.Numeric

Show a => Show (Quaternion a) Source # 
Instance details

Defined in HMath.Numeric

Eq a => Eq (Quaternion a) Source # 
Instance details

Defined in HMath.Numeric

Methods

(==) :: Quaternion a -> Quaternion a -> Bool #

(/=) :: Quaternion a -> Quaternion a -> Bool #

quaternionConjugate

quaternionConjugate :: Num a => Quaternion a -> Quaternion a Source #

For Quaternion real i j k, negate the three imaginary components and preserve the real part.

quaternionNorm

quaternionNorm :: RealFloat a => Quaternion a -> a Source #

Return scaled Euclidean norm of four quaternion components, reducing avoidable intermediate overflow. Empty/zero-component quaternion has norm zero.

quaternionInverse

quaternionInverse :: RealFloat a => Quaternion a -> Either MathError (Quaternion a) Source #

Invert a finite nonzero quaternion using scaled norm arithmetic. Zero/non-finite input returns DomainError; non-finite inverse returns NonFiniteResult.

rotateVector

rotateVector :: RealFloat a => Quaternion a -> (a, a, a) -> Either MathError (a, a, a) Source #

Given nonzero finite quaternion q then (x,y,z), return imaginary part of q*(0,x,y,z)*inverse(q). Normalization of q is implicit in the inverse; invalid input/result returns Left MathError.

DualQuaternion

data DualQuaternion a Source #

Real and dual quaternion pair, commonly representing a rigid rotation/translation. Construct normalized rigid transforms with rigidTransform.

Constructors

DualQuaternion (Quaternion a) (Quaternion a) 

Instances

Instances details
Show a => Show (DualQuaternion a) Source # 
Instance details

Defined in HMath.Numeric

Eq a => Eq (DualQuaternion a) Source # 
Instance details

Defined in HMath.Numeric

dualQuaternionMultiply

dualQuaternionMultiply :: RealFloat a => DualQuaternion a -> DualQuaternion a -> DualQuaternion a Source #

Multiply real/dual quaternion pairs as (a,b)*(c,d)=(a*c,a*d+b*c). Return the product using host quaternion arithmetic; no validation or normalization is added.

dualQuaternionInverse

dualQuaternionInverse :: RealFloat a => DualQuaternion a -> Either MathError (DualQuaternion a) Source #

Invert the real quaternion a, returning (inverse(a), -inverse(a)*b*inverse(a)). Invalid real part propagates quaternionInverse failure.

rigidTransform

rigidTransform :: RealFloat a => Quaternion a -> (a, a, a) -> Either MathError (DualQuaternion a) Source #

Construct a rigid transform from a nonzero rotation quaternion and translation.

transformPoint

transformPoint :: RealFloat a => DualQuaternion a -> (a, a, a) -> Either MathError (a, a, a) Source #

Given dual-quaternion transform then point tuple, rotate by its real part and add translation from twice the dual part times the real inverse. Invalid inverse or non-finite result fails.

kahanSum

kahanSum :: Num a => [a] -> a Source #

Sum a finite list using Kahan compensation; empty input yields zero. Arithmetic follows Num and compensation does not promise exact rounding or reject non-finite values.

neumaierSum

neumaierSum :: (Num a, Ord a) => [a] -> a Source #

Sum a finite list with Neumaier compensation, correcting for differing term magnitudes. Empty input gives zero; arithmetic follows the chosen ordered Num type.

pairwiseSum

pairwiseSum :: Num a => [a] -> a Source #

Recursively split and sum a finite list to reduce sequential rounding accumulation. Empty input gives zero. Arithmetic remains that of the chosen Num type.

logsumexp

logsumexp :: RealFloat a => [a] -> Either MathError a Source #

Empty input is -infinity; +infinity dominates finite/-infinite inputs. NaN is rejected, and an all -infinity input is -infinity.

sumErrorBound

sumErrorBound :: RealFloat a => [a] -> Either MathError a Source #

Conservative sequential sum bound gamma_(n-1) * sum abs x. Returns infinity when n*u >= 1 or finite inputs overflow the bound. Does not claim bounds in the presence of underflow; an extra (n-1)*minimumSubnormal term covers it.