DenseMatrix #

Dense Matrix implementation. This type implements an efficient Array format for dense matrices.

denseMatrix.storage() ⇒ string #

Get the storage format used by the matrix.

Usage:

const format = matrix.storage()                   // retrieve storage format

Kind: instance method of DenseMatrix Returns: string - The storage format.

denseMatrix.datatype() ⇒ string #

Get the datatype of the data stored in the matrix.

Usage:

const format = matrix.datatype()                   // retrieve matrix datatype

Kind: instance method of DenseMatrix Returns: string - The datatype.

denseMatrix.create(data, [datatype]) #

Create a new DenseMatrix

Kind: instance method of DenseMatrix

Param Type
data Array
[datatype] string

denseMatrix.subset(index, [replacement], [defaultValue]) #

Get a subset of the matrix, or replace a subset of the matrix.

Usage:

const subset = matrix.subset(index)               // retrieve subset
const value = matrix.subset(index, replacement)   // replace subset

Kind: instance method of DenseMatrix

Param Type Default Description
index Index    
[replacement] Array | DenseMatrix| \*    
[defaultValue] \* 0 Default value, filled in on new entries when the matrix is resized. If not provided, new matrix elements will be filled with zeros.

denseMatrix.get(index) ⇒ \* #

Get a single element from the matrix.

Kind: instance method of DenseMatrix Returns: \* - value

Param Type Description
index Array.<number> Zero-based index

denseMatrix.set(index, value, [defaultValue]) ⇒ DenseMatrix #

Replace a single element in the matrix.

Kind: instance method of DenseMatrix Returns: DenseMatrix- self

Param Type Description
index Array.<number> Zero-based index
value \*  
[defaultValue] \* Default value, filled in on new entries when the matrix is resized. If not provided, new matrix elements will be left undefined.

denseMatrix.resize(size, [defaultValue], [copy]) ⇒ Matrix #

Resize the matrix to the given size. Returns a copy of the matrix when copy=true, otherwise return the matrix itself (resize in place).

Kind: instance method of DenseMatrix Returns: Matrix - The resized matrix

Param Type Default Description
size Array.<number>   The new size the matrix should have.
[defaultValue] \* 0 Default value, filled in on new entries. If not provided, the matrix elements will be filled with zeros.
[copy] boolean   Return a resized copy of the matrix

denseMatrix.clone() ⇒ DenseMatrix #

Create a clone of the matrix

Kind: instance method of DenseMatrix Returns: DenseMatrix- clone

denseMatrix.size() ⇒ Array.<number> #

Retrieve the size of the matrix.

Kind: instance method of DenseMatrix Returns: Array.<number> - size

denseMatrix.map(callback) ⇒ DenseMatrix #

Create a new matrix with the results of the callback function executed on each entry of the matrix.

Kind: instance method of DenseMatrix Returns: DenseMatrix- matrix

Param Type Description
callback function The callback function is invoked with three parameters: the value of the element, the index of the element, and the Matrix being traversed.

denseMatrix.forEach(callback) #

Execute a callback function on each entry of the matrix.

Kind: instance method of DenseMatrix

Param Type Description
callback function The callback function is invoked with three parameters: the value of the element, the index of the element, and the Matrix being traversed.

denseMatrix.toArray() ⇒ Array #

Create an Array with a copy of the data of the DenseMatrix

Kind: instance method of DenseMatrix Returns: Array - array

denseMatrix.valueOf() ⇒ Array #

Get the primitive value of the DenseMatrix: a multidimensional array

Kind: instance method of DenseMatrix Returns: Array - array

denseMatrix.format([options]) ⇒ string #

Get a string representation of the matrix, with optional formatting options.

Kind: instance method of DenseMatrix Returns: string - str

Param Type Description
[options] Object | number | function Formatting options. See lib/utils/number:format for a description of the available options.

denseMatrix.toString() ⇒ string #

Get a string representation of the matrix

Kind: instance method of DenseMatrix Returns: string - str

denseMatrix.toJSON() ⇒ Object #

Get a JSON representation of the matrix

Kind: instance method of DenseMatrix

denseMatrix.diagonal([k]) ⇒ Array #

Get the kth Matrix diagonal.

Kind: instance method of DenseMatrix Returns: Array - The array vector with the diagonal values.

Param Type Default Description
[k] number | BigNumber 0 The kth diagonal where the vector will retrieved.

denseMatrix.swapRows(i, j) ⇒ Matrix #

Swap rows i and j in Matrix.

Kind: instance method of DenseMatrix Returns: Matrix - The matrix reference

Param Type Description
i number Matrix row index 1
j number Matrix row index 2

DenseMatrix.diagonal(size, value, [k], [defaultValue]) ⇒ DenseMatrix #

Create a diagonal matrix.

Kind: static method of DenseMatrix

Param Type Default Description
size Array   The matrix size.
value number | Array   The values for the diagonal.
[k] number | BigNumber 0 The kth diagonal where the vector will be filled in.
[defaultValue] number   The default value for non-diagonal

DenseMatrix.fromJSON(json) ⇒ DenseMatrix #

Generate a matrix from a JSON object

Kind: static method of DenseMatrix

Param Type Description
json Object An object structured like {"mathjs": "DenseMatrix", data: [], size: []}, where mathjs is optional

DenseMatrix.preprocess(data) ⇒ Array #

Preprocess data, which can be an Array or DenseMatrix with nested Arrays and Matrices. Replaces all nested Matrices with Arrays

Kind: static method of DenseMatrix Returns: Array - data

Param Type
data Array
Fork me on GitHub