Copyright | (c) Aleš Bizjak |
---|---|

License | BSD3 |

Maintainer | mikkonecny@gmail.com |

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

Language | Haskell98 |

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
- module Data.Number.MPFR.Mutable.Arithmetic
- module Data.Number.MPFR.Mutable.Special
- module Data.Number.MPFR.Mutable.Misc
- module Data.Number.MPFR.Mutable.Integer

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