Browse Source

rm old file

Lennart Braun 1 year ago
parent
commit
d99f4e45d3
1 changed files with 0 additions and 32 deletions
  1. 0 32
      dpf/src/utils.rs

+ 0 - 32
dpf/src/utils.rs

@@ -1,32 +0,0 @@
-use num::PrimInt;
-
-pub fn bit_decompose<T: PrimInt, U: From<bool>>(x: T, n_bits: usize) -> Vec<U> {
-    assert!(n_bits as u32 == T::zero().count_zeros() || x < T::one() << n_bits);
-    (0..n_bits)
-        .map(|i| (x & (T::one() << (n_bits - i - 1)) != T::zero()).into())
-        .collect()
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn test_bit_decompose() {
-        assert_eq!(
-            bit_decompose::<u32, u32>(0x42, 8),
-            vec![0, 1, 0, 0, 0, 0, 1, 0]
-        );
-        assert_eq!(
-            bit_decompose::<u32, u32>(0x42, 10),
-            vec![0, 0, 0, 1, 0, 0, 0, 0, 1, 0]
-        );
-        assert_eq!(
-            bit_decompose::<u32, u32>(0x46015ced, 32),
-            vec![
-                0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0,
-                1, 1, 0, 1,
-            ]
-        );
-    }
-}