Rev 3871 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{Diagonal}\alias{Diagonal}\title{Create Diagonal Matrix Object}\description{Create a diagonal matrix object, i.e., an object inheriting from\code{\linkS4class{diagonalMatrix}}.}\usage{Diagonal(n, x = NULL)}\arguments{\item{n}{integer specifying the dimension of the (square) matrix. Ifmissing, \code{length(x)} is used.}\item{x}{numeric or logical; if missing, a \emph{unit} diagonal\eqn{n \times n}{n x n} matrix is created.}}% \details{% ~~ If necessary, more details than the description above ~~% }\value{an object of class\code{\linkS4class{ddiMatrix}} or \code{\linkS4class{ldiMatrix}}(with \dQuote{superclass} \code{\linkS4class{diagonalMatrix}}).}%\author{Martin Maechler}\seealso{the generic function \code{\link{diag}} for \emph{extraction}of the diagonal from a matrix works for all \dQuote{Matrices}.\code{\link{Matrix}}, class \code{\linkS4class{diagonalMatrix}}.}\examples{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))}\keyword{array}\keyword{algebra}