mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
52 lines (36 loc) • 1.26 kB
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
Create a Sparse Matrix. The function creates a new `math.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.sparse() // creates an empty sparse matrix.
math.sparse(data) // creates a sparse matrix with initial data.
math.sparse(data, 'number') // creates a sparse matrix with initial data, number datatype.
```
Parameter | Type | Description
--------- | ---- | -----------
`data` | Array &
Type | Description
---- | -----------
Matrix | The created matrix
```js
let m = math.sparse([[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),
[ ](matrix.md)