You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add SparseMatrixCSR type alias for CSR storage format
- Add SparseMatrixCSR{Tv,Ti} as alias for Transpose{Tv, SparseMatrixCSC{Tv,Ti}}
- Add SparseMatrixCSR(::SparseMatrixCSC) constructor for CSC→CSR conversion
- Add SparseMatrixCSC(::SparseMatrixCSR) constructor for CSR→CSC conversion
- Update SparseMatrixMPI to use SparseMatrixCSR{T,Int} for the A field
- Update SparseMatrixMPI_local signature to use SparseMatrixCSR
- Optimize triplet-to-CSR construction by building M^T directly (swap I↔J)
- Add comprehensive documentation explaining the dual life of Transpose{SparseMatrixCSC}
- Update CLAUDE.md, api.md, and getting-started.md with CSR explanations
Copy file name to clipboardExpand all lines: docs/src/api.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,52 @@ MatrixMPI
22
22
VectorMPI
23
23
```
24
24
25
+
### SparseMatrixCSR
26
+
27
+
```@docs
28
+
SparseMatrixCSR
29
+
```
30
+
31
+
## CSR Storage Format
32
+
33
+
LinearAlgebraMPI uses CSR (Compressed Sparse Row) format internally for `SparseMatrixMPI` because row-partitioned distributed matrices need efficient row-wise access.
34
+
35
+
### The Dual Life of Transpose{SparseMatrixCSC}
36
+
37
+
In Julia, the type `Transpose{T, SparseMatrixCSC{T,Int}}` has two interpretations:
38
+
39
+
1.**Semantic**: A lazy transpose of a CSC matrix (what you get from `transpose(A)`)
40
+
2.**Storage**: Row-major (CSR) access to sparse data
41
+
42
+
This duality can be confusing. When you call `transpose(A)` on a SparseMatrixCSC, you get a wrapper that represents A^T. But the same wrapper type, when used for storage, provides efficient row iteration.
`SparseMatrixMPI` partitions matrices by rows across MPI ranks. Each rank needs to efficiently iterate over its local rows for operations like matrix-vector multiplication. CSR format provides O(1) access to each row's nonzeros, while CSC would require scanning the entire column pointer array.
Copy file name to clipboardExpand all lines: docs/src/getting-started.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,16 @@ The matrix is partitioned roughly equally by rows. For example, with 4 ranks and
54
54
- Rank 2: rows 51-75
55
55
- Rank 3: rows 76-100
56
56
57
+
### Internal Storage: CSR Format
58
+
59
+
Internally, each rank stores its local rows in CSR (Compressed Sparse Row) format using the `SparseMatrixCSR` type. This enables efficient row-wise iteration, which is essential for a row-partitioned distributed matrix.
60
+
61
+
In Julia, `SparseMatrixCSR{T,Ti}` is a type alias for `Transpose{T, SparseMatrixCSC{T,Ti}}`. This type has a dual interpretation:
62
+
-**Semantic view**: A lazy transpose of a CSC matrix
63
+
-**Storage view**: Row-major (CSR) access to the data
64
+
65
+
You don't need to worry about this for normal usage - it's handled automatically. But if you're accessing the internal storage (e.g., `A.A.parent`), be aware that it stores the transposed data in CSC format, which gives CSR access through the wrapper.
66
+
57
67
### Efficient Local-Only Construction
58
68
59
69
For large matrices, you can avoid replicating data across all ranks by only populating each rank's local portion:
0 commit comments