pub trait EuclideanRing: PrincipalIdealRing {
// Required methods
fn euclidean_div_rem(
&self,
lhs: Self::Element,
rhs: &Self::Element,
) -> (Self::Element, Self::Element);
fn euclidean_deg(&self, val: &Self::Element) -> Option<usize>;
// Provided methods
fn euclidean_div(
&self,
lhs: Self::Element,
rhs: &Self::Element,
) -> Self::Element { ... }
fn euclidean_rem(
&self,
lhs: Self::Element,
rhs: &Self::Element,
) -> Self::Element { ... }
}
Expand description
Trait for rings that support euclidean division.
In other words, there is a degree function d(.)
returning nonnegative integers such that for every x, y
with y != 0
there are q, r
with x = qy + r
and
d(r) < d(y)
. Note that q, r
do not have to be unique,
and implementations are free to use any choice.
§Example
let ring = StaticRing::<i64>::RING;
let (q, r) = ring.euclidean_div_rem(14, &6);
assert_el_eq!(ring, 14, ring.add(ring.mul(q, 6), r));
assert!(ring.euclidean_deg(&r) < ring.euclidean_deg(&6));
Required Methods§
Sourcefn euclidean_div_rem(
&self,
lhs: Self::Element,
rhs: &Self::Element,
) -> (Self::Element, Self::Element)
fn euclidean_div_rem( &self, lhs: Self::Element, rhs: &Self::Element, ) -> (Self::Element, Self::Element)
Computes euclidean division with remainder.
In general, the euclidean division of lhs
by rhs
is a tuple (q, r)
such that
lhs = q * rhs + r
, and r
is “smaller” than “rhs”. The notion of smallness is
given by the smallness of the euclidean degree function EuclideanRing::euclidean_deg()
.
Sourcefn euclidean_deg(&self, val: &Self::Element) -> Option<usize>
fn euclidean_deg(&self, val: &Self::Element) -> Option<usize>
Defines how “small” an element is. For details, see EuclideanRing
.
Provided Methods§
Sourcefn euclidean_div(
&self,
lhs: Self::Element,
rhs: &Self::Element,
) -> Self::Element
fn euclidean_div( &self, lhs: Self::Element, rhs: &Self::Element, ) -> Self::Element
Computes euclidean division without remainder.
In general, the euclidean division of lhs
by rhs
is a tuple (q, r)
such that
lhs = q * rhs + r
, and r
is “smaller” than “rhs”. The notion of smallness is
given by the smallness of the euclidean degree function EuclideanRing::euclidean_deg()
.
Sourcefn euclidean_rem(
&self,
lhs: Self::Element,
rhs: &Self::Element,
) -> Self::Element
fn euclidean_rem( &self, lhs: Self::Element, rhs: &Self::Element, ) -> Self::Element
Computes only the remainder of euclidean division.
In general, the euclidean division of lhs
by rhs
is a tuple (q, r)
such that
lhs = q * rhs + r
, and r
is “smaller” than “rhs”. The notion of smallness is
given by the smallness of the euclidean degree function EuclideanRing::euclidean_deg()
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl EuclideanRing for Complex64Base
impl EuclideanRing for Real64Base
impl EuclideanRing for MPZBase
mpir
only.