Description Usage Arguments Details Value See Also Examples
symmpart(x)
computes the symmetric part (x + t(x))/2
and
skewpart(x)
the
skew symmetric part (x - t(x))/2
of a square matrix x
,
more efficiently for specific Matrix classes.
Note that x == symmpart(x) + skewpart(x)
for all square
matrices – apart from extraneous NA
values in the RHS.
1 2 |
x |
a square matrix; either “traditional” of class
|
These are generic functions with several methods for different matrix
classes, use e.g., showMethods(symmpart)
to see them.
If the row and column names differ, the result will use the column
names unless they are (partly) NULL
where the row names are
non-NULL
(see also the examples).
symmpart()
returns a symmetric matrix, inheriting from
symmetricMatrix
iff x
inherited from
Matrix
.
skewpart()
returns a skew-symmetric matrix,
typically of the same class as x
(or the closest
“general” one, see generalMatrix
).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | m <- Matrix(1:4, 2,2)
symmpart(m)
skewpart(m)
stopifnot(all(m == symmpart(m) + skewpart(m)))
dn <- dimnames(m) <- list(row = c("r1", "r2"), col = c("var.1", "var.2"))
stopifnot(all(m == symmpart(m) + skewpart(m)))
colnames(m) <- NULL
stopifnot(all(m == symmpart(m) + skewpart(m)))
dimnames(m) <- unname(dn)
stopifnot(all(m == symmpart(m) + skewpart(m)))
## investigate the current methods:
showMethods(skewpart, include = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.