pub fn validate_csr_matrix(
matrix: &CsrMatrix<f32>,
) -> Result<(), ValidationError>Expand description
Validate the structural integrity of a CSR matrix.
Performs the following checks in order:
rowsandcolsare withinMAX_NODES.nnz(number of non-zeros) is withinMAX_EDGES.row_ptrlength equalsrows + 1.row_ptris monotonically non-decreasing.row_ptr[0] == 0androw_ptr[rows] == nnz.col_indiceslength equalsvalueslength.- All column indices are less than
cols. - No
NaNorInfvalues invalues. - Column indices are sorted within each row (emits a
tracing::warnif not, but does not error).
§Errors
Returns ValidationError describing the first violation found.
§Examples
use ruvector_solver::types::CsrMatrix;
use ruvector_solver::validation::validate_csr_matrix;
let m = CsrMatrix::<f32>::from_coo(2, 2, vec![(0, 0, 1.0), (1, 1, 2.0)]);
assert!(validate_csr_matrix(&m).is_ok());