Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

IDENTITY


Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The IDENTITY function returns an identity array (an array with ones along the main diagonal and zeros elsewhere) of the specified dimensions.

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.

Syntax

Result = IDENTITY( N [, /DOUBLE] )

Return Value

Returns an n by n identity array.

Arguments

N

The desired column and row dimensions.

Keywords

DOUBLE

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

Examples

; 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]] 
 
; Compute the inverse of A using the INVERT function: 
inverse = INVERT(A) 
 
; 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) 

Version History

Introduced: 5.0

See Also

FINDGEN, FLTARR


Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]