Changed loops order in from_fn_generic

This commit is contained in:
Thomas Forgione 2018-06-16 12:57:57 +02:00 committed by Sébastien Crozet
parent 3751602fb5
commit b1616e236c
2 changed files with 20 additions and 2 deletions

View File

@ -186,3 +186,21 @@ fn mat_mul_mat(bench: &mut Bencher) {
test::black_box(a.mul_to(&b, &mut ab));
})
}
#[bench]
fn mat100_from_fn(bench: &mut Bencher) {
bench.iter(|| {
DMatrix::from_fn(100, 100, |a, b| {
a + b
});
})
}
#[bench]
fn mat500_from_fn(bench: &mut Bencher) {
bench.iter(|| {
DMatrix::from_fn(500, 500, |a, b| {
a + b
});
})
}

View File

@ -108,8 +108,8 @@ where
{
let mut res = unsafe { Self::new_uninitialized_generic(nrows, ncols) };
for i in 0..nrows.value() {
for j in 0..ncols.value() {
for i in 0..nrows.value() {
unsafe { *res.get_unchecked_mut(i, j) = f(i, j) }
}
}