npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

matrixflow-js

v3.2.2

Published

Dense matrix computation and linear algebra for JavaScript

Readme

matrixflow-js

Dense matrix computation and linear algebra for JavaScript.

npm CI license homepage

matrixflow-js is a typed library for building, transforming, and decomposing dense matrices in Node.js and the browser. Create matrices, run element-wise and linear-algebra operations, and factorize with SVD, EVD, LU, QR, Cholesky, and NIPALS — all from one package.

Homepage: https://matrixflow-js.github.io/matrixflow-js/

Features

  • Dense Matrix with Float64-backed storage and a full operator surface
  • Views that slice, transpose, or flip without copying data
  • SymmetricMatrix and DistanceMatrix for structured data
  • Decompositions: SVD, EVD, LU, QR, Cholesky, NIPALS
  • Solvers: inverse, pseudo-inverse, least squares
  • Statistics: mean, variance, covariance, correlation, center, scale
  • ESM, CommonJS, and a minified UMD build
  • TypeScript definitions included

Install

npm install matrixflow-js

Quick start

ES modules

import { Matrix } from 'matrixflow-js';

const matrix = Matrix.ones(5, 5);

CommonJS

const { Matrix } = require('matrixflow-js');

const matrix = Matrix.ones(5, 5);

Browser (CDN)

<script src="https://cdn.jsdelivr.net/npm/matrixflow-js/matrix.umd.js"></script>
<script>
  const { Matrix } = matrixflow;
  console.log(Matrix.eye(3).toString());
</script>

Usage

Create matrices

import { Matrix } from 'matrixflow-js';

const A = new Matrix([
  [1, 1],
  [2, 2],
]);

const zeros = Matrix.zeros(3, 2);
const ones = Matrix.ones(2, 3);
const identity = Matrix.eye(3, 4);
const diagonal = Matrix.diag([1, 2, 3]);

Arithmetic

import { Matrix } from 'matrixflow-js';

const A = new Matrix([
  [1, 1],
  [2, 2],
]);
const B = new Matrix([
  [3, 3],
  [1, 1],
]);

Matrix.add(A, B); // [[4, 4], [3, 3]]
Matrix.sub(A, B); // [[-2, -2], [1, 1]]
A.mmul(B); // matrix product
Matrix.mul(A, 10); // scalar multiply
Matrix.div(A, 10); // scalar divide
Matrix.max(A, B);
Matrix.min(A, B);

In-place variants mutate the receiver:

const C = B.clone();
C.add(A);
C.mul(10);

Math functions

const A = new Matrix([
  [1, 1],
  [-1, -1],
]);

Matrix.exp(A);
Matrix.cos(A);
Matrix.abs(A);
A.clone().abs(); // in place

Available: abs, acos, acosh, asin, asinh, atan, atanh, cbrt, ceil, clz32, cos, cosh, exp, expm1, floor, fround, log, log1p, log10, log2, round, sign, sin, sinh, sqrt, tan, tanh, trunc.

Inspect and reshape

A.rows;
A.columns;
A.size;
A.get(0, 0);
A.set(1, 0, 10);
A.diag();
A.mean();
A.prod();
A.norm();
A.transpose();
A.isSquare();
A.isSymmetric();

Rows, columns, and concatenation

const M = new Matrix([
  [1, 2, 3],
  [4, 5, 6],
]);

const sumOf = (vector) => vector.reduce((total, value) => total + value, 0);

M.applyAlongAxis(sumOf, 'row'); // [6, 15]
M.applyAlongAxis(sumOf, 'column'); // [5, 7, 9]

M.concat([[7, 8, 9]]);
M.concat(Matrix.columnVector([7, 8]), 'column');

Linear algebra

import {
  Matrix,
  inverse,
  solve,
  linearDependencies,
  QrDecomposition,
  LuDecomposition,
  CholeskyDecomposition,
  EigenvalueDecomposition,
  SingularValueDecomposition,
} from 'matrixflow-js';

Inverse and pseudo-inverse

const A = new Matrix([
  [2, 3, 5],
  [4, 1, 6],
  [1, 3, 0],
]);

const inverseA = inverse(A);
A.mmul(inverseA); // ~ identity

const singular = new Matrix([
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
]);
inverse(singular, true); // SVD-based inverse

const tall = new Matrix([
  [1, 2],
  [3, 4],
  [5, 6],
]);
tall.pseudoInverse();

Least squares

Solve A · x = B:

const A = new Matrix([
  [3, 1],
  [4.25, 1],
  [5.5, 1],
  [8, 1],
]);
const B = Matrix.columnVector([4.5, 4.25, 5.5, 5.5]);
const x = solve(A, B);

Pass true as the third argument to use SVD when A is singular.

Decompositions

const A = new Matrix([
  [2, 3, 5],
  [4, 1, 6],
  [1, 3, 0],
]);

const QR = new QrDecomposition(A);
QR.orthogonalMatrix;
QR.upperTriangularMatrix;

const LU = new LuDecomposition(A);
LU.lowerTriangularMatrix;
LU.upperTriangularMatrix;
LU.pivotPermutationVector;

const cholesky = new CholeskyDecomposition(A);
cholesky.lowerTriangularMatrix;

const evd = new EigenvalueDecomposition(A);
evd.realEigenvalues;
evd.imaginaryEigenvalues;
evd.eigenvectorMatrix;

const svd = new SingularValueDecomposition(A);
svd.diagonal;
svd.leftSingularVectors;
svd.rightSingularVectors;

Linear dependencies

const A = new Matrix([
  [2, 0, 0, 1],
  [0, 1, 6, 0],
  [0, 3, 0, 1],
  [0, 0, 1, 0],
  [0, 1, 2, 0],
]);

linearDependencies(A);

Documentation

Full homepage, live playground, and API overview:

https://matrixflow-js.github.io/matrixflow-js/

The homepage deploys automatically on every push to main. In the GitHub repository, set Settings → Pages → Source to GitHub Actions.

TypeScript definitions ship with the package (matrix.d.ts).

License

MIT © LinNianPing ([email protected])