The problem is that Sage doesn't have a specialized type for integers mod N:
sage: type(M3)
<class 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'>

The best solution would be to create one, but of course that's a lot of
work.  Another possibility would be to change the __pow__ method for
integer matrices to not ignore the modulus argument.  As a workaround you
can either use pari (as you discovered), or use an integer matrix and
occasionally reduce the coefficients.
David

On Wed, Jun 14, 2023 at 9:18 AM Georgi Guninski <ggunin...@gmail.com> wrote:

> pari/gp appears significantly faster:
>
> sage: time M31=M3**n
> CPU times: user 11.2 s, sys: 8.11 ms, total: 11.2 s
> Wall time: 11.3 s
> sage: M3g=gp(M3)
> sage: time M32=M3g**n
> CPU times: user 617 µs, sys: 2.79 ms, total: 3.41 ms
> Wall time: 119 ms
> sage: M32==gp(M31)
> True
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/CAGUWgD829%2BHC5D-YpvdR6hab7gHAfc9cGQTN%2BGft-DsW8T526A%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAChs6_mMXR%3D_TxZnTYLBFpM2v1d8K74qJZvV78iiTZ0vOyNisQ%40mail.gmail.com.

Reply via email to