Flint has matrices mod n, see https://flintlib.org/doc/nmod_mat.html I guess they should be fast - but they need Sage interface to be provided.
On Thu, Jun 15, 2023 at 1:01 PM Georgi Guninski <ggunin...@gmail.com> wrote: > > On Wed, Jun 14, 2023 at 8:15 PM David Roe <roed.m...@gmail.com> wrote: > > > > 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. > > I implemented something very close to efficiently reduction modulo integers > when working over ZZ and probably it can implemented in __pow__(). > > check the attached file. > > sage: time M1f=matpowermodp(M,n,p) > CPU times: user 528 ms, sys: 2.98 ms, total: 531 ms > Wall time: 362 ms > sage: time M1s=M1p**n > CPU times: user 21.3 s, sys: 4.01 ms, total: 21.3 s > Wall time: 21.4 s > sage: M1s==M1f > 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/CAGUWgD8FPZQPJ_THJnzhiS80%3D%2BjwGZYC-%2BFoG5eXNuQQc1JNQw%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/CAAWYfq3-w6FFNeDpvgD84wJSHMnx9gvPoAP%3Dwf%2BhbxBYu3RzMQ%40mail.gmail.com.