mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
1.5 KiB
1.5 KiB
| layout |
|---|
| default |
Function index #
Create an index. An Index can store ranges having start, step, and end for multiple dimensions. Matrix.get, Matrix.set, and math.subset accept an Index as input.
Syntax #
math.index(range1, range2, ...)
Where #
- A number
- An instance of
Range - A one-dimensional Array or a Matrix with numbers
Parameters #
| Parameter | Type | Description |
|---|---|---|
ranges |
...* | Zero or more ranges or numbers. |
Returns #
| Type | Description |
|---|---|
| Index | Returns the created index |
Examples #
var math = math.js
var b = [1, 2, 3, 4, 5];
math.subset(b, math.index([1, 2, 3])); // returns [2, 3, 4]
var a = math.matrix([[1, 2], [3, 4]]);
a.subset(math.index(0, 1)); // returns 2