I have a struct with an array
struct Model<const D: usize> {
b: f64,
j: f64,
arr: Array<f64, Dim<[Ix, D]>,
}
And I noticed that I cannot access the value in arr via [usize; D], e.g.
impl<const D: usize> for Model<D> {
fn sum(&self) -> f64 {
// ...
let mut cursor = [0; D];
sum += arr[[cursor]]; // fail with error
}
}
because cursor is not implementing corresponding traits:
the trait bound [i32; D]: NdIndex<ndarray::Dim<[usize; D]>>
is not satisfied
I would expect for an arbitrary D > 0
ndarray should be able to handle it. Yet it is not possible. I am wondering if there is a workaround for this kind of isssue.