0.5.5 • Published 4 years ago

matrix-reef.js v0.5.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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:

2x23x34x416x1632x32256x256512x512
Matrix-reef JS1,787,4251,557,114869,24445,4976,31216.061.92
ml-Matrix188,606156,872127,50815,4175,31915.761.89
Math.js129,336101,76763,5283,5745530.920.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/matrix-reef.js@0.4.1/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.

0.5.5

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago