time-to-botec/js/node_modules/@stdlib/ndarray/sub2ind/docs/repl.txt

46 lines
1.4 KiB
Plaintext
Raw Normal View History

{{alias}}( shape, ...subscript[, options] )
Converts subscripts to a linear index.
Parameters
----------
shape: ArrayLike
Array shape.
subscript: ...integer
Subscripts.
options: Object (optional)
Options.
options.order: string (optional)
Specifies whether an array is row-major (C-style) or column-major
(Fortran style). Default: 'row-major'.
options.mode: string|Array<string> (optional)
Specifies how to handle subscripts which exceed array dimensions. If
equal to 'throw', the function throws an error when a subscript exceeds
array dimensions. If equal to 'wrap', the function wraps around
subscripts exceeding array dimensions using modulo arithmetic. If equal
to 'clamp', the function sets subscripts exceeding array dimensions to
either `0` (minimum index) or the maximum index along a particular
dimension. If provided a mode array, each array element specifies the
mode for a corresponding array dimension. If provided fewer modes than
dimensions, the function recycles modes using modulo arithmetic.
Default: [ 'throw' ].
Returns
-------
idx: integer
Linear index.
Examples
--------
> var d = [ 3, 3, 3 ];
> var idx = {{alias}}( d, 1, 2, 2 )
17
See Also
--------