Learn R Programming

fastmatrix (version 0.5-7721)

asSymmetric: Force a matrix to be symmetric

Description

Force a square matrix x to be symmetric

Usage

asSymmetric(x, lower = TRUE)

Value

a square symmetric matrix.

Arguments

x

a square matrix to be forced to be symmetric.

lower

logical, should the upper (lower) triangle be replaced with the lower (upper) triangle?

Examples

Run this code
a <- matrix(1:16, ncol = 4)
isSymmetric(a) # FALSE
a <- asSymmetric(a) # copy lower triangle into upper triangle

Run the code above in your browser using DataLab