The MATRIX_POWER function computes the product of a matrix with itself. For example, the fifth power of array A is A # A # A # A # A. Negative powers are computed using the matrix inverse of the positive power.
Example
Print an array to the one millionth power:
array = [ [0.401d, 0.600d], $
[0.525d, 0.475d] ]
PRINT, MATRIX_POWER(array, 1e6)
IDL prints:
2.4487434e+202 2.7960773e+202
2.4465677e+202 2.7935929e+202
Syntax
Result = MATRIX_POWER(Array, N [, /DOUBLE] [, STATUS=value])
Return Value
The result is a square array containing the value of the matrix raised to the specified power. A power of zero returns the identity matrix.
Arguments
Array
A square, two-dimensional array of any numeric type.
N
An integer representing the power. N may be positive or negative.
Keywords
DOUBLE
Set this keyword to return a double-precision result. Explicitly set this keyword equal to zero to return a single-precision result. The default return type depends upon the precision of Array.
Note: Computations are always performed using double-precision arithmetic.
STATUS
Set this keyword equal to a named variable that will contain the status of the matrix inverse for negative powers. Possible values are:
Value |
Description |
0 |
Successful completion.
|
1 |
Singular array (which indicates that the inversion is invalid).
|
2 |
Warning that a small pivot element was used and that significant accuracy was probably lost.
|
For non-negative powers, STATUS is always set to 0.
Version History
See Also
MATRIX_MULTIPLY