Open
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:
pub struct IterativeAlgo {
a: CsrMatrix<f64>
}
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`
// ...
}
}