Return an identity matrix.
If invoked with a single scalar argument n, return a square NxN identity matrix.
If supplied two scalar arguments (m, n), eye takes them
to be the number of rows and columns. If given a vector with two elements,
eye uses the values of the elements as the number of rows and
columns, respectively. For example:
eye (3)
⇒ 1 0 0
0 1 0
0 0 1
The following expressions all produce the same result:
eye (2) ≡ eye (2, 2) ≡ eye (size ([1, 2; 3, 4]))
The optional argument class, allows eye to return an array of
the specified type, like
val = zeros (n,m, "uint8")
Calling eye with no arguments is equivalent to calling it with an
argument of 1. Any negative dimensions are treated as zero. These odd
definitions are for compatibility with MATLAB.
See also: speye, ones, zeros.
Package: octave