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

hedgehog-matrix

v1.0.2

Published

**Hedgehog-matrix** is a library for JavaScript with sweet operator-overload syntax supported by Babel.

Downloads

7

Readme

Hedgehog-matrix

Hedgehog-matrix is a library for JavaScript with sweet operator-overload syntax supported by Babel.

Setup

To use in Node.js, please

npm install Hedgehog-matrix

Also install Babel and babel-plugin-overload

Quick start

Initialize a matrix

// Import matrix class from library
import {Mat} from 'hedgehog-matrix';        

// Initialize a new matrix
//  1  ,  2
//  3  ,  4
var a = new Mat([[1,2], [3,4]]);

Clone matrix A to B

var b = a.clone();

Matrix manipulation:

// c = a + b*2 + 10
var c = a+b*2+10;

// d = ( a * b - a ) * 0.5
var d = (a*b-a)*0.5

// x = a'*a
var x = a.T() * a

Matrix utilities

// initialize a matrix e as: 
// 1,2,3
// 4,5,6
// 7,8,9
var e = new Mat()     // initialize new empty matrix
     .range(1, 10)    // initialize as a 9*1 matrix with all elements [1,10)
     .reshape(3 ,3);  // reshape the matrix into a 3*3 matrix



//zeros
var zeros = new Mat().zeros(10,10);

//ones
var ones = new Mat().ones(10,10);

//identity matrix
var diag_mat = new Mat().identity(10);

//random matrix
var random_mat = new Mat().random(10,10);

Compare operator overload

// compare a * a with another matrix [[7,10], [15,22]] using operator "=="
if ( a * a == new Mat([
    [7, 10],
    [15,22]]  ) )
{
    console.log("Yay! Operator == works !");
}
else
{
    console.log("Operator == doens't work");
}

Matrix / CSV / JSON convertor

var x = csv2mat(
    '1,2,3
     4,5,6
     7,8,9');

var y = mat2csv(x);

var json_x = mat2json(x);
var x_from_json = json2mat(json_x);