Add test for empty matrix tr_mul.

This commit is contained in:
sebcrozet 2019-09-01 19:52:14 +02:00 committed by Sébastien Crozet
parent 5cb4d5f83c
commit 49abb14e1b

View File

@ -1,9 +1,30 @@
use na::{DMatrix, DVector}; use na::{DMatrix, DVector};
#[test] #[test]
fn empty_mul() { fn empty_matrix_mul_vector() {
// Issue #644 // Issue #644
let m = DMatrix::<f32>::zeros(8, 0); let m = DMatrix::<f32>::zeros(8, 0);
let v = DVector::<f32>::zeros(0); let v = DVector::<f32>::zeros(0);
assert_eq!(m * v, DVector::zeros(8)); assert_eq!(m * v, DVector::zeros(8));
}
#[test]
fn empty_matrix_mul_matrix() {
let m1 = DMatrix::<f32>::zeros(3, 0);
let m2 = DMatrix::<f32>::zeros(0, 4);
assert_eq!(m1 * m2, DMatrix::zeros(3, 4));
}
#[test]
fn empty_matrix_tr_mul_vector() {
let m = DMatrix::<f32>::zeros(0, 5);
let v = DVector::<f32>::zeros(0);
assert_eq!(m.tr_mul(&v), DVector::zeros(5));
}
#[test]
fn empty_matrix_tr_mul_matrix() {
let m1 = DMatrix::<f32>::zeros(0, 3);
let m2 = DMatrix::<f32>::zeros(0, 4);
assert_eq!(m1.tr_mul(&m2), DMatrix::zeros(3, 4));
} }