Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arzyu/compressed-sparse-row
https://github.com/arzyu/compressed-sparse-row
algorithm
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/arzyu/compressed-sparse-row
- Owner: arzyu
- Created: 2017-10-14T16:50:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-15T16:13:39.000Z (over 7 years ago)
- Last Synced: 2024-11-09T07:23:49.746Z (2 months ago)
- Topics: algorithm
- Language: TypeScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compressed Sparse Row
## Installation
```bash
yarn add compressed-sparse-row
```## Usage
```javascript
import csr from "compressed-sparse-row";const matrix = [
[1, 7, 0, 0],
[0, 2, 8, 0],
[5, 0, 3, 9],
[0, 6, 0, 4]
];const compressed = csr.compress(matrix);
console.log(JSON.stringify(compressed));
// [[4,4],[0,2,4,7,9],[0,1,1,2,0,2,3,1,3],[1,7,2,8,5,3,9,6,4]]
// [shape, rowOffsets, columnIndices, values]const originMatrix = csr.decompress(compressed);
console.log(JSON.stringify(originMatrix));
// [[1,7,0,0],[0,2,8,0],[5,0,3,9],[0,6,0,4]]```
## Reference
[Sparse Matrix Storage Formats](http://www.bu.edu/pasi/files/2011/01/NathanBell1-10-1000.pdf) [page 11]