Index #

new Index(...ranges) #

Create an index. An Index can store ranges and sets for multiple dimensions. Matrix.get, Matrix.set, and math.subset accept an Index as input.

Usage:

const index = new Index(range1, range2, matrix1, array1, ...)

Where each parameter can be any of:

The parameters start, end, and step must be integer numbers.

Param Type
…ranges \*

index.valueOf ⇒ Array #

Get the primitive value of the Index, a two dimensional array. Equivalent to Index.toArray().

Kind: instance property of [Index](#Index)
Returns: Array - array

index.clone() ⇒ [Index](#Index) #

Create a clone of the index

Kind: instance method of [Index](#Index)
Returns: [Index](#Index) - clone

index.size() ⇒ Array.<number> #

Retrieve the size of the index, the number of elements for each dimension.

Kind: instance method of [Index](#Index)
Returns: Array.<number> - size

index.max() ⇒ Array.<number> #

Get the maximum value for each of the indexes ranges.

Kind: instance method of [Index](#Index)
Returns: Array.<number> - max

index.min() ⇒ Array.<number> #

Get the minimum value for each of the indexes ranges.

Kind: instance method of [Index](#Index)
Returns: Array.<number> - min

index.forEach(callback) #

Loop over each of the ranges of the index

Kind: instance method of [Index](#Index)

Param Type Description
callback function Called for each range with a Range as first argument, the dimension as second, and the index object as third.

index.dimension(dim) ⇒ Range | null #

Retrieve the dimension for the given index

Kind: instance method of [Index](#Index)
Returns: Range | null - range

Param Type Description
dim Number Number of the dimension

index.isScalar() ⇒ boolean #

Test whether this index contains only a single value.

This is the case when the index is created with only scalar values as ranges, not for ranges resolving into a single value.

Kind: instance method of [Index](#Index)
Returns: boolean - isScalar

index.toArray() ⇒ Array #

Expand the Index into an array. For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]]

Kind: instance method of [Index](#Index)
Returns: Array - array

index.toString() ⇒ String #

Get the string representation of the index, for example ‘[2:6]’ or ‘[0:2:10, 4:7, [1,2,3]]’

Kind: instance method of [Index](#Index)
Returns: String - str

index.toJSON() ⇒ Object #

Get a JSON representation of the Index

Kind: instance method of [Index](#Index)
Returns: Object - Returns a JSON object structured as: {"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}

Index.fromJSON(json) ⇒ [Index](#Index) #

Instantiate an Index from a JSON object

Kind: static method of [Index](#Index)

Param Type Description
json Object A JSON object structured as: {"mathjs": "Index", "dimensions": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}
Fork me on GitHub