R/tri_mat.R

Defines functions is.upper.tri is.lower.tri

Documented in is.lower.tri is.upper.tri

## ID: tri_mat.R, last updated 2020-10-19, F.Osorio

is.lower.tri <- function(x, diag = FALSE)
{ ## test if a matrix is lower triangular
  if (diag)
    ok <- all(x[row(x) >= col(x)] != 0)
  else
    ok <- all(x[row(x) > col(x)] != 0)
  ok
}

is.upper.tri <- function(x, diag = FALSE)
{ ## test if a matrix is upper triangular
  if (diag)
    ok <- all(x[row(x) <= col(x)] != 0)
  else
    ok <- all(x[row(x) < col(x)] != 0)
  ok
}

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.