Flint2-Examples: Examples for the Flint2 library

[ gpl, math, program ] [ Propose Tags ]

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


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2 (info)
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), containers (>=0.6.7 && <0.7), filepath (>=1.4.2 && <1.5), Flint2 (>=0.1.0.4 && <0.2.0.0), 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-17T12:34:26Z
Distributions
Executables zeta_zeros, taylor_integrals, swinnerton_dyer_poly, stirling_matrix, real_roots, radix, qadic, primegen, poly_roots, pi_digits, partitions, padic, multi_crt, machin, logistic, l_values, l_central, keiper_li, integrals, hilbert_matrix_ca, hilbert_matrix, function_benchmark, fq_poly, fpwrap, fmpz_poly_factor_zassenhaus, fmpz_mpoly_factor, fmpz_mod_poly, fmpq_poly, factor_integer, expression, elementary, dft, delta_qexp, crt, complex_plot, class_poly, binet, bernoulli
Downloads 65 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2023-11-17 [all 2 reports]

Readme for Flint2-Examples-0.1.0.2

[back to package description]

examples of complex_plot

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

  • Install the C-library available from Flint. There are packages available for various operating systems.

  • Install the Haskell interface with

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