istriu - Determine if matrix is upper triangular - MATLAB (original) (raw)

Main Content

Determine if matrix is upper triangular

Syntax

Description

Examples

collapse all

Create a 5-by-5 matrix.

A = 5×5

17    24     1     8    15
 0     5     7    14    16
 0     0    13    20    22
 0     0     0    21     3
 0     0     0     0     9

Test if the matrix is upper triangular.

The matrix is upper triangular because all elements below the main diagonal are zero.

Create a 5-by-5 matrix of zeros. Test if the matrix is upper triangular.

The result is logical 1 (true) because an upper triangular matrix can have any number of zeros on the main diagonal.

Input Arguments

collapse all

Input array. istriu returns logical0 (false) if A has more than two dimensions.

Data Types: single | double | logical
Complex Number Support: Yes

More About

collapse all

A matrix is upper triangular if all elements below the main diagonal are zero. Any number of the elements on the main diagonal can also be zero.

For example, this matrix is upper triangular.

A diagonal matrix is both upper and lower triangular.

Tips

Extended Capabilities

expand all

Usage notes and limitations:

The istriu function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced in R2014a

expand all

The istriu supports C/C++ code generation for sparse matrix inputs.