pub mod and {
crate::bitset::binary_word::define_bitwise_binary_op! {
op_id: "vyre-primitives::bitset::and",
fn_name: bitset_and,
op_kind: And,
combine: |a, b| a & b,
inventory_words: 2,
inventory_lhs: [0xFF00, 0x0F0F],
inventory_rhs: [0xF0F0, 0xFF00],
inventory_expected: [0xF000, 0x0F00],
single_lhs: [0xFFFF_FFFF],
single_rhs: [0xFFFF_FFFF],
single_expected: [0xFFFF_FFFF],
boundary_lhs: [0x8000_0000, 0x0000_0001],
boundary_rhs: [0x8000_0000, 0x0000_0001],
boundary_expected: [0x8000_0000, 0x0000_0001]
}
}
pub mod and_into {
crate::bitset::binary_word::define_bitwise_in_place_op! {
op_id: "vyre-primitives::bitset::and_into",
fn_name: bitset_and_into,
op_kind: And,
combine: |target: u32, operand: u32| target & operand,
inventory_words: 2,
inventory_target: [0xFFFF, 0xF0F0],
inventory_operand: [0xFF00, 0xFFFF],
inventory_expected: [0xFF00, 0xF0F0],
cases: {
full_mask_is_identity: {
target: [0xDEAD_BEEF, 0x1234_5678],
operand: [0xFFFF_FFFF, 0xFFFF_FFFF],
expected: [0xDEAD_BEEF, 0x1234_5678]
},
empty_mask_zeros_target: {
target: [0xDEAD_BEEF, 0x1234_5678],
operand: [0, 0],
expected: [0, 0]
},
second_mask_remains_monotone: {
target: [0xFF00, 0xF0F0],
operand: [0x0F00, 0x0F0F],
expected: [0x0F00, 0x0000]
}
}
}
}
pub mod and_not;
pub mod and_not_into {
crate::bitset::binary_word::define_bitwise_in_place_op! {
op_id: "vyre-primitives::bitset::and_not_into",
fn_name: bitset_and_not_into,
op_kind: AndNot,
combine: |target: u32, operand: u32| target & !operand,
inventory_words: 2,
inventory_target: [0xFFFF, 0xF0F0],
inventory_operand: [0x0F0F, 0x00FF],
inventory_expected: [0xF0F0, 0xF000],
cases: {
subtraction_drops_waypoint_bits: {
target: [0xFFFF, 0xF0F0],
operand: [0xFF00, 0x00F0],
expected: [0x00FF, 0xF000]
},
empty_subtrahend_is_identity: {
target: [0xDEAD_BEEF, 0x1234_5678],
operand: [0, 0],
expected: [0xDEAD_BEEF, 0x1234_5678]
},
full_subtrahend_zeros_target: {
target: [0xDEAD_BEEF, 0x1234_5678],
operand: [0xFFFF_FFFF, 0xFFFF_FFFF],
expected: [0, 0]
},
idempotent_on_repeat_shape: {
target: [0x00FF],
operand: [0xFF00],
expected: [0x00FF]
}
}
}
}
pub mod any;
pub(crate) mod binary_word;
pub(crate) mod bit_update;
pub mod clear_bit {
crate::bitset::bit_update::define_bit_update_op! {
op_id: "vyre-primitives::bitset::clear_bit",
fn_name: bitset_clear_bit,
kind: Clear,
inventory_input: [0xFFFF_FFFF, 0xFFFF_FFFF],
inventory_expected: [0xFFFF_FFFE, 0xFFFF_FFFF]
}
}
pub mod contains;
pub mod copy;
pub mod equal;
pub mod four_russians;
pub mod frontier;
pub mod not;
pub mod or {
crate::bitset::binary_word::define_bitwise_binary_op! {
op_id: "vyre-primitives::bitset::or",
fn_name: bitset_or,
op_kind: Or,
combine: |a, b| a | b,
inventory_words: 2,
inventory_lhs: [0xFF00, 0x0F0F],
inventory_rhs: [0x00FF, 0xF0F0],
inventory_expected: [0xFFFF, 0xFFFF],
single_lhs: [0xFFFF_FFFF],
single_rhs: [0x0000_0000],
single_expected: [0xFFFF_FFFF],
boundary_lhs: [0x8000_0000, 0x0000_0000],
boundary_rhs: [0x0000_0000, 0x0000_0001],
boundary_expected: [0x8000_0000, 0x0000_0001]
}
}
pub mod or_into {
crate::bitset::binary_word::define_bitwise_in_place_op! {
op_id: "vyre-primitives::bitset::or_into",
fn_name: bitset_or_into,
op_kind: Or,
combine: |target: u32, operand: u32| target | operand,
inventory_words: 2,
inventory_target: [0xFFFF, 0xF0F0],
inventory_operand: [0x0F0F, 0x00FF],
inventory_expected: [0xFFFF, 0xF0FF],
cases: {
grows_empty_accumulator: {
target: [0, 0],
operand: [0xFF00, 0x0F0F],
expected: [0xFF00, 0x0F0F]
},
reaches_full_union: {
target: [0xFF00, 0x0F0F],
operand: [0x00FF, 0xF0F0],
expected: [0xFFFF, 0xFFFF]
},
repeat_full_union_is_idempotent: {
target: [0xFFFF, 0xFFFF],
operand: [0x00FF, 0xF0F0],
expected: [0xFFFF, 0xFFFF]
}
}
}
}
pub mod popcount;
pub(crate) mod relation;
pub mod select;
pub mod set_bit {
crate::bitset::bit_update::define_bit_update_op! {
op_id: "vyre-primitives::bitset::set_bit",
fn_name: bitset_set_bit,
kind: Set,
inventory_input: [0, 0],
inventory_expected: [1, 0]
}
}
pub mod subset_of;
pub mod test_bit;
pub(crate) mod unary_word;
pub mod xor {
crate::bitset::binary_word::define_bitwise_binary_op! {
op_id: "vyre-primitives::bitset::xor",
fn_name: bitset_xor,
op_kind: Xor,
combine: |a, b| a ^ b,
inventory_words: 1,
inventory_lhs: [0xFFFF_0000],
inventory_rhs: [0x0000_FFFF],
inventory_expected: [0xFFFF_FFFF],
single_lhs: [0xFFFF_FFFF],
single_rhs: [0xFFFF_FFFF],
single_expected: [0x0000_0000],
boundary_lhs: [0x8000_0000, 0x0000_0001],
boundary_rhs: [0x0000_0000, 0x0000_0001],
boundary_expected: [0x8000_0000, 0x0000_0000]
}
}
pub mod xor_into {
crate::bitset::binary_word::define_bitwise_in_place_op! {
op_id: "vyre-primitives::bitset::xor_into",
fn_name: bitset_xor_into,
op_kind: Xor,
combine: |target: u32, operand: u32| target ^ operand,
inventory_words: 2,
inventory_target: [0xFFFF, 0xF0F0],
inventory_operand: [0x0F0F, 0x00FF],
inventory_expected: [0xF0F0, 0xF00F],
cases: {
xor_with_self_zeros: {
target: [0xDEAD_BEEF, 0x1234_5678],
operand: [0xDEAD_BEEF, 0x1234_5678],
expected: [0, 0]
},
xor_with_zero_is_identity: {
target: [0xFFFF, 0x0F0F],
operand: [0, 0],
expected: [0xFFFF, 0x0F0F]
},
xor_is_self_inverse_second_step: {
target: [0x55AA],
operand: [0xFF00],
expected: [0xAAAA]
},
xor_distributes_per_word: {
target: [0x00FF, 0xFF00],
operand: [0x0F0F, 0xF0F0],
expected: [0x0FF0, 0x0FF0]
}
}
}
}
pub mod zero;
pub mod stochastic_compute;
#[must_use]
pub const fn bitset_words(n: u32) -> u32 {
n.div_ceil(32)
}