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

matrix-ops

v0.3.0

Published

A library for simple 2d-matrix operations

Downloads

5

Readme

npm version

###matrix-ops.js basic matrix operations library 'WIP'


###Use var matrix = require('matrix-ops');

###matrix.create ( ) //generates a random 3x3 matrix if nothing is passed in. var m = matrix.create();


###matrix.identity ( m )

returns the identity matrix(1's along the diagonal) of the passed in matrix.

var m = matrix.create();
var identity = matrix.identity(m);

--

###matrix.scalar ( s , m )

multiplies all elements in the passed in matrix by the passed in scalar.

var m = matrix.create();
m = matrix.scalar(5, m);

###matrix.trace ( m )

returns the sum of the diagonal of the passed in matrix.

var m = matrix.create();
var tr = matrix.trace(m);

###matrix.transpose ( m )

returns the passed in matrix with it's rows and columns swapped.

var m = matrix.create();
m = matrix.transpose(m);

###matrix.product ( m1, m2 )

returns a matrix that is the product of the passed in matrices.

var matrix1 = matrix.create();
var matrix2 = matrix.create();
var matrixProduct = matrix.product(matrix1, matrix2);

###matrix.dotProduct ( v1, v2 )

returns the dot product of two passed in vectors. works if v1.length === v2.length.

var vector1 = [1,2,3];
var vector2 = [4,5,6];
var dot = matrix.dotProduct(vector1, vector2); // should be 29

###matrix.reducedRowEchelonForm ( m )

reduces an augmented matrix, returns the reduced matrix.

var m = matrix.create([
	[0,1,2,3],
	[3,4,5,6],
	[6,7,8,9]
]);

var reduced = matrix.reducedRowEchelonForm(m);

###matrix.upperTriangular ( m )

returns the passed in matrix with all values below the diagonal being zero.

var m = matrix.create();
m = matrix.upperTriangular(m);

###matrix.lowerTriangular ( )

returns the passed in matrix with all values above the diagonal being zero.

var m = matrix.create();
m = matrix.lowerTriangular(m);

###matrix.addRowToMatrix ( m , r )

adds row vector 'r' to the bottom of matrix 'm'.

var m = matrix.create();
m = matrix.addRowToMatrix(m, [1,2,3]);

###matrix.addColumnToMatrix ( m , c )

adds column vector 'c' to the rightmost of matrix 'm'.

var m = matrix.create();
m = matrix.addColumnToMatrix(m, [1,2,3]);

###matrix.rowVector ( m , r )

returns the specified row number 'r' from matrix 'm'.

var m = matrix.create();
var row = matrix.rowVector(m, 0); // returns first row

###matrix.columnVector ( m , c )

returns the specified column number 'c' from matrix 'm'.

var m = matrix.create();
var row = matrix.columnVector(m, 0); // returns first column

###matrix.add ( m1 , m2 )

returns the sum of matrices m1 and m2. must have same number of rows and columns.

var matrix1 = matrix.create();
var matrix2 = matrix.create();
var row = matrix.add(matrix1, matrix2);

###matrix.subtract ( m1 , m2 )

returns the difference of matrices m1 and m2. must have same number of rows and columns.

var matrix1 = matrix.create();
var matrix2 = matrix.create();
var row = matrix.subtract(matrix1, matrix2);

###matrix.print ( m )

prints out the matrix in an ordered way.

alert(matrix.print(m));

###matrix.equal ( m1 , m2 )

returns true if each element in m1 is the same in m2.

var matrix1 = matrix.create();
var matrix2 = matrix.create();

if (matrix.equal(matrix1, matrix2)) {
	//...
}