This namespace contains an implementation of a ModInt
datatype and various
operations for creating and working with ModInt
instances. See "Modular
Arithmetic" on Wikipedia
for more details about modular arithmetic.
sicmutils.modint
also extends many SICMUtils generic operations
to the ModInt
datatype.
This namespace contains an implementation of a [[ModInt]] datatype and various operations for creating and working with [[ModInt]] instances. See ["Modular Arithmetic"](https://en.wikipedia.org/wiki/Modular_arithmetic) on Wikipedia for more details about modular arithmetic. [[sicmutils.modint]] also extends many SICMUtils generic operations to the [[ModInt]] datatype.
(chinese-remainder & modints)
Accepts a sequence of ModInt
instances (where the modulus :m
of
all ModInt
instances are relatively prime), and returns a ModInt
x
such that (:i input) == (mod x (:m input))
.
For example:
(let [a1 (m/make 2 5)
a2 (m/make 3 13)]
[(= 42 (chinese-remainder a1 a2))
(= (:i a1) (mod cr (:m a1)))
(= (:i a2) (mod cr (:m a2)))])
;;=> [true true true]
[Chinese Remainder Algorithm](https://en.wikipedia.org/wiki/Chinese_remainder_theorem). Accepts a sequence of [[ModInt]] instances (where the modulus `:m` of all [[ModInt]] instances are relatively prime), and returns a [[ModInt]] `x` such that `(:i input) == (mod x (:m input))`. For example: ```clojure (let [a1 (m/make 2 5) a2 (m/make 3 13)] [(= 42 (chinese-remainder a1 a2)) (= (:i a1) (mod cr (:m a1))) (= (:i a2) (mod cr (:m a2)))]) ;;=> [true true true] ```
(make i m)
Returns an instance of ModInt
that represents integer i
with integral
modulus m
.
Returns an instance of [[ModInt]] that represents integer `i` with integral modulus `m`.
(modint? x)
Returns true if x
is an instance of ModInt
, false otherwise.
Returns true if `x` is an instance of [[ModInt]], false otherwise.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close