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

node-gsl-matrix

v0.1.0

Published

A node library for matrix manipulation leveraging GSL

Downloads

9

Readme

node-gsl-matrix

This package exposes matrix functionality provided by GSL. For many applications such as scientific computing, fast matrix operations are critical. By using GSL, we can take advantage of all the heavy lifting done in the library to provide fast matrix operations.

While GSL also provides a variety of other classes (such as vectors, views, etc.) the goal of this library is simplicity. The only type of object exposed is a matrix. Vectors should be represented as matricies with one of the dimensions set to 1.

Installation

First you'll need to get an installation of GSL. If you're on OS X, you can just use brew.

brew install gsl

Then you should be able to install this package via npm.

npm install --save node-gsl-matrix

Usage

The constructor takes as arguments the number of rows and columns. You should always instantiate objects using this method.

var Matrix = require('node-gsl-matrix').Matrix;
var myMatrix = new Matrix(4, 3);  // A 4x3 matrix

Note that the values in the matrix have no guaranteed initialization. The Matrix object has the methods below (all examples presume that myMatrix is a 3x3 identity matrix and otherMatrix is a 1x3 matrix equal to [10, 11]):

addScaledRow

Adds a scaled row from another matrix to a row of the target matrix.

// Add first (and only) row of otherMatrix scaled by 2.0 to second row of myMatrix.
myMatrix.addScaledRow(1, otherMatrix, 0, 2.0);
myMatrix;  // [[1, 0], [20, 23]]

// Last argument is optional and assumed to be 1 if not provided.
myMatrix.addScaledrow(1, otherMatrix, 0);
myMatrix;  // [[1, 0], [10, 12]]

// Third argument is optional and assumed to be 0 if not provided.
myMatrix.addScaledrow(1, otherMatrix);
myMatrix;  // [[1, 0], [10, 12]]

get

Return the value in a particular entry

myMatrix.get(0, 0);  // 1

innerProduct

Return the inner product of a row in this matrix with a row in another matrix

// Compute the inner product of the second row of myMatrix 
// with the first (and only) row of otherMatrix
myMatrix.innerProduct(1, otherMatrix, 0);   // 11

// Last argument is optional, first row is assumed.
myMatrix.innerProduct(1, otherMatrix);  // 11

scale

Multiplies all values in the matrix by a constant value.

myMatrix.scale(0.1);
myMatrix;  // [[0.1, 0] [0, 0.1]]

set

Set a particular entry to a value

myMatrix.set(0, 1, 8);
myMatrix;  // [[1, 8], [0, 1]]

setAll

Sets all values in the matrix to a value

myMatrix.setAll(7);
myMatrix;  // [[7, 7], [7, 7]]

setRow

Sets all values in a particular row to a value

myMatrix.setRow(0, 6);
myMatrix;  // [[6, 6], [0, 1]]

License

node-gsl-matrix is available under the MIT license.