[][src]Struct swar::Bits8

pub struct Bits8<N>(pub N);

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

Methods

impl Bits8<u128>[src]

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

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

This computes the hamming weight distance from hamming weights.

use swar::*;
 
let bits = 8;
for a in 0u128..=bits as u128 {
    for b in 0u128..=bits as u128 {
        let aa = Bits8(a | a << bits);
        let bb = Bits8(b | b << bits);
        let out = aa.hwd(bb);
        let diff = (a as i128 - b as i128).abs() as u128;
        let expected = Bits8(diff | diff << bits);
        assert_eq!(out, expected, "got hamming distances {:016b} expected {:016b} ({:08b}, {:08b})", out.0, expected.0, a, b);
    }
}

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

Trait Implementations

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

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

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

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

impl<N> From<Bits4x8<N>> for Bits8<N>[src]

impl<N> From<Bits5x8<N>> for Bits8<N>[src]

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

type Output = Self

The resulting type after applying the & operator.

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

type Output = Self

The resulting type after applying the >> operator.

impl<N: Clone> Clone for Bits8<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 Bits8<N> where
    N: Send

impl<N> Sync for Bits8<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]