Remove POW_MAT_INT to speed up matrix powering#6293
Conversation
I understand that in theory, this provides a speedup. But in
practice, I could not find a single case where it was faster than
POW_OBJ_INT, but many were it was dramatically slower.
Here are some timings to back this up:
gap> x:=PseudoRandom(GL(2,5));;e:=30000000;;
gap> for i in [1..10000] do x:=POW_MAT_INT(x,e); od; time;
507
gap> for i in [1..10000] do x:=POW_OBJ_INT(x,e); od; time;
36
gap> x:=PseudoRandom(GL(3,127));;e:=30000000;;
gap> for i in [1..10000] do x:=POW_MAT_INT(x,e); od; time;
634
gap> for i in [1..10000] do x:=POW_OBJ_INT(x,e); od; time;
67
gap> x:=PseudoRandom(GL(20,256));;e:=30000000;;
gap> for i in [1..10000] do x:=POW_MAT_INT(x,e); od; time;
10378
gap> for i in [1..10000] do x:=POW_OBJ_INT(x,e); od; time;
3566
|
I do not approve this pull request. This code should not be removed. But the heuristics for choosing the best method in each case can certainly be improved. Certainly in the tiny cases you mention above.
In that context typical calls are for matrices in For compressed matrices over small finite fields the matrix multiplication is quite fast, and the overhead in For non-compressed matrices the break even point is much lower, e.g., In an attempt to improve the heuristics it may also be useful to reenable the method which is currently commented out (many matrices have efficient methods for characteristic/minimal polynomial and for large exponents one can reduce to As far as I remember, after introducing |
I understand that in theory, this provides a speedup. But in practice, I could not find a single case where it was faster than POW_OBJ_INT, but many were it was dramatically slower.
Here are some timings to back this up:
CC @frankluebeck who wrote that code -- maybe he can point me to cases were
POW_MAT_INTis faster, then we can look into tuning the heuristics for when to switch.