CSR/CSC: Allow working with borrowed data + generalize index type
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
This issue describes two in principle disjoint issues, but a design that address either needs to take care to accommodate both. They are:
- Currently CSC/CSR (and COO) matrices only work with *owned* data. However, in many cases a user might have access to compatible, borrowed CSC/CSR data. In this case, it should be possible to work on the borrowed data with our data structures.
- Currently all indices in CSR/CSC matrices are stored as `usize`. For the vast majority of applications, 32-bit indices suffice, which can be expected to have a significant impact on performance due to reduced memory bandwidth requirements. We should therefore generalize the index type.
There are nuances to both these issues, and in the end they must remain compatible. Our *primary* goal for the design of both these features, however, should be to try to reduce the added complexity of a larger and increasingly generic API surface. The library should remain easy to use, the documentation should be easy to browse and the API easy to use.
To this end, one possibility would be to add another *Storage* generic parameter to `CsrMatrix/CscMatrix` and make it default to owned storage, e.g.:
```rust
struct CsrMatrix> { ... }
```
The existing `CsMatrix` struct, which is currently only an implementation detail used to reduce repetition between the CSR and CSC implementations, might be repurposed to fit the role of a `OwnedCsStorage`.
There's similarly a host of issues related to storing the indices. For example, we would like to be able to use *signed* integers as indices, because other software might use signed integers for this purpose. However, we need to make sure that we can soundly convert back and forth between `usize` and the index type on demand. That is, we need to ensure that all indices stored in a *valid* CSR/CSC matrix are actually convertible to `usize` without overflow/underflow.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.