3.0.6 • Published 6 years ago

@smockle/matrix v3.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

npm Build Status Build status codecov Known Vulnerabilities Greenkeeper badge

matrix

Single or multi dimensional matrices and matrix functions.

Installation

Run npm install --save @smockle/matrix to add matrix to your project.

Usage

const Matrix = require('@smockle/matrix')

// 1x1 Matrix
const m11 = Matrix(3)

// 1x3 Matrix
const m13 = Matrix([1, 2, 3])

// 3x1 Matrix
const m31 = Matrix([[1], [2], [3]])

API Reference

Matrix ⏏

Kind: Exported class

new Matrix(x)

Creates a Matrix

Returns: Matrix - Single or multi dimensional matrix
Throws:

  • TypeError Argument x must be a number or number array
ParamTypeDescription
xnumber | Array.<number>Values to store in matrix

matrix.countRows() ⇒ number

Counts rows in this matrix

Kind: instance method of Matrix
Returns: number - Number of rows

matrix.countColumns() ⇒ number

Counts columns in this matrix

Kind: instance method of Matrix
Returns: number - Number of columns

matrix.addable(y) ⇒ boolean

Determines whether this matrix can be summed

Kind: instance method of Matrix
Returns: boolean - Whether this matrix can be summed (using matrix addition)

ParamTypeDescription
yMatrixMatrix to check

matrix.add(y) ⇒ Matrix

Adds this matrix using matrix addition

Kind: instance method of Matrix
Returns: Matrix - New matrix with the summation

ParamTypeDescription
yMatrixMatrix to add

matrix.multipliable(y) ⇒ boolean

Determines whether this matrix can be multiplied

Kind: instance method of Matrix
Returns: boolean - Whether two matrices can be summed (using matrix multiplication)

ParamTypeDescription
yMatrixMatrix to check

matrix.multiply(y) ⇒ Matrix

Calculates the dot product of this matrix

Kind: instance method of Matrix
Returns: Matrix - New matrix with the dot product

ParamTypeDescription
yMatrixMatrix to multiply

matrix.transpose() ⇒ Matrix

Calculates the transpose of this matrix

Kind: instance method of Matrix
Returns: Matrix - New matrix with the transpose

matrix.invert() ⇒ Matrix

Inverts this matrix

Kind: instance method of Matrix
Returns: Matrix - Matrix inverse

matrix.map() ⇒ Matrix

Maps over this matrix

Kind: instance method of Matrix
Returns: Matrix - Matrix inverse

matrix.valueOf() ⇒ number | Array.<number>

Returns the number or number array value

Kind: instance method of Matrix
Returns: number | Array.<number> - Number of number array value

matrix.inspect() ⇒ string

Formats and prints the matrix value

Kind: instance method of Matrix
Returns: string - Formatted matrix value

inspect~padding : string

Output array filled with zeroes

Kind: inner constant of inspect

Matrix.addable(x, y) ⇒ boolean

Determines whether two matrices can be summed

Kind: static method of Matrix
Returns: boolean - Whether two matrices can be summed (using matrix addition)

ParamTypeDescription
xMatrixMatrix to check
yMatrixMatrix to check

Matrix.add(x, y) ⇒ Matrix

Adds two matrices using matrix addition

Kind: static method of Matrix
Returns: Matrix - New matrix with the summation
Throws:

  • TypeError Matrices are not addable
ParamTypeDescription
xMatrixMatrix to add
yMatrixMatrix to add

Matrix.multipliable(x, y) ⇒ boolean

Determines whether two matrices can be multiplied

Kind: static method of Matrix
Returns: boolean - Whether two matrices can be summed (using matrix multiplication)

ParamTypeDescription
xMatrixMatrix to check
yMatrixMatrix to check

Matrix.multiply(x, y) ⇒ Matrix

Calculates the dot product of two matrices

Kind: static method of Matrix
Returns: Matrix - New matrix with the dot product

ParamTypeDescription
xMatrixMatrix to multiply
yMatrixMatrix to multiply

multiply~z : Matrix

New matrix with the dot product

Kind: inner constant of multiply

Matrix.invert(Matrix) ⇒ Matrix

Inverts a matrix

Kind: static method of Matrix
Returns: Matrix - Matrix inverse

ParamTypeDescription
Matrixxto invert

Matrix~matrix : Matrix

Single or multi dimensional matrix

Kind: inner constant of Matrix

Matrix~innerproduct(x, y, i) ⇒ number

Calculates the inner product of two matrices

Kind: inner method of Matrix
Returns: number - Inner product of matrices

ParamTypeDescription
xMatrixMatrix to multiply
yMatrixMatrix to multiply
inumberColumn in matrix y to multiply

Testing

matrix includes several unit tests. After cloning the matrix repo locally, run npm install in the project folder to install dependencies. Run npm test to execute the tests.

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago