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: T

Implementations

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.