\Header{lower.tri}{Lower and Upper Triangular Part of a Matrix}
\alias{upper.tri}{lower.tri}
\keyword{array}{lower.tri}
\begin{Description}\relax
Returns a matrix of logicals the same size of a given matrix with
entries \code{TRUE} in the lower or upper triangle.\end{Description}
\begin{Usage}
\begin{verbatim}
lower.tri(x, diag = FALSE)
upper.tri(x, diag = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a matrix.
\item[\code{diag}] logical. Should the diagonal be included?
\end{ldescription}
\end{Arguments}
\begin{SeeAlso}\relax
\code{\Link{diag}},
\code{\Link{matrix}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
m2 <- ma <- matrix(1:20, 4, 5)
m2[lower.tri(m2)] <- NA
m2
stopifnot(lower.tri(ma) == !upper.tri(ma, diag=TRUE))
\end{ExampleCode}
\end{Examples}

