Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | mikkonecny@gmail.com |
Safe Haskell | Safe-Infered |
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.
- 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
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
Special functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Special-Functions
Miscellaneous functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Miscellaneous functions
Integer related functions
For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Integer-Related-Functions