mpower - Matrix power - MATLAB (original) (raw)
Syntax
Description
C = [A](#btx%5F%5F27-1-A)^[B](#btx%5F%5F27-1-A)
computes A
to the B
power and returns the result in C
.
C = mpower([A](#btx%5F%5F27-1-A),[B](#btx%5F%5F27-1-A))
is an alternate way to execute A^B
, but is rarely used. It enables operator overloading for classes.
Examples
Create a 2-by-2 matrix and square it.
The syntax A^2
is equivalent to A*A
.
Create a 2-by-2 matrix and use it as the exponent for a scalar.
C = 2×2
1.2500 0.7500
0.7500 1.2500
Compute C
by first finding the eigenvalues D
and eigenvectors V
of the matrix B
.
V = 2×2
-0.7071 0.7071 0.7071 0.7071
Next, use the formula 2^B = V*2^D/V
to compute the power.
C = 2×2
1.2500 0.7500
0.7500 1.2500
Input Arguments
Operands, specified as scalars or matrices. Inputs A
and B
must be one of the following combinations:
- Base
A
and exponentB
are both scalars, in which caseA^B
is equivalent toA.^B
. - Base
A
is a square matrix and exponentB
is a scalar. IfB
is a positive integer, the power is computed by repeated squaring. For other values ofB
the calculation uses an eigenvalue decomposition (for most matrices) or a Schur decomposition (for defective matrices). - Base
A
is a scalar and exponentB
is a square matrix. The calculation uses an eigenvalue decomposition.
Operands with an integer data type cannot be complex.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
Complex Number Support: Yes
Tips
- MATLAB® computes
X^(-1)
andinv(X)
in the same manner, and both are subject to the same limitations. For more information, see inv.
References
[1] Higham, Nicholas J., and Lijing Lin. “An Improved Schur--Padé Algorithm for Fractional Powers of a Matrix and Their Fréchet Derivatives.” SIAM Journal on Matrix Analysis and Applications 34, no. 3 (January 2013): 1341–1360. https://doi.org/10.1137/130906118.
Extended Capabilities
Usage notes and limitations:
- If
A
is a 2-by-2 or larger matrix andB
isInf
or-Inf
, thenA^B
returns a matrix ofNaN
values. - For
A^b
, ifb
is a noninteger scalar, then at least one ofA
orb
must be complex. - Code generation does not support sparse matrix inputs for this function.
Usage notes and limitations:
- If
A
is a 2-by-2 or larger matrix andB
isInf
or-Inf
, thenA^B
returns a matrix ofNaN
values. - For
A^b
, ifb
is a noninteger scalar, then at least one ofA
orb
must be complex. - Code generation does not support sparse matrix inputs for this function.
Both inputs must be scalar, and the exponent input, k
, must be an integer.
The mpower
function supports GPU array input with these usage notes and limitations:
- If base
A
is a sparse matrix, exponentB
must be a nonnegative real integer. - If
A
is a sparse scalar,B
must be a scalar.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced before R2006a
The algorithm for defective matrices raised to a real power was improved. In previous releases, mpower
used an algorithm based on eigenvalue decomposition for these inputs that can return incorrect results for defective matrices. The new algorithm for defective matrices is instead based on the Schur decomposition.