DADiSP Worksheet Functions > Function Categories > Matrix Math and Special Matrices > DIAGONAL

 

DIAGONAL

Purpose:

Computes a matrix diagonal.

Syntax:

DIAGONAL(a, n)

a

-

A series or matrix.

n

-

Optional. An integer, the diagonal number:

0:

Main diagonal (default)

> 0:

Above main diagonal

< 0:

Below main diagonal 

Returns:

A series or square matrix.

Example:

W1: {1, 2, 3}

W2: diagonal(W1)

 

returns: {{1, 0, 0},

        {0, 2, 0}, 

        {0, 0, 3}} 

 

W3: diag(W2)

 

returns: {1, 2, 3}

 

W4: diag(W2, 1)

 

returns: {0, 0}

Remarks:

diagonal(series) returns a square matrix where the diagonal of the resulting matrix has the same values as the input series.

 

diagonal(matrix, n) returns a single column series where the values are the diagonal of the input matrix. n specifies the optional diagonal number.

 

DIAGONAL can be abbreviated DIAG.

See Also:

COL

EYE

MMULT

ROW

TRIL

TRIU