| Diagonal {Matrix} | R Documentation |
Create a diagonal matrix object, i.e., an object inheriting from
diagonalMatrix.
Diagonal(n, x = NULL)
n |
integer specifying the dimension of the (square) matrix. If
missing, length(x) is used. |
x |
numeric or logical; if missing, a unit diagonal n x n matrix is created. |
an object of class
ddiMatrix or ldiMatrix
(with “superclass” diagonalMatrix).
the generic function diag for extraction
of the diagonal from a matrix works for all “Matrices”.
Matrix, class diagonalMatrix.
Diagonal(3) Diagonal(x = 10^(3:1)) Diagonal(x = (1:4) >= 2)#-> "ldiMatrix" ## Use Diagonal() + kronecker() for "repeated-block" matrices: M1 <- Matrix(0+0:5, 2,3) (M <- kronecker(Diagonal(3), M1))