Ensure the output of addition is sorted.

This commit is contained in:
sebcrozet 2018-11-05 16:44:59 +01:00
parent 748cfeea66
commit 538e18b3e9
2 changed files with 7 additions and 3 deletions

View File

@ -241,7 +241,11 @@ where
&mut res,
);
for p in res.data.p[j]..nz {
// Keep the output sorted.
let range = res.data.p[j]..nz;
res.data.i[range.clone()].sort();
for p in range {
res.data.vals[p] = workspace[res.data.i[p]]
}
}

View File

@ -47,8 +47,8 @@ fn cs_mat_mul() {
#[test]
fn cs_mat_add() {
let m1 = Matrix4x5::new(
4.0, 1.0, 4.0, 0.0, 9.0,
5.0, 6.0, 0.0, 8.0, 10.0,
4.0, 1.0, 4.0, 0.0, 0.0,
5.0, 6.0, 0.0, 8.0, 0.0,
9.0, 10.0, 11.0, 12.0, 0.0,
0.0, 0.0, 1.0, 0.0, 10.0
);