Skip to content

Commit

Permalink
Simplify usize conversion in csr_sum_duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmech committed Sep 20, 2023
1 parent c5964fe commit 4dae844
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions russell_sparse/src/csr_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 4dae844

Please sign in to comment.