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-reef.js

v0.5.5

Published

Fast Matrix Library for Java Script

Downloads

11

Readme

Build Status Coverage Status Version Maintenance License

A faster Matrix for the Java Script World.

There are some awesome matrix libraries for Java Script in the wild. But if you are looking for something faster consider using this library.

Benchmarks

Some Matrix multiplication benchmarks:

| | 2x2 | 3x3 | 4x4 | 16x16 | 32x32 | 256x256 | 512x512 | |----------------|:---------:|:---------:|:-------:|:------:|:-----:|:-------:|:-------:| | Matrix-reef JS | 1,787,425 | 1,557,114 | 869,244 | 45,497 | 6,312 | 16.06 | 1.92 | | ml-Matrix | 188,606 | 156,872 | 127,508 | 15,417 | 5,319 | 15.76 | 1.89 | | Math.js | 129,336 | 101,767 | 63,528 | 3,574 | 553 | 0.92 | 0.08 |

# of operations per second. See How to run the benchmarks for details.

Disclaimer

Matrix-reef.js is still in its early stages. Some must-to-do features are not available, there is no docs, tutorials and no TypeScript. Thus, I'm afraid that Matrix-reef.js is not ready for production yet.

How to use

const A = new Matrix([
    [1, 2], 
    [3, 4], 
    [5, 6]
]); // create a 3x2 matrix

const B = new Matrix([
    [2, 1], 
    [2, 0]
]); // create a 2x2 matrix

const C = A.multiply(B);

See examples below for a complete list of functionalities and demonstration of how to use them.

How to install

Node.js

$ npm install matrix-reef.js

and include

const { Matrix } = require('matrix-reef.js');

CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>

API by examples

Real world examples

This example shows how to train a neural network using the Iris dataset and only add, multiply, dotMultiply and transpose:

$ node examples/training.ann.js 

Should output:

Elapsed time: 0.76 secs for 5000 epochs.

How to run the benchmarks

The benchmark code is here. This program uses Benchmark.js to compare the matrix-multiplication performance of Matrix-reef.js and two other Java Script Matrix implementations: Math.js and ml-Matrix. Execute the following command to run a benchmark yourself:

node benchmarks/multiplication.benchmark.js 10 4 10 5

The command above executes chunks of 10 4x10 by 10x5 matrix multiplications. Ps.: Use --max-old-space-size=4096 when running huge matrices.

New features, bugs and collaboration

Do not hesitate to open a new issue whenever you find something wrong or does not working as expected. Suggestions of new features are pretty welcome as well as collaborations by PR test cases, benchmarks or even new features.