MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / number_to_index

Function number_to_index

ciphercore-base/src/broadcast.rs:76–87  ·  view source on GitHub ↗
(num: u64, shape: &[u64])

Source from the content-addressed store, hash-verified

74}
75
76pub fn number_to_index(num: u64, shape: &[u64]) -> Vec<u64> {
77 let mut num_left = num;
78 let mut index = vec![];
79 let mut radix: u64 = shape.iter().product();
80 for d in shape {
81 radix /= d;
82 let digit = num_left / radix;
83 index.push(digit);
84 num_left %= radix;
85 }
86 index
87}
88
89#[cfg(tests)]
90mod tests {

Callers 9

broadcast_to_shapeFunction · 0.85
evaluate_dotFunction · 0.85
evaluate_matmulFunction · 0.85
evaluate_permute_axesFunction · 0.85
general_gemmFunction · 0.85
evaluate_sumFunction · 0.85
evaluate_cum_sumFunction · 0.85
evaluate_nodeMethod · 0.85
mask_to_valueFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected