Flint2-Examples
Introduction
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.
Installation
cabal install Flint2 --lib
- Check that your Cabal default local bin directory does not contain any
conflicting names (see below for a list of binaries)!
- Install the examples with
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
returns
[(3,1),(5,1),(17,1),(257,1),(641,1),(65537,1),(274177,1),(6700417,1),(67280421310721,1),(59649589127497217,1),(5704689200685129054721,1)]
A more advanced example: complex_plot
Try complex_plot by typing:
complex_plot
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,
zeta
-o,--output IMAGE-FILE write output to IMAGE-FILE
-h,--help Show this help tex
Multithreading
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)
GHCRTS='-N10'
export GHCRTS
List of available examples
- bernoulli
- binet
- class_poly
- complex_plot
- crt
- delta_qexp
- dft
- elementary
- expression
- factor_integer
- fmpq_poly
- fmpz_mod_poly
- fmpz_mpoly_factor
- fmpz_poly_factor_zassenhaus
- fpwrap
- fq_poly
- function_benchmark
- hilbert_matrix
- hilbert_matrix_ca
- integrals
- keiper_li
- l_central
- l_values
- logistic
- machin
- multi_crt
- padic
- partitions
- pi_digits
- poly_roots
- primegen
- qadic
- radix
- real_roots
- stirling_matrix
- swinnerton_dyer_poly
- taylor_integrals
- zeta_zeros