Linear algebra operations for matrices of class
spam
are designed to behave exactly as for
regular matrices. In particular, matrix multiplication, transpose, addition,
subtraction and various logical operations should work as with the conventional
dense form of matrix storage, as does indexing, rbind, cbind, and diagonal
assignment and extraction (see for example diag
).
Further functions with identical behavior are dim
and thus nrow
, ncol
.
The function norm
calculates the (matrix-)norm of the argument.
The argument type
specifies the l1
norm, sup
or max
norm (default), or the Frobenius or Hilbert-Schmidt
(frobenius/hs
) norm. Partial matching can be used. For example,
norm
is used to check for symmetry in the function chol
by
computing the norm of the difference between the matrix and its
transpose
The operator %d*%
efficiently multiplies a diagonal matrix (in
vector form) and a sparse matrix and is used for compatibility with the
package fields. More specifically, this method is used in the internal
functions of Krig
to make the code more readable. It avoids
having a branch in the source code to handle the diagonal or nondiagonal
cases. Note that this operator is not symmetric: a vector in
the left argument is interpreted as a diagonal matrix and a vector in
the right argument is kept as a column vector.
The operator %d+%
efficiently adds a diagonal matrix (in vector
form) and a sparse matrix, similarly to the operator %d+%
.