fast-arithmetic: Fast functions on integers.

[ algorithms, ats, bsd3, combinatorics, ffi, library, math, number-theory, numerics ] [ Propose Tags ]

Fast functions for number theory and combinatorics with a high level of safety guaranteed by ATS.

[Skip to Readme]


Manual Flags


Enable `-Werror`.


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Change log
Dependencies arithmoi (>=, base (>=4.10 && <5), combinat, hgmp [details]
License BSD-3-Clause
Copyright Copyright: (c) 2018-2021 Vanessa McHale
Author Vanessa McHale
Category Numerics, Math, Algorithms, Number Theory, Combinatorics, FFI, ATS
Bug tracker
Source repo head: git clone
Uploaded by vmchale at 2022-01-17T21:07:50Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 32816 total (144 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for fast-arithmetic-

[back to package description]


Build Status Hackage Dependencies of latest version on Hackage

This is a library for fast arithmetical functions using ATS, with a Haskell wrapper.

It is intended to supplement (but not replace) arithmoi and combinat where speed is important. In particular, this library provides a fast primality check and fast computation of basic combinatorial functions.


Computation Version (ATS/Haskell) Time
isPrime 2017 ATS 117.2 ns
isPrime 2017 Haskell 425.0 ns
φ(2016) ATS 191.5 ns
φ(2016) Haskell 384.8 ns
τ(3018) ATS 337.0 ns
τ(3018) Haskell 660.2 ns
σ(115) ATS 45.41 ns
σ(115) Haskell 322.4 ns
ω(91) ATS 65.52 ns
ω(91) Haskell 345.2 ns
160! ATS 2.363 μs
160! Haskell 6.134μs
79!! ATS 556.2 ns
79!! Haskell 1.355 μs
322 `choose` 16 ATS 467.6 ns
322 `choose` 16 Haskell 956.7 ns
catalan 300 ATS 13.74 μs
catalan 300 Haskell 28.76 μs
permutations 20 10 ATS 202.8 ns
permutations 20 10 Haskell 362.6 ns
maxRegions 45000 ATS 624.1 ns
maxRegions 45000 Haskell 1.064 μs
stirling2 25 8 ATS 3.108 μs
stirling2 25 8 Haskell 9.494 μs


The Haskell library comes with the C bundled, however you will likely want to build from source if you are hacking on the library. To that end, you can install atspkg and build with

atspkg build --pkg-args "./source.dhall"
cabal build


You can find documentation for the Haskell library on Hackage. Unfortunately, there is no documentation for the ATS library, however, the bundled source code is commented.