[][src]Struct swar::Bits2

pub struct Bits2<N>(pub N);

This is used when every 2 bits is a number stored in parallel.

Methods

impl Bits2<u128>[src]

pub fn sum_weight2(self) -> Bits4<u128>[src]

pub fn hwd(self, other: Self) -> Self[src]

This computes the hamming weight distance from hamming weights.

use swar::*;

// All combinations of inputs 0-2 (hamming weights)
let a = Bits2(0b00_01_10_00_01_10_00_01_10u128);
let b = Bits2(0b00_00_00_01_01_01_10_10_10u128);
// Expected output weights
let e = Bits2(0b00_01_10_01_00_01_10_01_00u128);

assert_eq!(a.hwd(b), e, "got hamming distances {:b} expected {:b}", a.hwd(b).0, e.0);

pub fn split(self) -> (Bits2x4<u128>, Bits2x4<u128>)[src]

Trait Implementations

impl<N: Copy> Copy for Bits2<N>[src]

impl<N: Debug> Debug for Bits2<N>[src]

impl<N: PartialEq> PartialEq<Bits2<N>> for Bits2<N>[src]

impl<N: Eq> Eq for Bits2<N>[src]

impl<N> From<Bits1x2<N>> for Bits2<N>[src]

impl BitAnd<u128> for Bits2<u128>[src]

type Output = Self

The resulting type after applying the & operator.

impl Shr<u32> for Bits2<u128>[src]

type Output = Self

The resulting type after applying the >> operator.

impl<N: Clone> Clone for Bits2<N>[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<N> Send for Bits2<N> where
    N: Send

impl<N> Sync for Bits2<N> where
    N: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]