R/offdiags.R

Defines functions offdiags

Documented in offdiags

#' Extract off-diagonals of square matrix.
#'
#' Returns vector of length n^2 - n, where n
#' @param x square matrix
#'
#' @keywords matrix
#'
#' @return vector of off-diagonal elements
#' @export
offdiags <- function(x) {
  stopifnot(is_square_mat(x))
  x[row(x) != col(x)]
}
mcfreund/mfutils documentation built on Feb. 6, 2022, 4:57 a.m.