If x
is a spam matrix then diag(x)
returns the diagonal of x
.
The assignment form sets the diagonal of the sparse matrix x
to the
given value(s).
diag.spam
works as diag
for spam matrices:
If x
is a vector (or 1D array) of length two or more, then
diag.spam(x)
returns a diagonal matrix whose diagonal is
x
.
spam_diag
is an alias for diag.spam
and in the spirit
of the result of diag
is a spam
object.
If x
is a vector of length one then diag.spam(x)
returns an
identity matrix of order the nearest integer to x
. The
dimension of the returned matrix can be specified by nrow
and
ncol
(the default is square).
The assignment form sets the diagonal of the matrix x
to the
given value(s).