sparse-matrix
Version:
Sparse Matrix TypeScript Implementation.
46 lines (33 loc) • 679 B
Markdown
Sparse Matrix TypeScript Implementation.
- [x] Sparse Matrix
- [x] Fast Transpose
- [x] Matrix Addition
- [x] Matrix Multiplication
Full Documentation: <https://jacoblincool.github.io/sparse-matrix/>
```sh
pnpm i sparse-matrix
```
```ts
import { Matrix } from "sparse-matrix";
const m = Matrix.empty(4, 4).set(1, 1, 2).set(2, 2, 4);
const n = Matrix.from2d([
[],
[],
[],
[],
]);
console.log(m.multiply(n).transpose().to2d());
```
```sh
❯ tsx example/index.ts
[
[ 0, 10, 36, 0 ],
[ 0, 12, 40, 0 ],
[ 0, 14, 44, 0 ],
[ 0, 16, 48, 0 ]
]
```