klyn.math.NDArray.flat
property
public property flat[index as Long] as T
Description

Reads or writes one scalar using a row-major linear index, at any rank. This indexed property does not allocate a view, copy or iterator. The last axis varies fastest. Negative indices count backwards from the end.

Parameters
ParameterDescription
indexZero-based linear position, or a negative position from the end.
Returns

The element of type T; assignments update this array directly.

Throws
  • IndexException If the index is outside the array, including an empty array.
Example
matrix = NDArray<Int>([[1, 2], [3, 4]])
matrix.flat[2] = 42
assert matrix[1, 0] == 42 and matrix.flat[-1] == 4