mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
54 lines (37 loc) • 1.45 kB
Markdown
Create a Matrix. The function creates a new `math.type.Matrix` object from
an `Array`. A Matrix has utility functions to manipulate the data in the
matrix, like getting the size and getting or setting values in the matrix.
```js
math.matrix() // creates an empty matrix using default storage format (dense).
math.matrix(data) // creates a matrix with initial data using default storage format (dense).
math.matrix('dense') // creates an empty matrix using the given storage format.
math.matrix(data, 'dense') // creates a matrix with initial data using the given storage format.
```
Parameter | Type | Description
--------- | ---- | -----------
`data` | Array &
`format` | string | The Matrix storage format
Type | Description
---- | -----------
Matrix | The created matrix
```js
var m = math.matrix([[1, 2], [3, 4]]);
m.size(); // Array [2, 2]
m.resize([3, 2], 5);
m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]]
m.get([1, 0]) // number 3
```
[](bignumber.md),
[](boolean.md),
[](complex.md),
[](index.md),
[](number.md),
[](string.md),
[](unit.md)
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->