Struct modular_equations::LinEq
source · [−]pub struct LinEq<T: UInt> {
pub a: T,
pub b: T,
pub c: T,
pub modu: T,
}Expand description
Type for linear equations with unsigned terms only.
Linear modular equations are of the form ax + b = c (mod modu) where
coefficients a, b and c must be nonnegative for this type. Also
modu must be the same unsigned type and strictly larger than one. Solve
method of this type will panic if the modulo doesn’t satisfy this requirement.
Fields
a: Tb: Tc: Tmodu: TImplementations
sourceimpl<T: UInt> LinEq<T>
impl<T: UInt> LinEq<T>
sourcepub fn solve(&self) -> Option<Vec<T>>
pub fn solve(&self) -> Option<Vec<T>>
Solve linear modular equation ax + b = c (mod modu).
There will be 0 to N solutions x, 0 case occurring when gcd(a, modu) doesn’t divide the c coefficient and on the contrary, magnitude of N depending on the equation. If gcd(a, modu) == 1, there will be a unique solution.
If a % modu == 0 (0 is the smallest nonnegative representative of [a]), there are no solutions since the variable x vanishes from the equation.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for LinEq<T> where
T: RefUnwindSafe,
impl<T> Send for LinEq<T>
impl<T> Sync for LinEq<T>
impl<T> Unpin for LinEq<T> where
T: Unpin,
impl<T> UnwindSafe for LinEq<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more