[−][src]Struct swar::Bits64
This is used when every 64
bits is a number stored in parallel.
Methods
impl Bits64<u128>
[src]
pub fn from_element(e: u128) -> Self
[src]
Spread a single value out to each element. Must be able to fit.
use swar::*; assert_eq!(Bits64::from_element(0xFEED_FACE_CAFE_BEEF), Bits64(0xFEED_FACE_CAFE_BEEF_FEED_FACE_CAFE_BEEF));
pub fn union(left: Bits128<u128>, right: Bits128<u128>) -> Self
[src]
Takes two inputs that have half-sized elements and compresses them into half the space and puts them in the left and right sides of this.
use swar::*; let input = Bits64(0xFEED_FACE_CAFE_BEEF_FEED_FACE_CAFE_BEEF); let (left, right) = input.halve(); let output = Bits64::union(left, right); assert_eq!(input, output);
pub fn sum_weight2(self) -> Bits128<u128>
[src]
pub fn hwd(self, other: Self) -> Self
[src]
This computes the hamming weight distance from hamming weights.
use swar::*; let bits = 64; for a in 0u128..=bits as u128 { for b in 0u128..=bits as u128 { let aa = Bits64(a | a << bits); let bb = Bits64(b | b << bits); let out = aa.hwd(bb); let diff = (a as i128 - b as i128).abs() as u128; let expected = Bits64(diff | diff << bits); assert_eq!(out, expected); } }
pub fn split(self) -> (Bits128<u128>, Bits128<u128>)
[src]
pub fn halve(self) -> (Bits128<u128>, Bits128<u128>)
[src]
Takes the left and right sides and spreads them out so that the bits in each element are spread out into twice the amount of space.
use swar::*; let input = Bits64(0x0BAD_CAFE << 64 | 0xDEAD_BEEF); let (left, right) = input.halve(); assert_eq!(left, Bits128(0x0BAD_CAFE)); assert_eq!(right, Bits128(0xDEAD_BEEF));
Trait Implementations
impl<N: PartialEq> PartialEq<Bits64<N>> for Bits64<N>
[src]
impl<N: Eq> Eq for Bits64<N>
[src]
impl<N: Debug> Debug for Bits64<N>
[src]
impl Add<Bits64<u128>> for Bits64<u128>
[src]
Note that you are responsible for dealing with overflow. Try to avoid overflow or use the split() method to add in two halves. You can use split() on the result to get the carry bits.
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
impl BitAnd<u128> for Bits64<u128>
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, rhs: u128) -> Self
[src]
impl Shr<u32> for Bits64<u128>
[src]
type Output = Self
The resulting type after applying the >>
operator.
fn shr(self, rhs: u32) -> Self
[src]
impl<N: Copy> Copy for Bits64<N>
[src]
impl<N: Clone> Clone for Bits64<N>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,