diff --git a/nalgebra-sparse/src/io/matrix_market.rs b/nalgebra-sparse/src/io/matrix_market.rs index 2620eea6..446f045d 100644 --- a/nalgebra-sparse/src/io/matrix_market.rs +++ b/nalgebra-sparse/src/io/matrix_market.rs @@ -1072,17 +1072,6 @@ fn parse_dense_shape( let mut inner = shape_inner.into_inner(); let r = inner.next().unwrap().as_str().parse::().unwrap(); let c = inner.next().unwrap().as_str().parse::().unwrap(); - // shape information can't use 0 as dimension - if r * c == 0 { - return Err(MatrixMarketError::from_kind_and_message( - MatrixMarketErrorKind::ZeroError, - String::from( - " - Matrix can't have 0 as shape dimensions. - ", - ), - )); - } // check for square matrix, when it's not a general matrix if *storagescheme != StorageScheme::General && r != c { diff --git a/nalgebra-sparse/tests/unit_tests/matrix_market.rs b/nalgebra-sparse/tests/unit_tests/matrix_market.rs index 58db6e02..48ff1a78 100644 --- a/nalgebra-sparse/tests/unit_tests/matrix_market.rs +++ b/nalgebra-sparse/tests/unit_tests/matrix_market.rs @@ -7,7 +7,7 @@ use nalgebra_sparse::CooMatrix; #[test] #[rustfmt::skip] fn test_matrixmarket_sparse_real_general_empty() { - // Test several valid zero-shapes of a matrix + // Test several valid zero-shapes of a sparse matrix let shapes = vec![ (0, 0), (1, 0), (0, 1) ]; let strings: Vec = shapes .iter() @@ -22,6 +22,24 @@ fn test_matrixmarket_sparse_real_general_empty() { } } +#[test] +#[rustfmt::skip] +fn test_matrixmarket_dense_real_general_empty() { + // Test several valid zero-shapes of a dense matrix + let shapes = vec![ (0, 0), (1, 0), (0, 1) ]; + let strings: Vec = shapes + .iter() + .map(|(m, n)| format!("%%MatrixMarket matrix array real general\n {} {}", m, n)) + .collect(); + + for (shape,string) in shapes.iter().zip(strings.iter()) { + let sparse_mat = load_coo_from_matrix_market_str::(string).unwrap(); + assert_eq!(sparse_mat.nrows(), shape.0); + assert_eq!(sparse_mat.ncols(), shape.1); + assert_eq!(sparse_mat.nnz(), 0); + } +} + #[test] #[rustfmt::skip] fn test_matrixmarket_sparse_real_general() {