hmpfr-0.3.3.4: Haskell binding to the MPFR library

Portabilitynon-portable
Stabilityexperimental
Maintainermikkonecny@gmail.com
Safe HaskellSafe-Infered

Data.Number.MPFR.Mutable

Contents

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

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.

Instances

Eq (MMPFR s) 

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

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

exp :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource

exp2 :: 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

eint :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource

li2 :: MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource

zeta :: MMPFR s -> MMPFR s -> 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

max :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource

min :: MMPFR s -> MMPFR s -> MMPFR s -> RoundMode -> ST s IntSource

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

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