Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cablanchard/matrix

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cablanchard/matrix

Containers for some kind of number

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI Coverage Status Greenkeeper badge

Matrix

Instantiation

import { Matrix } from "@cablanchard/matrix";

new Matrix(2,3); // Create 2x3 numeric matrix
// [
//  0, 0, 0,
//  0, 0, 0,
// ]

new Matrix(2, 2).fill(1);
// [
//  1, 1,
//  1, 1,
// ]

new Matrix(2, 2).map((elem, i, j) => i)
// [
//  0, 0,
//  1, 1,
// ]

new Matrix(2,2).fromArray([0,1,2,3]);
// [
//  0, 1,
//  2, 3,
// ]

Accessors

M.rows         // Returns an array of 1D matrices representing rows
M.columns      // Returns an array of 1D matrices representing columns
M.diagonal     // Returns main diagonal
M.antiDiagonal // Returns main antidiagonal
M.transpose    // Returns a new matrix which is a transpose of m

Methods

Throws if elems are out of bounds

M.iRow(i)               // Returns i'th row
M.jCol(j)               // Returns j'th column
M.kDiagonal(k)          // Returns k'th diagonal
M.get(i, j)             // Gets value at position i, j
M.forEach((elem, i, j)) // Iterates over all values n of matrix in positions i, j

Throws if 2 matrices are incompatible

M.equals(N)   // Compares M and N
M.eq(N)       // Shorthand for equals
M.add(N)
M.subtract(N) // Subtracts N from M
M.multiply(N) // Multiplies M (LHS) by N (RHS)
M.x(N)        // Shorthand for multiply
M.scale(n)    // Scale by factor n

Utils

M.toString()

Licence

MIT

FAQs

Package last updated on 11 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc