hmpfr-0.3: Haskell binding to MPFR librarySource codeContentsIndex
Data.Number.MPFR.Mutable
Portabilitynon-portable
Stabilityexperimental
Maintainerales.bizjak0@gmail.com
Contents
Utility functions
Basic arithmetic functions
Special functions
Miscellaneous functions
Integer related functions
Description

This module provides a "mutable" interface to the MPFR library. Functions i this module should have very little overhead over the original C functions.

Type signatures of functions should be self-explanatory. Order of arguments is identical to the one in C functions. See MPFR manual for documentation on particular functions.

All operations are performed in the ST monad so safe transition between mutable and immutable interface is possible with runST. For example mutable interface could be used in inner loops or in local calculations with temporary variables, helping reduce allocation overhead of the pure interface.

Synopsis
data MMPFR s
thaw :: MPFR -> ST s (MMPFR s)
writeMMPFR :: MMPFR s -> MPFR -> ST s ()
freeze :: MMPFR s -> ST s MPFR
unsafeThaw :: MPFR -> ST s (MMPFR s)
unsafeWriteMMPFR :: MMPFR s -> MPFR -> ST s ()
unsafeFreeze :: MMPFR s -> ST s MPFR
add :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
addw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
addi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
addd :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s Int
sub :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
subw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
subi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
subd :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s Int
wsub :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s Int
isub :: MMPFR s -> Int -> MMPFR s -> RoundMode -> ST s Int
dsub :: MMPFR s -> Double -> MMPFR s -> RoundMode -> ST s Int
mul :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
mulw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
muli :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
muld :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s Int
sqr :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
div :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
divw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
divi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
divd :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s Int
wdiv :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s Int
idiv :: MMPFR s -> Int -> MMPFR s -> RoundMode -> ST s Int
ddiv :: MMPFR s -> Double -> MMPFR s -> RoundMode -> ST s Int
sqrt :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sqrtw :: MMPFR s -> Word -> RoundMode -> ST s Int
recSqrt :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
cbrt :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
root :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
pow :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
poww :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
powi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
wpow :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s Int
neg :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
absD :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
dim :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
mul2w :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
mul2i :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
div2w :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s Int
div2i :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s Int
log :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
log2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
log10 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
exp :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
exp2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
exp10 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sin :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
cos :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
tan :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sec :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
csc :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
cot :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sincos :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
asin :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
acos :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
atan :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
atan2 :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sinh :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
cosh :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
tanh :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sinhcosh :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
sech :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
csch :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
coth :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
asinh :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
acosh :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
atanh :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
facw :: MMPFR s -> Word -> RoundMode -> ST s Int
log1p :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
expm1 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
eint :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
li2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
gamma :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
lngamma :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
zeta :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
zetaw :: MMPFR s -> Word -> RoundMode -> ST s Int
erf :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
erfc :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
j0 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
j1 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
jn :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s Int
y0 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
y1 :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
yn :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s Int
fma :: MMPFR s -> MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
fms :: MMPFR s -> MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
agm :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
hypot :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
nextAbove :: MMPFR s -> ST s ()
nextbelow :: MMPFR s -> ST s ()
max :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
min :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
getExp :: MMPFR s -> ST s Exp
getPrec :: MMPFR s -> ST s Precision
rint :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
ceil :: MMPFR s -> MMPFR s -> ST s Int
floor :: MMPFR s -> MMPFR s -> ST s Int
round :: MMPFR s -> MMPFR s -> ST s Int
trunc :: MMPFR s -> MMPFR s -> ST s Int
rintCeil :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
rintFloor :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
rintRound :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
rintTrunc :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
modf :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
frac :: MMPFR s -> MMPFR s -> RoundMode -> ST s Int
fmod :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
remainder :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s Int
Documentation
data MMPFR s Source
A mutable MPFR. Currently this is just a newtype wrapped STRef to a MPFR but this may change in the future for a more efficient implementation. Type argument s is the state variable argument for the ST type.
Utility functions
thaw :: MPFR -> ST s (MMPFR s)Source
Convert an immutable MPFR to a mutable one, making a complete copy.
writeMMPFR :: MMPFR s -> MPFR -> ST s ()Source
Replace the state of the mutable MPFR with a new one, making a complete copy.
freeze :: MMPFR s -> ST s MPFRSource
Convert a mutable MPFR to an immutable one, making a complete copy.
unsafeThaw :: MPFR -> ST s (MMPFR s)Source
Convert an immutable MPFR to a mutable one. The unsafe prefix comes from the fact that limbs of the MPFR are not copied so any modifications done on on the mutable MPFR will reflect on the original. If the original will not be used or limbs of the mutable not modified, then it is safe to use.
unsafeWriteMMPFR :: MMPFR s -> MPFR -> ST s ()Source
Replace the state of the mutable MPFR with a new one. The actual limbs are not copied, so any further modifications on the mutable MPFR will reflect on the MPFR given in as the second argument.
unsafeFreeze :: MMPFR s -> ST s MPFRSource
Convert a mutable MPFR to an immutable one. The unsafe prefix comes from the fact that limbs of the MPFR are not copied so any further modifications on the mutable MPFR will reflect on the "frozen" one. If mutable MPFR will not be modified afterwards, it is perfectly safe to use.
Basic arithmetic functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Basic-Arithmetic-Functions
add :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
addw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
addi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
addd :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s IntSource
sub :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
subw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
subi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
subd :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s IntSource
wsub :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s IntSource
isub :: MMPFR s -> Int -> MMPFR s -> RoundMode -> ST s IntSource
dsub :: MMPFR s -> Double -> MMPFR s -> RoundMode -> ST s IntSource
mul :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
mulw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
muli :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
muld :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s IntSource
sqr :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
div :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
divw :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
divi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
divd :: MMPFR s -> MMPFR s -> Double -> RoundMode -> ST s IntSource
wdiv :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s IntSource
idiv :: MMPFR s -> Int -> MMPFR s -> RoundMode -> ST s IntSource
ddiv :: MMPFR s -> Double -> MMPFR s -> RoundMode -> ST s IntSource
sqrt :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sqrtw :: MMPFR s -> Word -> RoundMode -> ST s IntSource
recSqrt :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
cbrt :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
root :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
pow :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
poww :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
powi :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
wpow :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s IntSource
neg :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
absD :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
dim :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
mul2w :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
mul2i :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
div2w :: MMPFR s -> MMPFR s -> Word -> RoundMode -> ST s IntSource
div2i :: MMPFR s -> MMPFR s -> Int -> RoundMode -> ST s IntSource
Special functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Special-Functions
log :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
log2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
log10 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
exp :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
exp2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
exp10 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sin :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
cos :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
tan :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sec :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
csc :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
cot :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sincos :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
asin :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
acos :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
atan :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
atan2 :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sinh :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
cosh :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
tanh :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sinhcosh :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
sech :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
csch :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
coth :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
asinh :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
acosh :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
atanh :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
facw :: MMPFR s -> Word -> RoundMode -> ST s IntSource
log1p :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
expm1 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
eint :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
li2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
gamma :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
lngamma :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
zeta :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
zetaw :: MMPFR s -> Word -> RoundMode -> ST s IntSource
erf :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
erfc :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
j0 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
j1 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
jn :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s IntSource
y0 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
y1 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
yn :: MMPFR s -> Word -> MMPFR s -> RoundMode -> ST s IntSource
fma :: MMPFR s -> MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
fms :: MMPFR s -> MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
agm :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
hypot :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
Miscellaneous functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Miscellaneous functions
nextAbove :: MMPFR s -> ST s ()Source
nextbelow :: MMPFR s -> ST s ()Source
max :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
min :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
getExp :: MMPFR s -> ST s ExpSource
getPrec :: MMPFR s -> ST s PrecisionSource
Integer related functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Integer-Related-Functions
rint :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
ceil :: MMPFR s -> MMPFR s -> ST s IntSource
floor :: MMPFR s -> MMPFR s -> ST s IntSource
round :: MMPFR s -> MMPFR s -> ST s IntSource
trunc :: MMPFR s -> MMPFR s -> ST s IntSource
rintCeil :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
rintFloor :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
rintRound :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
rintTrunc :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
modf :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
frac :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
fmod :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
remainder :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource
Produced by Haddock version 2.4.2