IDENTITY

The IDENTITY function returns an n by n identity array (an array with ones along the main diagonal and zeros elsewhere).

This routine is written in the IDL language. Its source code can be found in the file identity.pro in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = IDENTITY( N )

Argument

N

The desired column and row dimensions.

Keyword

DOUBLE

Set this keyword to return a double-precision identity array.

Example

Define an array, A.

A = [[ 2.0, 1.0, 1.0, 1.5], $

     [ 4.0, -6.0, 0.0, 0.0], $

     [-2.0, 7.0, 2.0, 2.5], $

     [ 1.0, 0.5, 0.0, 5.0]]

inverse = INVERT(A) ; Compute the inverse of A using the INVERT function

Verify the accuracy of the computed inverse using the mathematical identity, A x A -1 - I(4) = 0; where A -1 is the inverse of A, I(4) is the 4 by 4 identity array and 0 is a 4 by 4 array of zeros.

PRINT, A ## inverse - IDENTITY(4)

See Also

FINDGEN , FLTARR