Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6099

Re: MatrixPower works inconsistently for a matrix of elements of GF[p]

From Francois Grieu <fgrieu@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: MatrixPower works inconsistently for a matrix of elements of GF[p]
Date 2011-11-01 05:10 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j8nuvf$eid$1@smc.vnet.net> (permalink)

Show all headers | View raw


Answering my own question asked on 25/10/2011 12:23:

> I'm trying to evaluate powers of a square matrix of elements in GF[p].
>
> I obtain mostly the correct result with MatrixPower, as follows.
> However, some of the elements equal to 0 (mod p) are plain 0,
> rather than elements of GF[p]; how could that be?

At least some of this is documented:
"Zero is special. [The Finite Fields] package makes the assumption that 
zero is zero, regardless of the field it is in. The main consequence of 
this is that a field zero is simplified to the integer 0 automatically. 
Many functions in Mathematica work better with this assumption. The 
assumption is not rigorously correct, but will not produce nonsensical 
output unless nonsensical input is given."

Still I do not understand why it happens for some, but not all
occurences of zero, e.g. in

<<FiniteFields`;
m={
   {GF[5][{1}], GF[5][{1}]},
   {GF[5][{1}], GF[5][{0}]}
};
MatrixForm[MatrixPower[m, 5]]


> Also, the power n in MatrixPower[m,n] is limited: MatrixPower[m, 2^31] fails,
> although only 31 matrix multiplications are required to evaluate it; how comes?

That ones seems to be a bug/limitation, but I now have this kludge
that works for huge exponents:

MyMatrixPower[m_,n_]:=If[n<=2147483647,MatrixPower[m,n],
  Dot[MyMatrixPower[MyMatrixPower[m,Floor[Sqrt[n]]],Floor[Sqrt[n]]],
  MyMatrixPower[m,n-Floor[Sqrt[n]]^2]]];
MatrixForm[MyMatrixPower[m, 2^31]]


   Francois Grieu

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: MatrixPower works inconsistently for a matrix of elements of GF[p] Francois Grieu <fgrieu@gmail.com> - 2011-11-01 05:10 +0000

csiph-web