pub struct NonZeroFactorization<Factor, Power, Residual> {
pub sign: NonZeroSign,
pub factors: Vec<(Factor, Power)>,
pub residual: Residual,
}Expand description
Factorization of a nonzero integer or rational number.
Includes a sign.
§Invariant
The three fields together always describe the entire value:
value == sign * residual * product(factor ^ power)The factorization routines are deliberately incomplete, because splitting a large cofactor is
expensive. Whatever they did not decompose is in residual rather than dropped, so the identity
above holds regardless of how they were tuned. Use Self::is_complete to find out whether the
value was decomposed entirely.
Fields§
§sign: NonZeroSignWhether the number is negative.
factors: Vec<(Factor, Power)>(factor, power) tuples.
These factors are often, but not necessarily, primes; they are all larger than 1. The factors should all be smaller than 64 bits and can have negative powers; that is, appear in the denominator. The powers can’t be zero, as this is a sparse representation.
When this field is empty, nothing was decomposed and the value is sign * residual. In
particular, an empty list does not mean that the value is 1 or -1; that is the case
only when the residual is one as well.
residual: ResidualThe part of the value that was not decomposed.
One exactly when the factors describe the entire value, see Self::is_complete. It is
always positive; the sign of the value is in sign.
Implementations§
Source§impl<Factor, Power, Residual: FactorizationResidual> NonZeroFactorization<Factor, Power, Residual>
impl<Factor, Power, Residual: FactorizationResidual> NonZeroFactorization<Factor, Power, Residual>
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the value was decomposed entirely, that is, whether the residual is one.
When this is false, the factors describe only the part of the value that could be split
off cheaply, and multiplying them together does not reproduce the value: the residual is
the missing factor.
Trait Implementations§
Source§impl<Factor: Clone, Power: Clone, Residual: Clone> Clone for NonZeroFactorization<Factor, Power, Residual>
impl<Factor: Clone, Power: Clone, Residual: Clone> Clone for NonZeroFactorization<Factor, Power, Residual>
Source§fn clone(&self) -> NonZeroFactorization<Factor, Power, Residual>
fn clone(&self) -> NonZeroFactorization<Factor, Power, Residual>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more