LinearAlgebra[Modular]
MatrixPower
compute a power of a square mod m Matrix
Calling Sequence
Parameters
Description
Examples
MatrixPower(m, A, n)
m
-
modulus
A
square mod m Matrix
n
nonnegative integer power
The MatrixPower function efficiently computes the nth power of the input mod m Matrix via binary powering.
This command is part of the LinearAlgebra[Modular] package, so it can be used in the form MatrixPower(..) only after executing the command with(LinearAlgebra[Modular]). However, it can always be used in the form LinearAlgebra[Modular][MatrixPower](..).
with⁡LinearAlgebraModular:
A≔Mod⁡13,Matrix⁡2,0,0,2,integer
A≔2002
Compute A^0 (identity)
MatrixPower⁡13,A,0
1001
Compute A^1
MatrixPower⁡13,A,1
2002
Compute A^20 (diagonal = 2^20 mod 13 = 9)
MatrixPower⁡13,A,20
9009
See Also
LinearAlgebra/Details
LinearAlgebra[Modular][Create]
LinearAlgebra[Modular][Mod]
Download Help Document