diff --git a/nalgebra-sparse/src/cs.rs b/nalgebra-sparse/src/cs.rs index 474eb2c09..61675d9d0 100644 --- a/nalgebra-sparse/src/cs.rs +++ b/nalgebra-sparse/src/cs.rs @@ -22,6 +22,16 @@ pub struct CsMatrix { values: Vec, } +///The default implementation for the CsMatrix +impl Default for CsMatrix { + fn default() -> Self { + Self { + sparsity_pattern: Default::default(), + values: Default::default(), + } + } +} + impl CsMatrix { /// Create a zero matrix with no explicitly stored entries. #[inline] diff --git a/nalgebra-sparse/src/csc.rs b/nalgebra-sparse/src/csc.rs index 0cd89f5c2..3471f740b 100644 --- a/nalgebra-sparse/src/csc.rs +++ b/nalgebra-sparse/src/csc.rs @@ -132,6 +132,15 @@ pub struct CscMatrix { pub(crate) cs: CsMatrix, } +///The default implementation for the CscMatrix +impl Default for CscMatrix { + fn default() -> Self { + Self { + cs: Default::default(), + } + } +} + impl CscMatrix { /// Constructs a CSC representation of the (square) `n x n` identity matrix. #[inline] diff --git a/nalgebra-sparse/src/pattern.rs b/nalgebra-sparse/src/pattern.rs index c51945b7c..69d627374 100644 --- a/nalgebra-sparse/src/pattern.rs +++ b/nalgebra-sparse/src/pattern.rs @@ -52,6 +52,17 @@ pub struct SparsityPattern { minor_dim: usize, } +///The default implementation for the SparsityPattern +impl Default for SparsityPattern { + fn default() -> Self { + Self { + major_offsets: Default::default(), + minor_indices: Default::default(), + minor_dim: Default::default(), + } + } +} + impl SparsityPattern { /// Create a sparsity pattern of the given dimensions without explicitly stored entries. pub fn zeros(major_dim: usize, minor_dim: usize) -> Self { diff --git a/src/base/vec_storage.rs b/src/base/vec_storage.rs index 4614598be..0c49650ce 100644 --- a/src/base/vec_storage.rs +++ b/src/base/vec_storage.rs @@ -31,6 +31,20 @@ pub struct VecStorage { ncols: C, } +/// The default implementation for the VecStorage struct. +/// Requires R and C to implement the default trait. +impl Default + for VecStorage +{ + fn default() -> Self { + Self { + data: Default::default(), + nrows: Default::default(), + ncols: Default::default(), + } + } +} + #[cfg(feature = "serde-serialize")] impl Serialize for VecStorage where