Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "ndarray/sub2ind/docs/types/index.d"

Index

Interfaces

Functions

Functions

sub2ind

  • Converts subscripts to a linear index.

    Notes

    • The function accepts the following "modes":

      • throw: throws an error when a subscript exceeds array dimensions.
      • wrap: wrap around subscripts exceeding array dimensions using modulo arithmetic.
      • clamp: set subscripts exceeding array dimensions to either 0 (minimum index) or the maximum index along a particular dimension.
    • If provided fewer modes than dimensions, the function recycles modes using modulo arithmetic.

    throws

    first argument must be an array-like object containing nonnegative integers

    throws

    subscripts must be integer valued

    throws

    must provide valid options

    throws

    must provide subscripts which do not exceed array dimensions

    throws

    number of subscripts much match the number of dimensions

    Parameters

    • shape: ArrayLike<number>

      array shape

    • Rest ...args: Array<number | Options>

      subscripts followed by an optional options object

    Returns number

    linear index

    Example

    var i = sub2ind( [ 3, 3, 3 ], 1, 2, 2 );
    // returns 17