asSymmetric: Force a matrix to be symmetric

View source: R/asSymmetric.R

asSymmetricR Documentation

Force a matrix to be symmetric

Description

Force a square matrix x to be symmetric

Usage

asSymmetric(x, lower = TRUE)

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?

Value

a square symmetric matrix.

Examples

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

fastmatrix documentation built on Oct. 12, 2023, 5:14 p.m.