pub struct BitVec2048 { /* private fields */ }Expand description
A 2048-bit bitvector.
The vector is stored as 32 little-endian 64-bit words.
Bit n resides in word n / 64, at position n % 64.
Implementations§
Source§impl BitVec2048
impl BitVec2048
Sourcepub fn intersection_popcount(&self, other: &Self) -> u32
pub fn intersection_popcount(&self, other: &Self) -> u32
Count the number of bits set in A & B without allocating a temporary.
This is the fundamental primitive for bulk Tanimoto computation:
hoisting the query popcount and reusing this per db entry avoids
the per-pair allocation of self.and(other).popcount().
Sourcepub fn tanimoto_with_counts(
&self,
other: &Self,
self_popcount: u32,
other_popcount: u32,
) -> f32
pub fn tanimoto_with_counts( &self, other: &Self, self_popcount: u32, other_popcount: u32, ) -> f32
Tanimoto similarity given precomputed popcounts, returning f32.
Use when calling one query against many db entries: hoist
self_popcount = query.popcount() outside the loop, compute
other_popcount = db_entry.popcount() once per entry, then call
this instead of tanimoto() to avoid redundant allocation and
recomputation.
Returns 1.0 when union is zero (both all-zero convention).
Sourcepub fn tanimoto(&self, other: &Self) -> f64
pub fn tanimoto(&self, other: &Self) -> f64
Tanimoto similarity: |A & B| / |A | B|.
Returns 1.0 when both vectors are all-zero (the empty-set convention).
Sourcepub fn dice(&self, other: &Self) -> f64
pub fn dice(&self, other: &Self) -> f64
Dice similarity: 2|A & B| / (|A| + |B|).
Returns 1.0 when both vectors are all-zero.
Sourcepub fn fold(&self, bits: usize) -> Self
pub fn fold(&self, bits: usize) -> Self
XOR-fold this 2048-bit vector to bits bits.
The upper half is XOR-folded into the lower half, and the upper half is zeroed. This is applied recursively until the target width is reached.
bits must be 1024, 512, or 256.
§Panics
Panics if bits is not one of 1024, 512, or 256.
Sourcepub fn to_bitvecn(&self) -> BitVecN
pub fn to_bitvecn(&self) -> BitVecN
Convert to a variable-length BitVecN with the same bits.
Trait Implementations§
Source§impl Clone for BitVec2048
impl Clone for BitVec2048
Source§fn clone(&self) -> BitVec2048
fn clone(&self) -> BitVec2048
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BitVec2048
impl Debug for BitVec2048
Source§impl Default for BitVec2048
impl Default for BitVec2048
impl Eq for BitVec2048
Source§impl PartialEq for BitVec2048
impl PartialEq for BitVec2048
Source§fn eq(&self, other: &BitVec2048) -> bool
fn eq(&self, other: &BitVec2048) -> bool
self and other values to be equal, and is used by ==.