// Check properties that would typically be considered invariants of the format.
// It is a logic error to call other methods on this type when these properties
// are not satisfied.
Check properties that would typically be considered invariants of the format.
It is a logic error to call other methods on this type when these properties
are not satisfied.
Check properties that would typically be considered invariants of the format . It is a logic error to call other methods on this type when these properties are not satisfied .
pub fn validate(&self) -> Result<(), SparseMatrixError>  {
        let RawCsr { dim, ref val, ref col, ref row_ptr } = *self;
        ensure!(val.len() == col.len(), "mismatched val/col len");
        ensure!(col.iter().max().unwrap().index() < dim.1, "col index out of range");
        ensure!(row_ptr.raw.windows(2).all(|w| w[0] <= w[1]), "row_ptr not sorted");
        ensure!(row_ptr.len() == dim.0 + 1, "row_ptr wrong len");
        ensure!(*row_ptr.raw.first().unwrap() == 0, "row_ptr first value incorrect");
        ensure!(*row_ptr.raw.last().unwrap() == val.len(), "row_ptr last value incorrect");
        ensure!(
            self.row_ranges().into_iter().all(|range| col[range].windows(2).all(|w| w[0] < w[1])),
            "columns in at least one row not strictly sorted"
        );
        Ok(())
    }
pub fn validate ( & self ) -> Result < ( ) , SparseMatrixError > { let RawCsr { dim , ref val , ref col , ref row_ptr } = * self ; ensure ! ( val len ( ) col len ( ) " " ) ; ensure ! ( col iter ( ) max ( ) unwrap ( ) index ( ) dim 1 " " ) ; ensure ! ( row_ptr raw windows ( 2 ) all ( w w [ 0 ] w [ 1 ] ) " " ) ; ensure ! ( row_ptr len ( ) dim 0 1 " " ) ; ensure ! ( row_ptr raw first ( ) unwrap ( ) 0 " " ) ; ensure ! ( row_ptr raw last ( ) unwrap ( ) val len ( ) " " ) ; ensure ! ( self row_ranges ( ) into_iter ( ) all ( range col [ range ] windows ( 2 ) all ( w w [ 0 ] w [ 1 ] ) ) " " ) ; Ok ( ( ) ) }
Check properties that would typically be considered invariants of the format.
Check properties that would typically be considered invariants of the format .
&self