Library
Module
Module type
Parameter
Class
Class type
The functor application Make (M)
defines modular arithmetic operations with a fixed, non‐zero modulus M.modulo
. Because the modulus needs not be repeated for each individual operation, meaningful unary and binary operators can be defined. Operations in the resulting module follow the same specifications as those in module Modular
, with respect to return values, exceptions raised, and time costs.
module _ : sig ... end
val of_int : int -> t
val to_int : t -> int
Conversions to and from integers.
This is Modular.div_nonunique
~modulo
. “Divide, just divide.”
This is Modular.inv_factorize
~modulo
.
val rand : unit -> t
Random generation with the uniform distribution.
The following operators are shortcuts that spare us the need to write of_int
conversions on their operands. The most useful ones are ( *.:)
and (/:.)
, for multiplicative literal constants.
val (~-:.) : int -> t
val (~/:.) : int -> t
val (+..) : int -> int -> t
val (-..) : int -> int -> t
val (*..) : int -> int -> t
val (/..) : int -> int -> t
val (//..) : int -> int -> t
val (**.:) : int -> int -> t