sparse-matrix
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Sparse Matrix

Sparse Matrix TypeScript Implementation.

Features

  • [x] Sparse Matrix
  • [x] Fast Transpose
  • [x] Matrix Addition
  • [x] Matrix Multiplication

Full Documentation: https://jacoblincool.github.io/sparse-matrix/

Install

pnpm i sparse-matrix

Usage

import { Matrix } from "sparse-matrix";

const m = Matrix.empty(4, 4).set(1, 1, 2).set(2, 2, 4);

const n = Matrix.from2d([
    [1, 2, 3, 4],
    [5, 6, 7, 8],
    [9, 10, 11, 12],
    [13, 14, 15, 16],
]);

console.log(m.multiply(n).transpose().to2d());
❯ tsx example/index.ts
[
  [ 0, 10, 36, 0 ],
  [ 0, 12, 40, 0 ],
  [ 0, 14, 44, 0 ],
  [ 0, 16, 48, 0 ]
]

Readme

Keywords

Package Sidebar

Install

npm i sparse-matrix

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

14.4 kB

Total Files

6

Last publish

Collaborators

  • jacoblincool