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

linalg-panthr

v0.0.1

Published

Linear Algebra library

Downloads

5

Readme

linAlg.js

A linear algebra library.

Linear algebra methods with effort towards efficiency and stability for medium/large-scale vectors and matrices.

linAlg is a project attempting to implement standard linear algebra methods for medium/large-scale vectors and matrices. The effort is on making operations easy to use and reasonably efficient for large vectors and matrices. No effort has been made to make the operations fast for a large number of small vectors or matrices.

The linAlg module is currently available as a node module, or via AMD. It offers access to two classes, Vector and Matrix.

Vector

Fixed length vectors and operations on them. Vectors are always treated as 1-indexed, so even if the vector has come from a regular Javascript array, that array's first element would be accessed via the vector at the 1 index.

The visible constructor Vector accepts the vector data in one of three forms:

  • As a Javascript array of values. For instance new Vector([3, 5, 6]).
  • As a Javascript object of the non-zero indices and their values. A second argument indicating the desired vector length must be included. For instance new Vector({ 2: 5, 10: 3}, 20) creates a length 20 vector with 2 non-zero values at indices 2 and 10.
  • As a Javascript function, which when evaluated at an index will return the value of the vector at that index. A second argument indicating the desired vector length must be included. For instance new Vector(function(x) { return x*x; }, 5) will create the vector [1, 4, 9, 16, 25].

One important thing to note is that vector computations are done lazily where that makes sense. For example in the function format above, the 5 entries won't be computed until someone tries to access them.

Vectors should be treated as immutable objects. While there is a Vector.prototype.set method, it is primarily used internally. Vectors might be defined as providing you with a "view" into an matrix (when say "viewing" the matrix's 5-th row), and thus changing the values of the vector is meant to change values in the original matrix. Oftentimes that is exactly the intent. But you must be aware of these relationships when you mutate vectors.

Examples

function double(x) { return x*x; }
Vector.seq(1, 7, 2).map(double).sum()       // Computes 1^2 + 3^3 + 5^2 + 7^2

Matrix