The standard basis vector of length p with 1 in the first position and 0 elsewhere.
32.3.2 Matrix of ones
In mathematics, a matrix of ones (also called an all-ones matrix) is a matrix where every entry equals 1, i.e. In general, When two indices are provided, e.g., , the first indicates the number of rows and the second the number of columns. When only one index is given, e.g., , it denotes a square matrix of size . Some basic matrix operations include:
Matrix of ones
J_n <-function(i, j){matrix(1, nrow = i, ncol = j)}
32.3.3 Identity matrix
In linear algebra, the identity matrix of size is the square matrix with ones on the main diagonal and zeros elsewhere, i.e.
Identity matrix
I_n <-function(i, j){diag(1, nrow = i, ncol = j) }
32.4 Determinant
The determinant is a scalar value that can be computed from a square matrix. It provides important information about the matrix, such as whether it is invertible, its volume-scaling factor in linear transformations, and the linear dependence of its rows or columns. For a matrix , the determinant is denoted . Consider two matrices and , then the determinant satisfies some properties.
Scalar: for .
Transpose: .
Multiplication: .
Inverse: .
Rank: if
then .
then .
The determinant of an matrix can be computed by expanding along any row or column. Expanding along the i-th row gives: where is the sub-matrix without the -th row and the -th column. For example considering a matrix, the determinant simplifies to a well-known formula:
Determinant of a matrix with Laplace recursion
Let’s consider a generic matrix, i.e. then, let’s fix the row and develop the Laplace expansion (Equation 32.4), i.e. where the sub-matrices , and read explicitly as: Then, the determinant of matrices is easily computable as: Finally, coming back to Equation 32.6 and substituting the result in Equation 32.7 one obtain:
32.5 Trace
The trace of a square matrix is the sum of its diagonal elements. It is also equal to the sum of the eigenvalues of , counted with algebraic multiplicity, i.e.