UNPKG

1.13 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function index
4
5Create an index. An Index can store ranges having start, step, and end
6for multiple dimensions.
7Matrix.get, Matrix.set, and math.subset accept an Index as input.
8
9
10## Syntax
11
12```js
13math.index(range1, range2, ...)
14```
15
16### Where
17
18- A number
19- A string for getting/setting an object property
20- An instance of `Range`
21- A one-dimensional Array or a Matrix with numbers
22
23### Parameters
24
25Parameter | Type | Description
26--------- | ---- | -----------
27`ranges` | ...* | Zero or more ranges or numbers.
28
29### Returns
30
31Type | Description
32---- | -----------
33Index | Returns the created index
34
35
36## Examples
37
38```js
39const math = require('mathjs')
40
41const b = [1, 2, 3, 4, 5]
42math.subset(b, math.index([1, 2, 3])) // returns [2, 3, 4]
43
44const a = math.matrix([[1, 2], [3, 4]])
45a.subset(math.index(0, 1)) // returns 2
46```
47
48
49## See also
50
51[bignumber](bignumber.md),
52[boolean](boolean.md),
53[complex](complex.md),
54[matrix](matrix.md),
55[number](number.md),
56[string](string.md),
57[unit](unit.md)