pub struct SmallBitwiseClause<const N: usize, const W: usize> { /* private fields */ }Expand description
Bitwise clause with compile-time known feature count.
Uses packed u64 bitmasks for SIMD-friendly evaluation. Processes 64 features per AND operation.
§Type Parameters
N- Number of features (compile-time constant)W- Number of u64 words needed:(N + 63) / 64
Implementations§
Source§impl<const N: usize, const W: usize> SmallBitwiseClause<N, W>
impl<const N: usize, const W: usize> SmallBitwiseClause<N, W>
Sourcepub fn new(n_states: i16, polarity: i8) -> Self
pub fn new(n_states: i16, polarity: i8) -> Self
Creates bitwise clause with given states and polarity.
§Panics
Debug-asserts that W == (N + 63) / 64.
Sourcepub const fn n_features(&self) -> usize
pub const fn n_features(&self) -> usize
Returns the number of features (compile-time constant).
Sourcepub const fn include_automata(&self) -> &[Automaton; N]
pub const fn include_automata(&self) -> &[Automaton; N]
Returns read-only access to include automata.
Sourcepub fn include_automata_mut(&mut self) -> &mut [Automaton; N]
pub fn include_automata_mut(&mut self) -> &mut [Automaton; N]
Returns mutable access to include automata.
Sourcepub const fn negated_automata(&self) -> &[Automaton; N]
pub const fn negated_automata(&self) -> &[Automaton; N]
Returns read-only access to negated automata.
Sourcepub fn negated_automata_mut(&mut self) -> &mut [Automaton; N]
pub fn negated_automata_mut(&mut self) -> &mut [Automaton; N]
Returns mutable access to negated automata.
Sourcepub fn rebuild_masks(&mut self)
pub fn rebuild_masks(&mut self)
Rebuilds bitmasks from automaton states.
Call after training before evaluation.
Sourcepub fn evaluate_packed(&self, x_packed: &[u64; W]) -> bool
pub fn evaluate_packed(&self, x_packed: &[u64; W]) -> bool
Evaluates clause using bitwise AND operations.
Processes 64 features per CPU instruction for massive speedup.
§Panics
Debug-asserts that rebuild_masks() was called after training.
Sourcepub fn vote_packed(&self, x_packed: &[u64; W]) -> i32
pub fn vote_packed(&self, x_packed: &[u64; W]) -> i32
Returns polarity if fires, 0 otherwise.
Sourcepub fn vote_weighted_packed(&self, x_packed: &[u64; W]) -> f32
pub fn vote_weighted_packed(&self, x_packed: &[u64; W]) -> f32
Returns weighted vote if fires.
Trait Implementations§
Source§impl<const N: usize, const W: usize> Clone for SmallBitwiseClause<N, W>
impl<const N: usize, const W: usize> Clone for SmallBitwiseClause<N, W>
Source§fn clone(&self) -> SmallBitwiseClause<N, W>
fn clone(&self) -> SmallBitwiseClause<N, W>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more