# UpperTriangularize

gives a matrix in which all but the upper triangular elements of m are replaced with zeros.

UpperTriangularize[m,k]

replaces with zeros only the elements below the k subdiagonal of m.

# Details • works even if m is not a square matrix.
• In UpperTriangularize[m,k], positive k refers to subdiagonals above the main diagonal and negative k refers to subdiagonals below the main diagonal.
• UpperTriangularize works with SparseArray objects.

# Examples

open allclose all

## Basic Examples(2)

Get the upper triangular part of a matrix:

Get the strictly upper triangular part of a matrix:

## Scope(12)

### Basic Uses(8)

Get the upper triangular part of non-square matrices:

Find the upper triangular part of a machine-precision matrix:

Upper triangular part of a complex matrix:

Upper triangular part of an exact matrix:

Upper triangular part of an arbitrary-precision matrix:

Compute the upper triangular part of a symbolic matrix:

Large matrices are handled efficiently:

The number of rows or columns limits the meaningful values of the parameter k:

### Special Matrices(4)

The upper triangular part of a sparse matrix is returned as a sparse matrix:

Format the result:

The upper triangular part of structured matrices:

The upper triangular part of an identity matrix is the matrix itself:

This is true of any diagonal matrix:

Compute the the upper triangular part, including the subdiagonal, for HilbertMatrix:

## Properties & Relations(2)

Matrices returned by UpperTriangularize satisfy UpperTriangularMatrixQ:

UpperTriangularize[m,k] is equivalent to Transpose[LowerTriangularize[Transpose[m],-k]]: