pub enum Binary {
Zero,
One,
}Expand description
§Binary
A number that is either 0 or 1, stored in a single byte.
Used primarily for the cost in the artificial tableau, where a variable is either minimised out
of the basis or ignored. The same shape appears in a matrix provider whose coefficients can only
be 0 or 1: an incidence matrix, or a set cover. Storing a rational number for such a
coefficient wastes both space and time, so this type stores it in a byte and lets
Absorb apply it to a wide accumulator directly — adding a Zero is nothing at
all, multiplying by a One is a clone.
The variants are declared in increasing numeric order, so the derived Ord is the order of
the integers they stand for. Do not reorder them.
See also the documentation in relp::algorithm::two_phase::tableau::kind::artificial::Cost.
§Absent traits
There is deliberately no Neg and no Negateable impl:
-1 is not a value this type can represent, so negating One would have to lie about its
result. Use SignedOne when the coefficient can have either sign.
There is also no Add<Binary> for Binary, and hence no num_traits::Zero or
num_traits::One: One + One is 2, which this type cannot represent. The only addition
that makes sense is into a type that can hold the result, which is what Absorb
and the Add<Binary> for i32-style impls below do.
Variants§
Trait Implementations§
Source§impl Absorb<Binary> for Rational8
impl Absorb<Binary> for Rational8
Source§fn from_narrow(narrow: &Binary) -> Self
fn from_narrow(narrow: &Binary) -> Self
Source§fn add_narrow(&mut self, narrow: &Binary)
fn add_narrow(&mut self, narrow: &Binary)
Source§fn sub_narrow(&mut self, narrow: &Binary)
fn sub_narrow(&mut self, narrow: &Binary)
Source§fn mul_narrow(&self, narrow: &Binary) -> Self
fn mul_narrow(&self, narrow: &Binary) -> Self
Source§fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
Source§impl Absorb<Binary> for Rational16
impl Absorb<Binary> for Rational16
Source§fn from_narrow(narrow: &Binary) -> Self
fn from_narrow(narrow: &Binary) -> Self
Source§fn add_narrow(&mut self, narrow: &Binary)
fn add_narrow(&mut self, narrow: &Binary)
Source§fn sub_narrow(&mut self, narrow: &Binary)
fn sub_narrow(&mut self, narrow: &Binary)
Source§fn mul_narrow(&self, narrow: &Binary) -> Self
fn mul_narrow(&self, narrow: &Binary) -> Self
Source§fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
Source§impl Absorb<Binary> for Rational32
impl Absorb<Binary> for Rational32
Source§fn from_narrow(narrow: &Binary) -> Self
fn from_narrow(narrow: &Binary) -> Self
Source§fn add_narrow(&mut self, narrow: &Binary)
fn add_narrow(&mut self, narrow: &Binary)
Source§fn sub_narrow(&mut self, narrow: &Binary)
fn sub_narrow(&mut self, narrow: &Binary)
Source§fn mul_narrow(&self, narrow: &Binary) -> Self
fn mul_narrow(&self, narrow: &Binary) -> Self
Source§fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
Source§impl Absorb<Binary> for Rational64
impl Absorb<Binary> for Rational64
Source§fn from_narrow(narrow: &Binary) -> Self
fn from_narrow(narrow: &Binary) -> Self
Source§fn add_narrow(&mut self, narrow: &Binary)
fn add_narrow(&mut self, narrow: &Binary)
Source§fn sub_narrow(&mut self, narrow: &Binary)
fn sub_narrow(&mut self, narrow: &Binary)
Source§fn mul_narrow(&self, narrow: &Binary) -> Self
fn mul_narrow(&self, narrow: &Binary) -> Self
Source§fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
Source§impl Absorb<Binary> for Rational128
impl Absorb<Binary> for Rational128
Source§fn from_narrow(narrow: &Binary) -> Self
fn from_narrow(narrow: &Binary) -> Self
Source§fn add_narrow(&mut self, narrow: &Binary)
fn add_narrow(&mut self, narrow: &Binary)
Source§fn sub_narrow(&mut self, narrow: &Binary)
fn sub_narrow(&mut self, narrow: &Binary)
Source§fn mul_narrow(&self, narrow: &Binary) -> Self
fn mul_narrow(&self, narrow: &Binary) -> Self
Source§fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
Source§impl<const S: usize> Absorb<Binary> for Big<S>
impl<const S: usize> Absorb<Binary> for Big<S>
Source§fn from_narrow(narrow: &Binary) -> Self
fn from_narrow(narrow: &Binary) -> Self
Source§fn add_narrow(&mut self, narrow: &Binary)
fn add_narrow(&mut self, narrow: &Binary)
Source§fn sub_narrow(&mut self, narrow: &Binary)
fn sub_narrow(&mut self, narrow: &Binary)
Source§fn mul_narrow(&self, narrow: &Binary) -> Self
fn mul_narrow(&self, narrow: &Binary) -> Self
Source§fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
fn add_mul_narrow(&mut self, narrow: &Binary, other: &Self)
Source§impl AddAssign<&Binary> for i8
impl AddAssign<&Binary> for i8
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for i16
impl AddAssign<&Binary> for i16
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for i32
impl AddAssign<&Binary> for i32
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for i64
impl AddAssign<&Binary> for i64
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for i128
impl AddAssign<&Binary> for i128
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for u8
impl AddAssign<&Binary> for u8
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for u16
impl AddAssign<&Binary> for u16
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for u32
impl AddAssign<&Binary> for u32
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for u64
impl AddAssign<&Binary> for u64
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl AddAssign<&Binary> for u128
impl AddAssign<&Binary> for u128
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl<const S: usize> AddAssign<&Binary> for Big<S>
impl<const S: usize> AddAssign<&Binary> for Big<S>
Source§fn add_assign(&mut self, rhs: &Binary)
fn add_assign(&mut self, rhs: &Binary)
+= operation. Read moreSource§impl<const S: usize> AddAssign<Binary> for Big<S>
impl<const S: usize> AddAssign<Binary> for Big<S>
Source§fn add_assign(&mut self, rhs: Binary)
fn add_assign(&mut self, rhs: Binary)
+= operation. Read moreimpl Copy for Binary
Source§impl Debug for Binary
Debug forwards to Display, because 0 and 1 read better in test output than the variant
names.
impl Debug for Binary
Debug forwards to Display, because 0 and 1 read better in test output than the variant
names.
Source§impl<const S: usize> DivAssign<&Binary> for Big<S>
impl<const S: usize> DivAssign<&Binary> for Big<S>
Source§fn div_assign(&mut self, rhs: &Binary)
fn div_assign(&mut self, rhs: &Binary)
/= operation. Read moreSource§impl<const S: usize> DivAssign<Binary> for Big<S>
impl<const S: usize> DivAssign<Binary> for Big<S>
Source§fn div_assign(&mut self, rhs: Binary)
fn div_assign(&mut self, rhs: Binary)
/= operation. Read moreimpl Eq for Binary
Source§impl Mul for Binary
Multiplication is closed on {0, 1} and agrees with multiplication of the integers 0 and 1,
unlike addition, which is why this impl exists and Add<Binary> for Binary does not.
impl Mul for Binary
Multiplication is closed on {0, 1} and agrees with multiplication of the integers 0 and 1,
unlike addition, which is why this impl exists and Add<Binary> for Binary does not.
Source§impl<const S: usize> MulAssign<&Binary> for Big<S>
impl<const S: usize> MulAssign<&Binary> for Big<S>
Source§fn mul_assign(&mut self, rhs: &Binary)
fn mul_assign(&mut self, rhs: &Binary)
*= operation. Read moreSource§impl<const S: usize> MulAssign<Binary> for Big<S>
impl<const S: usize> MulAssign<Binary> for Big<S>
Source§fn mul_assign(&mut self, rhs: Binary)
fn mul_assign(&mut self, rhs: Binary)
*= operation. Read moreSource§impl NonZero for Binary
Unlike the other fixed types, this one can be zero, so the answer depends on the value.
impl NonZero for Binary
Unlike the other fixed types, this one can be zero, so the answer depends on the value.