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

matrix-nodejs

v1.0.3

Published

light module to create, count, operate, and manipulate. matrix 2D, matrix 3D and vector

Downloads

6

Readme

Matrix js

version size matrix-nodejs

light module to create, count, operate, and manipulate. matrix 2D, matrix 3D and vector

installation

install using npm

# using npm
npm install matrix-nodejs --save

how to usage

basic rules

// must require with dustructuring object
// import object matrix
const { matrix } = require("matrix-nodejs")
// import class Matrix
const { Matrix } = require("matrix-nodejs")
// or import object matrix & class Matrix
const { matrix, Matrix } = require("matrix-nodejs")

// example
let A = [
   [1, 2],
   [3, 4]
  ]
let B = [
   [5, 6],
   [7, 8]
  ]
// example initialize matrix
const A = new Matrix(a)
A.addition(a, b) // incorrect
A.addition(b) // correct

// example without initialize matrix
matrix.addition(a) // incorrect
matrix.addition(a, b) // correct

declare matrix

const { matrix } = require("matrix-nodejs")

/* matrix a (2D) */
let a = [
    [1, 2],
    [3, 4]
  ]
  
/* matrix b (3D) */
let b = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
  ]
  
// initialize matrix A from array a
let A = new Matrix(a)

example usage

basic usage

const { 
  matrix, // object 
  Matrix // class
} 
= require("matrix-nodejs")

// create array matrix
const a = [
    [1, 2],
    [3, 4]
  ]
const b = [
    [5, 6],
    [7, 8]
  ]
const c = [
    [9, 0],
    [1, 2]
  ]
  
const result = matrix.addition(a, b) // return array matrix a + b

// initialize matrix from array
const C = new Matrix(c)

// just call method without passing matrix in argument function
console.log(C.size())

// passing matrix to addition with matrix initialized
console.log(C.addition(a)) // matrix c + matrix a
console.log(result) // result matrix a + b

multiple matrix

const { matrix } = require("matrix-nodejs")
const a = [
    [1, 2],
    [3, 4]
  ]
const b = [
    [5, 6],
    [7, 8]
  ]
const c = [
    [9, 0],
    [1, 2]
  ]

const AxB = matrix.multiple(a, b) // return array matrix
const multiple = matrix.multipleX(1/2, a) // return array matrix

// initialize matrix C from array c
const C = new Matrix(c)

C.multipleX(1/2) // return c * 1/2
C.multiple(b) // return c * 1/2

console.log(AxB) // result matrix a * b
console.log(multiple) // result 1/2 * matrix a

vector

cross vector

const { vector } = require("matrix-nodejs")

/* generate arrat vector from I-J-K */
// example i + 2j + 3k
let a = vector.generate({
  i: 1,
  j: 2,
  k: 3
})

// example string vector (strict space)
let b = vector.destruct("- 2j + 3i - k") // return array

let AxB = vector.cross(a, b) // return object
let angle = vector.angle(a, b) // return number

console.log(AxB.string) // - 11i - 5j + 7k
console.log(AxB.matrix) // [ [-11], [-5], [7] ]
console.log(angle) // 86 degree

list properties

matrix

  • addition (matrix a + matrix b)
  • subtraction (matrix a - matrix b)
  • det2D (determinant matrix 2D)
  • det3D (determinant matrix 3D)
  • dot (matrix a . matrix b)
  • multiple (matrix a * matrix b)
  • multipleX (any * a matrix)
  • length (count total length of matrix)
  • rows (count total rows of matrix)
  • invers (return invers matrix)
  • transpost (return transpost matrix)
  • size (return dimension of matrix)

vector

  • generate (generate array vector)
  • destruct (destruct array vector from string)
  • cross (multiple cross two vector)
  • angle (find angle of two vector)

built with ❤️ by Fiandev