diff --git a/russell_sparse/src/csr_matrix.rs b/russell_sparse/src/csr_matrix.rs index 5dc237dd..2ddecd2e 100644 --- a/russell_sparse/src/csr_matrix.rs +++ b/russell_sparse/src/csr_matrix.rs @@ -139,26 +139,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: i32 = 0; + let mut nnz = 0; let mut row_end = 0; for i in 0..nrow { let mut jj = row_end; - row_end = ap[i + 1]; + row_end = ap[i + 1] as usize; while jj < row_end { - let j = aj[jj as usize]; - let mut x = ax[jj as usize]; + let j = aj[jj]; + let mut x = ax[jj]; jj += 1; - while jj < row_end && aj[jj as usize] == j { - x += ax[jj as usize]; + while jj < row_end && aj[jj] == j { + x += ax[jj]; jj += 1; } - aj[nnz as usize] = j; - ax[nnz as usize] = x; + aj[nnz] = j; + ax[nnz] = x; nnz += 1; } - ap[i + 1] = nnz; + ap[i + 1] = to_i32(nnz); } - nnz as usize + nnz } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////