mlx.core.eye

目錄

mlx.core.eye#

eye(n: int, m: int | None = None, k: int = 0, dtype: Dtype | None = float32, *, stream: None | Stream | Device = None) array#

Create an identity matrix or a general diagonal matrix.

參數:
  • n (int) -- The number of rows in the output.

  • m (int, optional) -- The number of columns in the output. Defaults to n.

  • k (int, optional) -- Index of the diagonal. Defaults to 0 (main diagonal).

  • dtype (Dtype, optional) -- Data type of the output array. Defaults to float32.

  • stream (Stream, optional) -- Stream or device. Defaults to None.

回傳:

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

回傳型別:

array