Creates an n x n identity matrix.
nv_eye_like() is a variant where dtype and device default to those of
like.
Arguments
- n
(
integer(1))
Size of the identity matrix.- dtype
(
NULL|character(1)|DataType)
Data type of the result. Can be any data type;NULL(default) uses the default float data type (seedefault_dtypes()). Fornv_eye_like(),NULLusesdtype(like).- device
(
NULL|character(1)| device)
The device the data lives on, given either as:a device string naming the platform (e.g.
"cpu","cuda","cuda:<n>"), which is resolved against the backend in use, ora device object as returned by
nv_device(): aPJRTDevicefor the"pjrt"backend or aquickr_devicefor the"quickr"backend. Because a device object is backend-specific, it also determines the backend.
The default (
NULL) usesdefault_device().- like
(
AnvlArray)
Existing array whose attributes are used as defaults (only fornv_eye_like()).
Value
(arrayish)
Has the given dtype and shape (n, n): ones on the diagonal, zeros
elsewhere.
See also
nv_diag() for general diagonal matrices.