Function eye

  • Return a 2-D array with ones on the diagonal and zeros elsewhere.

    Parameters

    • N: number

      Number of rows in the output.

    • Optional M: number

      Number of columns in the output.

    • k: number = 0

      Index of the diagonal.

    Returns number[][]

    An array where all elements are equal to zero, except for the k-th diagonal, whose values are equal to one.