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
37 lines (23 loc) • 880 B
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
# Function matrixFromFunction
Create a matrix by evaluating a generating function at each index.
## Syntax
```js
math.matrixFromFunction(size, fn)
math.matrixFromFunction(size, fn, format)
math.matrixFromFunction(size, fn, format, datatype)
math.matrixFromFunction(size, format, fn)
math.matrixFromFunction(size, format, datatype, fn)
```
### Parameters
Parameter | Type | Description
--------- | ---- | -----------
## Examples
```js
math.matrixFromFunction([3,3], i => i[0] - i[1]) // an antisymmetric matrix
math.matrixFromFunction([100, 100], 'sparse', i => i[0] - i[1] === 1 ? 4 : 0) // a sparse subdiagonal matrix
math.matrixFromFunction([5], i => math.random()) // a random vector
```
## See also
[matrix](matrix.md),
[zeros](zeros.md)