From 0636d0fa564c24355931280ffd110de1f31f936a Mon Sep 17 00:00:00 2001 From: Dorival Pedroso Date: Wed, 20 Sep 2023 11:00:03 +1000 Subject: [PATCH] Revert back csr_sum_duplicates using usize cast --- russell_sparse/src/csr_matrix.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/russell_sparse/src/csr_matrix.rs b/russell_sparse/src/csr_matrix.rs index a8e1f65d..85b51313 100644 --- a/russell_sparse/src/csr_matrix.rs +++ b/russell_sparse/src/csr_matrix.rs @@ -131,26 +131,26 @@ fn csr_sum_duplicates(nrow: usize, ap: &mut [i32], aj: &mut [i32], ax: &mut [f64 // * Explicit zeros are retained // * ap, aj, and ax will be modified in place - let mut nnz = 0; + let mut nnz: i32 = 0; let mut row_end = 0; for i in 0..nrow { let mut jj = row_end; - row_end = ap[i + 1] as usize; + row_end = ap[i + 1]; while jj < row_end { - let j = aj[jj]; - let mut x = ax[jj]; + let j = aj[jj as usize]; + let mut x = ax[jj as usize]; jj += 1; - while jj < row_end && aj[jj] == j { - x += ax[jj]; + while jj < row_end && aj[jj as usize] == j { + x += ax[jj as usize]; jj += 1; } - aj[nnz] = j; - ax[nnz] = x; + aj[nnz as usize] = j; + ax[nnz as usize] = x; nnz += 1; } - ap[i + 1] = to_i32(nnz); + ap[i + 1] = nnz; } - nnz + nnz as usize } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////