good first issue
仓库指标
- 星标
- (80 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
In GitLab by @pdamme on Mar 11, 2022, 13:11
DAPHNE data types need to support extracting rectangular fragments out of them. This is required at several points, e.g.
- in the vectorized engine, where we split the input into segments for multi-threaded and cache-conscious processing
- for so-called right indexing in DaphneDSL, where a user might want to extract a certain part out of a data object (for instance,
x[100:200, 3:5];extracts rows 100 to 199 of columns 3 to 4 fromx)
For that reason, Structure, the superclass of all DAPHNE data types, defines the following slicing methods:
sliceRow(rl, ru)-> extracts a row segment (all columns, but only a segment of the rows)sliceCol(cl, cu)-> extracts a column segment (all rows, but only a segment of the columns)slice(rl, ru, cl, cu)-> extracts the intersection of a row and a column segment
We already have implementations for DenseMatrix and Frame, but CSRMatrix supports only sliceRow so far.
The Task:
- Implement
CSRMatrix::sliceCol(). - Optionally implement
CSRMatrix::slice().
Hints:
- In contrast to the existing
slice/sliceRow/sliceColimplementations,sliceColonCSRMatrixis no zero-copy operation, in the general case. Thus, you need to create a freshCSRMatrix. - A possible approach could be as follows: For each row: find the range of
colIdx-valuepairs which are within the bounds of the column segment to extract (note that column indexes are sorted within each row), and copy those over to the outputCSRMatrix. - Optionally, you may also implement the general
sliceonCSRMatrix, that should be straightforward once you've implementedsliceCol.