Flint2-Examples: Examples for the Flint2 library

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Examples for Flint2 Haskell bindings for the flint library for number theory.

[Skip to Readme]


Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), containers (>=0.6.7 && <0.7), filepath (>=1.4.2 && <1.5), Flint2 (>= && <, gloss (>=1.13.2 && <1.14), gloss-juicy (>=0.2.3 && <0.3), JuicyPixels (>=3.3.8 && <3.4), mtl (>=2.2.2 && <2.3), optparse-applicative (>=0.18.1 && <0.19), time (>=1.12.2 && <1.13), timeit (>=2.0 && <2.1) [details]
License GPL-2.0-only
Copyright 2023 Hartmut Monien
Author monien
Maintainer hmonien@uni-bonn.de
Category Math
Home page https://github.com/monien/Flint2-Examples#readme
Bug tracker https://github.com/monien/Flint2-Examples/issues
Source repo head: git clone https://github.com/monien/Flint2-Examples
Uploaded by monien at 2023-11-16T19:16:00Z



Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Readme for Flint2-Examples-

[back to package description]

examples ofcomplex_plot



Examples for the Flint2 Haskell wrapper of the Flint library.

Most of these are directly "translated" from C to Haskell so they are written using "imperative" constructs in Haskell to demonstrate the use of the Haskell wrapper (not intended as examples of elegant Haskell code). The structure of programs follows closely the structure of the C code (with some exceptions: e.g. swinnerton_dyer_poly uses a different algorithm, logistic uses a monad transformer instead of a for loop ...)

There are basic benchmarks in some of the programs. In some cases experimental support of multithreading is available. Checkout the options by typing prog -h.


cabal install Flint2 --lib
cabal install Flint2-Examples


Source code

To study the source code download the code from Github with. More documentation will hopefully available soon. Also check the flintlib site.

git clone https://github.com/monien/Flint2-Examples.git

Quick start

A simple example would be the factorization of integers (factor_integers). To find out what options are available use -h:

factor_integers -h

which prints

Factor integers.

Usage: factor_integer INTEGER [-t|--threads THREADS] [--timing]

  Factor integers.

Available options:
  INTEGER                  Integer given as expression (e.g. 2^64+1)
  -t,--threads THREADS     number of threads
  --timing                 timing
  -h,--help                Show this help text

Now typing

factor_integer 2^256-1



A more advanced example: complex_plot

Try complex_plot by typing:


This will plot the phase of the Klein invariant in the upper half plane.

The app complex_plot has many more options. Using the help option one obtains

Plotting special functions in the complex plane.

Usage: complex_plot [--xa XA] [--xb XB] [--ya YA] [--yb YB] [--width WIDTH] 
                    [--height HEIGHT] [-c|--color-mode COLOR-MODE] 
                    [-f|--function FUNCTION] [-o|--output IMAGE-FILE]

  plotting special functions.

Available options:
  -c,--color-mode COLOR-MODE
                           possible values: 0 .. 6
  -f,--function FUNCTION   possible values: agm, ai, barnesg, besseli, besselj,
                           besselk, bessely, bi, digamma, ellipp, ellipsigma,
                           ellipzeta, erf, fresnelc, fresnels, gamma, lgamma,
                           modeta, modetaq, modj, modjq, modlambda, modlambdaq,
  -o,--output IMAGE-FILE   write output to IMAGE-FILE
  -h,--help                Show this help tex


To use the experimental support of multithreading it is most convenient to set the number of cores available using the environment variable GHCRTS (e.g. for 10 cores)

export GHCRTS

List of available examples