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

Function bits_per_dim

nodedb-array/src/coord/normalize.rs:25–31  ·  view source on GitHub ↗

Bits per dim for an `n`-dim schema, dividing [`PREFIX_BITS`] evenly (truncated). Returns at least 1 bit per dim.

(n_dims: usize)

Source from the content-addressed store, hash-verified

23/// Bits per dim for an `n`-dim schema, dividing [`PREFIX_BITS`] evenly
24/// (truncated). Returns at least 1 bit per dim.
25pub fn bits_per_dim(n_dims: usize) -> u32 {
26 if n_dims == 0 {
27 return 0;
28 }
29 let raw = PREFIX_BITS / n_dims as u32;
30 raw.max(1)
31}
32
33/// Normalize one cell coordinate into per-dim integer coordinates in
34/// `[0, 2^bits)`. The output `Vec` has the same arity as the schema.

Callers 3

encode_hilbert_prefixFunction · 0.85
encode_zorder_prefixFunction · 0.85
tile_id_for_cellFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected