eye
result = eye(n)
Input: n · Output: result
What it is
The n×n identity matrix (ones on the diagonal, zeros elsewhere). n is a single non-negative integer. identity is an alias for eye.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = eye(n) | n matrixnot documented yet | result Mat | Returns an n×n Mat. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
A = [1, 2, 3; 4, 5, 6]
print("size={size(A)} numel={numel(A)}")
print(eye(3))
print(identity(2))
p = [1, 2]
q = [3, 4]
print(cat(1, p, q)) # vertical: stacks rows
print(cat(2, p, q)) # horizontal: concatenates
output
size=[2, 3] numel=6 [1, 0, 0; 0, 1, 0; 0, 0, 1] [1, 0; 0, 1] [1, 2; 3, 4] [1, 2, 3, 4]
from core-math
See also
identity — documented in the same entry.