Merge pull request #16 from nathanic/master
Fix coordinate calculation in DMat::from_fn().
This commit is contained in:
commit
335bdd8a01
|
@ -3,3 +3,4 @@
|
||||||
doc
|
doc
|
||||||
lib
|
lib
|
||||||
TODO
|
TODO
|
||||||
|
target/
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl<N> DMat<N> {
|
||||||
DMat {
|
DMat {
|
||||||
nrows: nrows,
|
nrows: nrows,
|
||||||
ncols: ncols,
|
ncols: ncols,
|
||||||
mij: Vec::from_fn(nrows * ncols, |i| { let m = i % ncols; f(m, m - i * ncols) })
|
mij: Vec::from_fn(nrows * ncols, |i| f(i % nrows, i / nrows))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,3 +266,16 @@ fn test_decomp_qr_mat5() {
|
||||||
fn test_decomp_qr_mat6() {
|
fn test_decomp_qr_mat6() {
|
||||||
test_decomp_qr_impl!(Mat6<f64>);
|
test_decomp_qr_impl!(Mat6<f64>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_from_fn() {
|
||||||
|
let actual: DMat<uint> = DMat::from_fn( 3, 4,
|
||||||
|
|i,j| 10*i + j);
|
||||||
|
let expected: DMat<uint> = DMat::from_row_vec(3, 4,
|
||||||
|
[0_0, 0_1, 0_2, 0_3,
|
||||||
|
1_0, 1_1, 1_2, 1_3,
|
||||||
|
2_0, 2_1, 2_2, 2_3 ]);
|
||||||
|
|
||||||
|
assert_eq!(actual, expected);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue