Add `clear` methods to sparse matrices
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
It is sometimes desirable to reuse the data in a sparse matrix, e.g., in an iterative algorithm, to avoid reallocation. Adding a `clear` method to these types would allow code as in the following:
``` rust
pub struct IterativeAlgo {
a: CsrMatrix
}
impl IterativeAlgo {
pub fn run(&mut self) {
loop {
self.run_iter()
}
}
fn run_iter(&mut self) {
self.populate_a_at_iter_start()
// Use `self.a`
}
fn populate_a_at_iter_start(&mut self) {
// Clear existing memory, but don't deallocate
self.a.clear()
// Write to `self.a`
// ...
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.