hmpfr-0.4.4: Haskell binding to the MPFR library

Copyright(c) Aleš Bizjak
LicenseBSD3
Maintainermikkonecny@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

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) Source # 

Methods

(==) :: MMPFR s -> MMPFR s -> Bool #

(/=) :: MMPFR s -> MMPFR s -> Bool #

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 MPFR Source #

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 MPFR Source #

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 functions

Integer related functions

For documentation on particular functions see http://www.mpfr.org/mpfr-current/mpfr.html#Integer-Related-Functions