[−][src]Trait maths_traits::analysis::ordered::ArchimedeanDiv
Division with remainder using an ordering and the Archimedean Property
In a sense, this is extremely similar to Euclidean division and in certain contexts (like the Integers and Naturals), this division satisfies the same relevant axioms. However, they are not always equivalent, the real numbers being a notable exception.
Required methods
fn embed_nat<N: Natural>(n: N) -> Self
Maps a natural number into this structure preserving addition and using the relevant canonical representation
For rings and semirings with One, this representation should map the Natural 1 to 1 in the structure and should also preserve multiplication
fn div_arch(self, rhs: Self) -> Self
the unique integer n
such that n*rhs <= self
and (n+1)*rhs > self
fn rem_arch(self, rhs: Self) -> Self
the remaining difference after dividing by rhs (ie. self - self.div_arch(rhs)*rhs
)
fn div_alg_arch(self, rhs: Self) -> (Self, Self)
Divides self
by rhs
with remainder using the archimdean property
Specifically, this function finds the unique Integer n
and element r
such that:
self = n*rhs + r
n*rhs <= self
(n+1)*rhs > self
Note that the meaning of "Integer" here refers to the canonical representation/mapping of the Integers into this structure by nature of the additive ordering on this structure and not the integers themselves. As such, the quotient returned must be a possible output or negation a possibile output of embed_nat().
Furthermore, because the choice of quotient, the remainder returned must always be non-negative.
For this reason, for primitive types, this method corresponds to the div_euclid and
rem_euclid methods and not the /
and %
operators.