Euclidean Ring Interface
If a ring provides a meaningful Euclidean structure such that a useful Euclidean remainder can be computed practically, various additional functionality is provided by AbstractAlgebra.jl for those rings. This functionality depends on the following functions existing. An implementation must provide divrem, and the remaining are optional as generic fallbacks exist.
Base.divrem — Method
divrem(f::T, g::T) where T <: RingElemReturn a pair q, r consisting of the Euclidean quotient and remainder of $f$ by $g$. A DivideError should be thrown if $g$ is zero.
AbstractAlgebra.mulmod — Method
mulmod(f::T, g::T, m::T) where T <: RingElemReturn mod(f*g, m) but possibly computed more efficiently.
Base.powermod — Method
powermod(f::T, e::Int, m::T) where T <: RingElemReturn mod(f^e, m) but possibly computed more efficiently.
Base.invmod — Method
invmod(f::T, m::T) where T <: RingElemReturn an inverse of $f$ modulo $m$, meaning that isone(mod(invmod(f,m)*f,m)) returns true.
If such an inverse doesn't exist, a NotInvertibleError should be thrown.
AbstractAlgebra.divides — Method
divides(f::T, g::T) where T <: RingElemReturn a pair, flag, q, where flag is set to true if $g$ divides $f$, in which case q is set to the quotient, or flag is set to false and q is undefined.
AbstractAlgebra.is_divisible_by — Method
is_divisible_by(x::T, y::T) where T <: RingElemCheck if x is divisible by y, i.e. if $x = zy$ for some $z$.
AbstractAlgebra.is_associated — Method
is_associated(x::T, y::T) where T <: RingElemCheck if x and y are associated, i.e. if x is a unit times y.
AbstractAlgebra.remove — Method
remove(f::T, p::T) where T <: RingElemReturn a pair v, q where $p^v$ is the highest power of $p$ dividing $f$ and $q$ is the cofactor after $f$ is divided by this power.
See also valuation, which only returns the valuation.
AbstractAlgebra.valuation — Method
valuation(f::T, p::T) where T <: RingElemReturn v where $p^v$ is the highest power of $p$ dividing $f$.
See also remove.
AbstractAlgebra.gcdinv — Method
gcdinv(f::T, g::T) where T <: RingElemReturn a tuple d, s such that $d = gcd(f, g)$ and $s = (f/d)^{-1} \pmod{g/d}$. Note that $d = 1$ iff $f$ is invertible modulo $g$, in which case $s = f^{-1} \pmod{g}$.
AbstractAlgebra.crt — Method
crt(r1::T, m1::T, r2::T, m2::T; check::Bool=true) where T <: RingElementReturn an element congruent to $r_1$ modulo $m_1$ and $r_2$ modulo $m_2$. If check = true and no solution exists, an error is thrown.
If T is a fixed precision integer type (like Int), the result will be correct if abs(ri) <= abs(mi) and abs(m1 * m2) < typemax(T).
AbstractAlgebra.crt — Method
crt(r::Vector{T}, m::Vector{T}; check::Bool=true) where T <: RingElementReturn an element congruent to $r_i$ modulo $m_i$ for each $i$.
AbstractAlgebra.crt_with_lcm — Method
crt_with_lcm(r1::T, m1::T, r2::T, m2::T; check::Bool=true) where T <: RingElementReturn a tuple consisting of an element congruent to $r_1$ modulo $m_1$ and $r_2$ modulo $m_2$ and the least common multiple of $m_1$ and $m_2$. If check = true and no solution exists, an error is thrown.
AbstractAlgebra.crt_with_lcm — Method
crt_with_lcm(r::Vector{T}, m::Vector{T}; check::Bool=true) where T <: RingElementReturn a tuple consisting of an element congruent to $r_i$ modulo $m_i$ for each $i$ and the least common multiple of the $m_i$.
AbstractAlgebra.coprime_base — Function
coprime_base(S::Vector{RingElement}) -> Vector{RingElement}Returns a coprime base for $S$, i.e. the resulting array contains pairwise coprime objects that multiplicatively generate the same set as the input array.
AbstractAlgebra.coprime_base_push! — Function
coprime_base_push!(S::Vector{RingElem}, a::RingElem) -> Vector{RingElem}Given an array $S$ of coprime elements, insert a new element, that is, find a coprime base for push(S, a).