# eye(A)

eye(A)

Constructs an identity matrix of the same dimensions and type as `A`.

## Examples

``````julia> eye(2)
2x2 Array{Float64,2}:
1.0    0.0
0.0    1.0
julia> eye(2,3)
2x3 Array{Float64,2}:
1.0    0.0    0.0
0.0    1.0    0.0
julia> foo = zeros((2,2));
julia> eye(foo)
2x2 Array{Float64,2}:
1.0    0.0
0.0    1.0``````

Create a square identity matrix:

``````julia> eye(3)
3×3 Array{Float64,2}:
1.0  0.0  0.0
0.0  1.0  0.0
0.0  0.0  1.0``````

This example creates a 3x3 identity matrix where all the diagonal elements are 1 and all other elements are 0.

Create a larger identity matrix:

``````julia> eye(5)
5×5 Array{Float64,2}:
1.0  0.0  0.0  0.0  0.0
0.0  1.0  0.0  0.0  0.0
0.0  0.0  1.0  0.0  0.0
0.0  0.0  0.0  1.0  0.0
0.0  0.0  0.0  0.0  1.0``````

In this example, a 5x5 identity matrix is created.

Handle edge cases:

``````julia> eye(0)
0×0 Array{Float64,2}``````

When `n` is 0, an empty matrix is returned.

``````julia> eye(1)
1×1 Array{Float64,2}:
1.0``````

When `n` is 1, a 1x1 identity matrix is returned.

Common mistake example:

``````julia> eye(3.5)
ERROR: InexactError: Int64(3.5)``````

The `eye` function expects an integer value for `n`. Providing a non-integer value will result in an error. Make sure to pass a valid integer to `eye`.