Contents Previous Next Subchapters

Upper Triangular Part of a Matrix
Syntax triu(A)
triu(
Ak)
See Also tril , diag , identity

Description
The syntax triu(A) returns the upper triangular part of A

The syntax triu(X,k) returns the elements on and above the k-th diagonal of A where k is an integer, real or double-precision scalar. The value k = 0 corresponds to the main diagonal, k > 0 corresponds to above the main diagonal, and k < 0 corresponds to below the main diagonal.

Example:
If you enter
     A = {[1, 2], [3, 4]}
     triu(A)
O-Matrix will respond
     {
     [ 1 , 2 ]
     [ 0 , 4 ]
     }
If you enter
     A = {[1, 2 , 3], [4, 5, 6], [7, 8, 9]}
     k = 1
     triu(A, k)
O-Matrix will respond
     {
     [ 0 , 2 , 3 ]
     [ 0 , 0 , 6 ]
     [ 0 , 0 , 0 ]
     }