JSPM

sparse-matrix

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34
  • Score
    100M100P100Q85909F
  • License MIT

Sparse Matrix TypeScript Implementation.

Package Exports

  • sparse-matrix
  • sparse-matrix/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sparse-matrix) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Sparse Matrix

Sparse Matrix TypeScript Implementation.

Features

  • Sparse Matrix
  • Fast Transpose
  • Matrix Addition
  • 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 ]
]