Skip to main content

total_bits

Function total_bits 

Source
pub fn total_bits(local_dims: &[usize]) -> Result<u64, IndexKeyError>
Expand description

Total bit width of the bit-packed key for local_dims.

§Errors

Returns IndexKeyError::ZeroDimension naming the first zero dimension, and IndexKeyError::WidthOverflow if the widths do not fit a u64.

§Examples

use tensor4all_core::index_key::total_bits;
assert_eq!(total_bits(&[2, 2, 2]).unwrap(), 3);
assert_eq!(total_bits(&[4, 3, 1]).unwrap(), 4);
assert_eq!(total_bits(&[]).unwrap(), 0);
assert!(total_bits(&[2, 0]).is_err());