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 🙏

© 2024 – Pkg Stats / Ryan Hefner

matrmath

v0.1.3

Published

A library for performing common matrix operations.

Downloads

10

Readme

matrmath

A library for performing matrix operations.

Installation

npm install matrmath

Usage

Utilize the functions in this library for performing matrix operations.

For example, compute the diagonal difference of a square (n x n) matrix:

const mtr = require("matrmath");

let diff = mtr.diagonalDiff([
    [2, 5, 3],
    [4, 6, 1],
    [7, 8, 9]
]);

console.log(diff);
// |(2+6+9) - (3+6+7)| = |17-16| = 1

Or compute a matrix in reduced row echelon form:

const mtr = require("matrmath");

let reduced = mtr.rowReduce([
    [5, 8, 2],
    [3, 5, 3],
    [6, 4, 9]
]);

console.log(reduced);
// [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]

Config

rowReduce(M)

Transform a matrix in-place and return the reduced row-echelon form of a matrix. Row replacement is achieved through Gaussian Elimination.

  • M - number[][] - A 2-dimensional array.
  • square - boolean - Optional boolean parameter to specify if the matrix is square (ie 3x3, 4x4 etc).

diagonalDiff(M)

Return the diagonal difference of a square. The diagonal difference is the absolute value of the left diagonal minus the right diagonal in a square matrix.

  • M - number[][] | number[] - A 2-dimensional array, or optionally 1D array.
  • is2D - boolean - Optional boolean parameter to specify if the matrix is 1D instead of 2D.
  • debug - boolean - Optional boolean parameter to output the lib object with items used in computations.

isSquare(M)

Check whether a 2D or 1D matrix is square. That is the number of rows equals the number of columns in a n x m layout where n = rows and m = columns and n must equal m.

  • M - number[][] | number[] - A 2D or 1D array, or optionally 1D array.
  • is2D - boolean - Optional boolean parameter to specify if the matrix is 1D instead of 2D.

det(M)

Calculate the determinant of a matrix.

  • M - number[][] - A 2-dimensional array.

isIndependent(M)

Calculate whether a square matrix is linearly independent. If the determinant of a matrix is not equal to 0, its linearly independent.

  • M - number[][] - A 2-dimensional array.

isDependent(M)

Calculate whether a square matrix is linearly dependent. Meaning its determinant equals 0.

  • M - number[][] - A 2-dimensional array.

Tests

npm run test

Todo

  • [ ] Add a utility for transforming points in R^n to R^n. In other words, transform a set of points in some space (R2) to points in (R3). Have a initial input matrix and a transformation matrix as parameters to output the points after being multiplied by the transformation matrix.

Resources