import type { array, matrix } from "../types"; /** * Converts 2D subscripts to linear indices. * * Converts 2D coordinates `[X, Y]` into linear indices based on the given matrix size. * * @param size The size of the matrix. * @param index X, Y coordinates in the range `[0...N-1]`. * @returns The computed linear index or an array of indices. * @throws If input arguments are missing or invalid. * * @example * ```ts * import { assertEquals } from "jsr:@std/assert"; * * var a = [[5,6,5],[7,8,-1]]; * ``` * * @example Convert single 2D coordinate to linear index * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(sub2ind([2, 3], [1, 2]), 5); * * ``` * * @example Convert multiple 2D coordinates to linear indices * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(sub2ind([2, 3], [[0, 0], [1, 0], [0, 1]]), [0, 1, 2]); * * ``` * * @example Convert index for a row vector * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(sub2ind([1, 3], [2, 0]), 2); * * ``` */ export default function sub2ind(size: array, index: array | matrix): number | array; //# sourceMappingURL=sub2ind.d.ts.map