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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@oc-soft/glrs

v0.2.0

Published

matrix library.

Readme

Matrix library for web-assembly

This is matrix library for web-assembly. I designed this libray for web-gl, but you may use general purpose program.

How to use this in javascript

Matrix procedures are in web-assembly. You have to load the assembly first.

// load glrs.js 
const glrs = require('glrs')

let wasmMod = undefined;

if (typeof window === 'undefined') {
  // You have to compile if you use this library in nodejs.
  const path = require('path')
  const fs = require('fs')
  const wasmPath = path.join(
      path.dirname(require.resolve('glrs')), 'glrs_bg.wasm') 
  wasmMod = WebAssembly.compile(fs.readFileSync(wasmPath))
}

(async () => {
  const glrsInterface = await glrs.init(wasmMod)
  // You can use glrs matrix library
  
})

Matrix operation in javascript

To use matrix, you have to get handle to matrix object. When you don't need it anymore, You should release the handle from memory heap.

// instantiate matrix 
// create matrix 
// | 2.0 0.0 |
// | 0.0 1.0 |
const mt = glrs.matrix_create_with_components_row_order([2.0, 0.0, 0.0, 1.0]) 
// mt is handle

// You use mt 

// release matrix
glrs.matrix_release(mt)

You can do some matrix operations with matrix handle.

// the handle to matrix object
const matrix = [0, 0, 0]

matrix[0] =
glrs.matrix_create_with_components_row_order(
[ 7, 2, 1,
  0, 3, -1,
  -3, 4, -2])

// get inverse of matrix.
matrix[1] = glrs.matrix_inverse(matrix[0])

// If you pass the matrix having determinant 0, 
// you would have invalid handle which equals 0

// inverse of matrix is here.
const expectedComponents0 = [
  -2, 8, -5,
  3, -11, 7,
  9, -34, 21
]

const components0 = glrs.matrix_get_components_row_order(matrix[1])

components0.forEach( (compo, idx) => {
  // internal matrix use floating value.
  // some components may not equal exact value you expect for floating 
  // operation error.
  assert.ok(0.0001 > Math.abs((expectedComponents0[idx] - compo)))
})

// multiply operation
matrix[2] = glrs.matrix_multiply(matrix[0], matrix[1])
// result equals identity matrix
const expectedComponents1 = [
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
]
const components1 = glrs.matrix_get_components_row_order(matrix[2])
components1.forEach( (compo, idx) => {
  // some value might not equal exactly for floating operation error.
  assert.ok(0.0001 > Math.abs((expectedComponents1[idx] - compo)))
})

// release matrix instance
matrix.forEach( mt => glrs.matrix_release(mt) )

Matrix vector opeation in javascript

You can operate vector with matrix.

// the handle to matrix object
const matrix = [0, 0]

// create 3x3 matrix
matrix[0] = glrs.matrix_create_with_components_row_order(
  [ 7, 2, 1,
    0, 3, -1,
    -3, 4, -2 ])
// get inverse of matrix
matrix[1] = glrs.matrix_inverse(matrix[0])

// apply matrix to vector
const vec0 = glrs.matrix_apply_r_64(matrix[0], [2, 3, 4])
const vec1 = glrs.matrix_apply_r_64(matrix[1], vec0)

// you expect these components. 
const expectedVec0 = [ 24, 5, -2 ]


vec0.forEach((compo, idx) => {
  // some components do not equal exactly for floating operation error.
  assert.ok(0.0001 > Math.abs((expectedVec0[idx] - compo)))
})

const expectedVec1 = [ 2, 3, 4 ]

vec1.forEach((compo, idx) => {
  assert.ok(0.0001 > Math.abs((expectedVec1[idx] - compo)))
})

// release matrix instance from heap
matrix.forEach( mt => glrs.matrix_release(mt) )