R: Symmetric Part and Skew(symmetric) Part of a Matrix

symmpart {Matrix} | R Documentation

## Symmetric Part and Skew(symmetric) Part of a Matrix

### Description

`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.

### Usage

    symmpart(x)
    skewpart(x)

### Arguments

`x` | a square matrix; either “traditional” of class `"matrix"`, or typically, inheriting from the `Matrix` class.

### Details

These are generic functions with several methods for different matrix classes, use e.g., `showMethods(symmpart)` to see them.

### Value

`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`).

### Examples

    m <- Matrix(1:4, 2,2)
    symmpart(m)
    skewpart(m)

    stopifnot(all(m == symmpart(m) + skewpart(m)))

    ## investigate the current methods:
    showMethods(skewpart, include = TRUE)

[Package Matrix version 1.0-6 Index]