stm_identity()
creates an n x n
identity matrix where all
diagonal elements are 1, and all off-diagonal elements are 0
.
Arguments
- n
A positive integer specifying the size of the identity matrix.
It represents both the number of rows and columns.
Value
An n x n
identity matrix.
Details
The identity matrix is a square matrix with ones on the diagonal
and zeros elsewhere. It is used in various mathematical operations such
as matrix inversion and solving systems of linear equations.
Examples
stm_identity(3)
#> [,1] [,2] [,3]
#> [1,] 1 0 0
#> [2,] 0 1 0
#> [3,] 0 0 1
stm_identity(5)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 0 0 0 0
#> [2,] 0 1 0 0 0
#> [3,] 0 0 1 0 0
#> [4,] 0 0 0 1 0
#> [5,] 0 0 0 0 1