mod alternatives and similar packages
Based on the "Math" category.
Alternatively, view mod alternatives based on common mentions on social networks and blogs.
vector9.8 5.8 mod VS vectorAn efficient implementation of Int-indexed arrays (both mutable and immutable), with a powerful loop optimisation framework .
subhask9.8 0.0 mod VS subhaskType safe interface for working in subcategories of Hask
hmatrix9.8 0.0 mod VS hmatrixLinear algebra and numerical computation
statistics9.7 2.2 mod VS statisticsA fast, high quality library for computing with statistics in Haskell.
linear9.7 2.6 mod VS linearLow-dimensional linear algebra primitives for Haskell.
what49.4 6.1 mod VS what4Symbolic formula representation and solver interaction library
HerbiePlugin9.4 0.0 mod VS HerbiePluginGHC plugin that improves Haskell code's numerical stability
hgeometry9.3 8.2 mod VS hgeometryHGeometry is a library for computing with geometric objects in Haskell. It defines basic geometric types and primitives, and it implements some geometric data structures and algorithms. The main two focusses are: (1) Strong type safety, and (2) implementations of geometric algorithms and data structures that have good asymptotic running time guarantees.
units9.2 0.0 mod VS unitsThe home of the units Haskell package
grid9.2 0.0 mod VS gridTools for working with regular grids/graphs/lattices.
algebra9.2 0.0 mod VS algebraconstructive abstract algebra
semigroups9.1 0.0 mod VS semigroupsHaskell 98 semigroups
dimensional9.1 5.7 mod VS dimensionalDimensional library variant built on Data Kinds, Closed Type Families, TypeNats (GHC 7.8+).
computational-algebra9.0 0.0 mod VS computational-algebraGeneral-Purpose Computer Algebra System as an EDSL in Haskell
estimator9.0 0.0 mod VS estimatorState-space estimation algorithms and models
hermit9.0 0.0 mod VS hermitHaskell Equational Reasoning Model-to-Implementation Tunnel
hblas8.9 0.0 mod VS hblashaskell bindings for blas and lapack
matrix8.9 0.0 mod VS matrixA Haskell native implementation of matrices and their operations.
mwc-random8.9 1.0 mod VS mwc-randomA very fast Haskell library for generating high quality pseudo-random numbers.
numhask8.8 2.9 mod VS numhaskA haskell numeric prelude, providing a clean structure for numbers and operations that combine them.
lambda-calculator8.8 4.7 mod VS lambda-calculatorAn introduction to the Lambda Calculus
vector-space8.7 0.0 mod VS vector-spaceVector & affine spaces, linear maps, and derivatives
math-functions8.6 1.0 mod VS math-functionsSpecial mathematical functions
poly8.5 4.7 mod VS polyFast polynomial arithmetic in Haskell (dense and sparse, univariate and multivariate, usual and Laurent)
vector-sized8.5 0.0 mod VS vector-sizedSize tagged vectors
rounded8.5 0.0 mod VS roundedMPFR bindings for Haskell
deeplearning-hs8.5 0.0 mod VS deeplearning-hsDeep Learning in Haskell
bayes-stack8.5 0.0 mod VS bayes-stackFramework for Gibbs sampling of probabilistic models
arrayfire8.5 1.7 mod VS arrayfireHaskell bindings to ArrayFire
optimization8.4 0.0 mod VS optimizationSome numerical optimization methods implemented in Haskell
rampart8.3 0.0 mod VS rampart:european_castle: Determine how intervals relate to each other.
safe-decimal8.3 0.0 mod VS safe-decimalSafe and very efficient arithmetic operations on fixed decimal point numbers
equational-reasoning8.2 2.9 mod VS equational-reasoningAgda-style equational reasoning in Haskell
bed-and-breakfast8.2 0.0 mod VS bed-and-breakfastMatrix operations in 100% pure Haskell
monte-carlo8.2 0.0 mod VS monte-carloA Monte Carlo monad and transformer for Haskell.
type-natural8.2 0.0 mod VS type-naturalType-level well-kinded natural numbers.
sbvPlugin8.2 4.2 mod VS sbvPluginFormally prove properties of Haskell programs using SBV/SMT.
intervals8.1 0.0 mod VS intervalsInterval Arithmetic
Decimal8.1 0.0 mod VS DecimalDecimal numbers with variable precision
simple-smt8.1 2.6 mod VS simple-smtA simple way to interact with an SMT solver process.
monoid-subclasses7.9 0.0 mod VS monoid-subclassesSubclasses of Monoid with a solid theoretical foundation and practical purposes
polynomial7.9 0.0 mod VS polynomialHaskell library for manipulating and evaluating polynomials
eigen7.9 0.0 L2 mod VS eigenHaskel binding for Eigen library. Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
mltool7.9 0.0 mod VS mltoolMachine Learning Toolbox
simd7.8 0.0 mod VS simdsimple interface to ghc's simd vector support
dimensions7.8 0.0 mod VS dimensionsMany-dimensional type-safe numeric ops
manifold-random7.7 4.2 mod VS manifold-randomCoordinate-free hypersurfaces as Haskell types
hTensor7.7 0.0 mod VS hTensorMultidimensional arrays and simple tensor computations
Clean code begins in your IDE with SonarLint
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of mod or a related project?
Modular arithmetic, promoting moduli to the type level, with an emphasis on performance. Originally a part of arithmoi package.
> :set -XDataKinds > 4 + 5 :: Mod 7 (2 `modulo` 7) > 4 - 5 :: Mod 7 (6 `modulo` 7) > 4 * 5 :: Mod 7 (6 `modulo` 7) > 4 / 5 :: Mod 7 (5 `modulo` 7) > 4 ^ 5 :: Mod 7 (2 `modulo` 7)
There are other Haskell packages, employing the very same idea of moduli on the type level,
finite-field. One can also use
which covers some elementary modular arithmetic as well.
Unfortunately, all of them fall behind
in terms of performance. Here is a brief comparison:
Addition. All competing implementations of the modular addition involve divisions, while
modcompletely avoids this costly operation. It makes difference even for small numbers; e. g.,
sum [1..10^7]becomes 5x faster. For larger integers the speed up is even more significant, because the computational complexity of division is not linear.
(*). When a modulo fits a machine word (which is quite a common case on 64-bit architectures),
modimplements the modular multiplication as a couple of CPU instructions and neither allocates intermediate arbitrary-precision values, nor calls
libgmpat all. For computations like
product [1..10^7]this gives a 3x boost to performance in comparison to other libraries.
Inversion. This package relies on
libgmpfor modular inversions. Even for small arguments it is about 5x faster than the native implementation of modular inversion in
Power. This package relies on
libgmpfor modular exponentiation. Even for small arguments it is about 2x faster than competitors.
Overflows. At first glance
modular-arithmeticis more flexible than
mod, because it allows to specify the underlying representation of a modular residue, e. g.,
Mod Integer 100,
Mod Int 100,
Mod Word8 100. We argue that this is a dangerous freedom, vulnerable to overflows. For instance,
20 ^ 2 :: Mod Word8 100returns
44instead of expected
0. Even less expected is that
50 :: Mod Word8 300appears to be
6(remember that type-level numbers are always
What is the difference between
mod is specifically designed to represent modular residues
for mathematical applications (wrapping-around finite numbers) and
provides modular inversion and exponentiation.
The main focus of
finite-typelits is on non-wrapping-around finite numbers,
like indices of arrays in
It features a
Num instance only for the sake of overloading numeric literals.
There is no lawful way to define
Num except modular arithmetic,
finite-typelits viewpoint this is a by-product.
Citius, altius, fortius!
If you are looking for an ultimate performance
and your moduli fit into
which is a drop-in replacement of
but offers almost twice faster addition and multiplication, and much less allocations.
Here are some relative benchmarks (less is better),
which can be reproduced by running
This package was cut out of
to provide a modular arithmetic
with a light dependency footprint. This goal certainly limits the scope of API
to the bare minimum. If you need more advanced tools
(the Chinese remainder theorem, cyclic groups, modular equations, etc.)
please refer to Math.NumberTheory.Moduli.