R/asSymmetric.R

Defines functions asSymmetric

Documented in asSymmetric

## ID: asSymmetric.R, last updated 2021-04-07, F.Osorio

asSymmetric <- function(x, lower = TRUE)
{ ## coerces to symmetry
  if (!is.matrix(x))
    stop("supply a matrix-like 'x'")
  if (!is.numeric(x))
    stop("argument 'x' is not a numeric matrix")
  if (nrow(x) != ncol(x))
    stop("'x' must be a square matrix.")

  if (lower)
    x[row(x) < col(x)] <- x[row(x) > col(x)]
  else
    x[row(x) > col(x)] <- x[row(x) < col(x)]
  x
}

Try the fastmatrix package in your browser

Any scripts or data that you put into this service are public.

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