1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Bit-tensor specialization: a packed-word boolean tensor element type and its
//! `SpecTensor` backend, with bitwise operations over the tensor domain.
//!
//! [`BitTensor`] is the storage type (booleans packed into `u64` words) with
//! element-wise [`bit_and`](BitTensor::bit_and), [`bit_or`](BitTensor::bit_or),
//! and [`bit_xor`](BitTensor::bit_xor). [`BitTensorLib`] registers it as the
//! `bool` element-type backend for the base tensor domain.
//!
//! # Examples
//!
//! Pack booleans, combine two tensors bit-for-bit, and unpack the result:
//!
//! ```
//! use sim_lib_numbers_tensor_bit::BitTensor;
//!
//! let left = BitTensor::from_bools(vec![4], &[true, false, true, true]).unwrap();
//! let right = BitTensor::from_bools(vec![4], &[true, true, false, true]).unwrap();
//! let masked = left.bit_and(&right).unwrap();
//! assert_eq!(masked.to_bools(), vec![true, false, false, true]);
//! ```
//!
//! Shape mismatches fail closed rather than truncate:
//!
//! ```
//! use sim_lib_numbers_tensor_bit::BitTensor;
//!
//! let a = BitTensor::from_bools(vec![2], &[true, false]).unwrap();
//! let b = BitTensor::from_bools(vec![3], &[true, false, true]).unwrap();
//! assert!(a.bit_or(&b).is_none());
//! ```
pub use ;
/// Cookbook recipes for this lib, embedded at build time.
pub static RECIPES: EmbeddedDir =
include!;