Skip to content

Latest commit

 

History

History
316 lines (146 loc) · 4.83 KB

File metadata and controls

316 lines (146 loc) · 4.83 KB

Home > @josh-brown/vector > Matrix

Matrix interface

A generalized Matrix - one of the core data types

Signature:

export interface Matrix<S = number> extends LinearTransformation<Vector<S>, Vector<S>> 

Extends: LinearTransformation<Vector<S>, Vector<S>>

Methods

Method

Description

add(other)

Implements matrix addition

adjoint()

Returns the adjoint of the matrix

apply(vector)

Applies the matrix as a linear transformation to the given vector. Implements matrix-vector multiplication.

builder()

Returns a MatrixBuilder which will build new matrices of the same type

combine(other, combineEntries)

Builds a matrix by combining element-wise the values of this matrix with the values of another matrix.

equals(other)

Tests if two matrices are equal

forEach(callback)

Executes the callback function for each entry in the matrix.

getColumn(j)

Returns a vector corresponding to the column at index columnIndex

getColumnVectors()

An array of vectors corresponding to the columns of the matrix

getDiagonal()

Returns a vector containing the elements of the main diagonal of the matrix

getEntry(i, j)

Returns the entry of the matrix at the specified indices i and j

getNumberOfColumns()

Returns the number of columns in the matrix

getNumberOfRows()

Returns the number of rows in the matrix

getRow(i)

Returns a vector corresponding to the row at index rowIndex

getRowVectors()

Returns an array of vectors corresponding to the rows of the matrix

getShape()

Returns a tuple representing the dimensions of the matrix. The first entry is the number of rows, and the second entry is the number of columns.

getSparseData()

Returns the contents of the matrix as a nested map of rowIndex to columnIndex to nonzero value

map(entryFunction)

Builds a matrix by transforming the values of the current matrix.

multiply(other)

Implements matrix multiplication

ops()

Returns a ScalarOperations object which will allow consumers to work generically with the scalars contained in the vector.

scalarMultiply(scalar)

Implements multiplication of a matrix by a scalar

set(i, j, value)

Returns a new matrix equal to the old one, except with the entry at (i, j) replaced with value

toArray()

Returns the contents of the matrix as a 2-D array.

trace()

Returns the trace of the matrix

transpose()

Returns the transpose of the matrix

vectorBuilder()

Returns a VectorBuilder which will build new vectors of a compatible type