<< linalg_hbandL linalg linalg_powfast >>

linalg >> linalg > linalg_pow

linalg_pow

Computes A^p

Calling Sequence

B = linalg_pow ( A , p )

Parameters

A :

a n-by-n matrix of doubles. May be dense, real, complex or sparse.

p :

a 1-by-1 matrix of doubles, integer value, positive.

B :

a n-by-n matrix of doubles, B=A^p

Description

Uses a binary algorithm to compute the power of the matrix A. This algorithm requires generally log2(p) iterations, which is (much) faster that Scilab v5 power algorithm for real matrices. It is based on a macro.

Examples

A = [
5.    4.    3.    2.    1.
4.    4.    3.    2.    1.
0.    3.    3.    2.    1.
0.    0.    2.    2.    1.
0.    0.    0.    1.    1.
];
B = linalg_pow(A,5)
E = [
37721.    47455.    45750.    34540.    18160.
33940.    42751.    41245.    31150.    16380.
15420.    19695.    19156.    14525.    7650.
3720.     5010.     5020.     3861.     2045.
360.      570.      620.      495.      266.
];

// With a complex matrix
A = (3  - 2 * %i ) * testmatrix("frk",5)
A^6
linalg_pow(A,6)

// Measure the difference between Scilab's pow and this pow
p = 99999;
tic();A^p;toc() // Typically: 2.7 s
tic();linalg_pow(A,p);toc() // Typically: 0.003 s
tic();linalg_powfast(A,p);toc() // Typically: 0.002 s

Authors

Bibliography

D. Knuth, "The Art of Computer Programming", Vol. 2, "Seminumerical Algorithms"

http://bugzilla.scilab.org/show_bug.cgi?id=8428


Report an issue
<< linalg_hbandL linalg linalg_powfast >>