MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / unpack_cold

Function unpack_cold

nodedb-codec/src/vector_quant/ternary/packing.rs:46–59  ·  view source on GitHub ↗

Unpack cold 5-trits-per-byte format back to `i8` trits.

(cold: &[u8], dim: usize)

Source from the content-addressed store, hash-verified

44
45/// Unpack cold 5-trits-per-byte format back to `i8` trits.
46pub fn unpack_cold(cold: &[u8], dim: usize) -> Vec<i8> {
47 let mut out = Vec::with_capacity(dim);
48 'outer: for &byte in cold {
49 let mut v = byte;
50 for _ in 0..5 {
51 if out.len() >= dim {
52 break 'outer;
53 }
54 out.push(u8_to_trit(v % 3));
55 v /= 3;
56 }
57 }
58 out
59}
60
61/// Pack trits into hot 2-bpw format (4 trits per byte).
62///

Callers 2

cold_to_hotFunction · 0.85

Calls 3

u8_to_tritFunction · 0.85
lenMethod · 0.45
pushMethod · 0.45

Tested by 1