Open
Description
Note: We encourage higher level functionality including map, Zip, azip!() and so on before resorting indexing.
Still, it is a good benchmark to consider bounds check elision in the most trivial cases — assuming it will improve it in some less trivial cases too.
Set the goal that the following examples compile without extra bounds checks, because their loop counters are already in bounds.
pub fn test1d(a: &Array1<f64>) -> f64 {
let mut sum = 0.;
for i in 0..a.len() {
sum += a[i];
}
sum
}
pub fn test2d(a: &Array2<f64>) -> f64 {
let mut sum = 0.;
for i in 0..a.rows() {
for j in 0..a.cols() {
sum += a[[i, j]];
}
}
sum
}
- test1d_single Tweak bounds checked indexing code (Index, IndexMut) #350
- test1d
- test2d Tweak bounds checked indexing code (Index, IndexMut) #350