(num: u64, shape: &[u64])
| 74 | } |
| 75 | |
| 76 | pub 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)] |
| 90 | mod tests { |
no test coverage detected