docs/reference/classes/densematrix.md
<a name="DenseMatrix"></a>
Dense Matrix implementation. This type implements an efficient Array format for dense matrices.
<a name="DenseMatrix+storage"></a>
Get the storage format used by the matrix.
Usage:
const format = matrix.storage() // retrieve storage format
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>string</code> - The storage format.
<a name="DenseMatrix+datatype"></a>
Get the datatype of the data stored in the matrix.
Usage:
const format = matrix.datatype() // retrieve matrix datatype
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>string</code> - The datatype.
<a name="DenseMatrix+create"></a>
Create a new DenseMatrix
Kind: instance method of <code>DenseMatrix</code>
| Param | Type |
|---|---|
| data | <code>Array</code> |
| [datatype] | <code>string</code> |
<a name="DenseMatrix+subset"></a>
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 <code>DenseMatrix</code>
| Param | Type | Default | Description |
|---|---|---|---|
| index | <code>Index</code> | ||
| [replacement] | <code>Array</code> | <code>DenseMatrix</code>| <code>*</code> | ||
| [defaultValue] | <code>*</code> | <code>0</code> | Default value, filled in on new entries when the matrix is resized. If not provided, new matrix elements will be filled with zeros. |
<a name="DenseMatrix+get"></a>
Get a single element from the matrix.
Kind: instance method of <code>DenseMatrix</code> Returns: <code>*</code> - value
| Param | Type | Description |
|---|---|---|
| index | <code>Array.<number></code> | Zero-based index |
<a name="DenseMatrix+set"></a>
Replace a single element in the matrix.
Kind: instance method of <code>DenseMatrix</code> Returns: <code>DenseMatrix</code>- self
| Param | Type | Description |
|---|---|---|
| index | <code>Array.<number></code> | Zero-based index |
| value | <code>*</code> | |
| [defaultValue] | <code>*</code> | Default value, filled in on new entries when the matrix is resized. If not provided, new matrix elements will be left undefined. |
<a name="DenseMatrix+resize"></a>
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 <code>DenseMatrix</code> Returns: <code>Matrix</code> - The resized matrix
| Param | Type | Default | Description |
|---|---|---|---|
| size | <code>Array.<number></code> | The new size the matrix should have. | |
| [defaultValue] | <code>*</code> | <code>0</code> | Default value, filled in on new entries. If not provided, the matrix elements will be filled with zeros. |
| [copy] | <code>boolean</code> | Return a resized copy of the matrix |
<a name="DenseMatrix+clone"></a>
Create a clone of the matrix
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>DenseMatrix</code>- clone
<a name="DenseMatrix+size"></a>
Retrieve the size of the matrix.
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>Array.<number></code> - size
<a name="DenseMatrix+map"></a>
Create a new matrix with the results of the callback function executed on each entry of the matrix.
Kind: instance method of <code>DenseMatrix</code> Returns: <code>DenseMatrix</code>- matrix
| Param | Type | Description |
|---|---|---|
| callback | <code>function</code> | The callback function is invoked with three parameters: the value of the element, the index of the element, and the Matrix being traversed. |
<a name="DenseMatrix+forEach"></a>
Execute a callback function on each entry of the matrix.
Kind: instance method of <code>DenseMatrix</code>
| Param | Type | Description |
|---|---|---|
| callback | <code>function</code> | The callback function is invoked with three parameters: the value of the element, the index of the element, and the Matrix being traversed. |
<a name="DenseMatrix+toArray"></a>
Create an Array with a copy of the data of the DenseMatrix
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>Array</code> - array
<a name="DenseMatrix+valueOf"></a>
Get the primitive value of the DenseMatrix: a multidimensional array
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>Array</code> - array
<a name="DenseMatrix+format"></a>
Get a string representation of the matrix, with optional formatting options.
Kind: instance method of <code>DenseMatrix</code> Returns: <code>string</code> - str
| Param | Type | Description |
|---|---|---|
| [options] | <code>Object</code> | <code>number</code> | <code>function</code> | Formatting options. See lib/utils/number:format for a description of the available options. |
<a name="DenseMatrix+toString"></a>
Get a string representation of the matrix
Kind: instance method of <code>DenseMatrix</code>
Returns: <code>string</code> - str
<a name="DenseMatrix+toJSON"></a>
Get a JSON representation of the matrix
Kind: instance method of <code>DenseMatrix</code> <a name="DenseMatrix+diagonal"></a>
Get the kth Matrix diagonal.
Kind: instance method of <code>DenseMatrix</code> Returns: <code>Array</code> - The array vector with the diagonal values.
| Param | Type | Default | Description |
|---|---|---|---|
| [k] | <code>number</code> | <code>BigNumber</code> | <code>0</code> | The kth diagonal where the vector will retrieved. |
<a name="DenseMatrix+swapRows"></a>
Swap rows i and j in Matrix.
Kind: instance method of <code>DenseMatrix</code> Returns: <code>Matrix</code> - The matrix reference
| Param | Type | Description |
|---|---|---|
| i | <code>number</code> | Matrix row index 1 |
| j | <code>number</code> | Matrix row index 2 |
<a name="DenseMatrix.diagonal"></a>
Create a diagonal matrix.
Kind: static method of <code>DenseMatrix</code>
| Param | Type | Default | Description |
|---|---|---|---|
| size | <code>Array</code> | The matrix size. | |
| value | <code>number</code> | <code>Array</code> | The values for the diagonal. | |
| [k] | <code>number</code> | <code>BigNumber</code> | <code>0</code> | The kth diagonal where the vector will be filled in. |
| [defaultValue] | <code>number</code> | The default value for non-diagonal |
<a name="DenseMatrix.fromJSON"></a>
Generate a matrix from a JSON object
Kind: static method of <code>DenseMatrix</code>
| Param | Type | Description |
|---|---|---|
| json | <code>Object</code> | An object structured like {"mathjs": "DenseMatrix", data: [], size: []}, where mathjs is optional |
<a name="DenseMatrix.preprocess"></a>
Preprocess data, which can be an Array or DenseMatrix with nested Arrays and Matrices. Replaces all nested Matrices with Arrays
Kind: static method of <code>DenseMatrix</code> Returns: <code>Array</code> - data
| Param | Type |
|---|---|
| data | <code>Array</code> |