Easiest way to perform modular matrix inversion with Python?

前端 未结 6 1202
逝去的感伤
逝去的感伤 2020-12-25 14:32

I\'d like to take the modular inverse of a matrix like [[1,2],[3,4]] mod 7 in Python. I\'ve looked at numpy (which does matrix inversion but not modular matrix inversion) an

6条回答
  •  伪装坚强ぢ
    2020-12-25 15:21

    It can be calculated using Sage (www.sagemath.org) as

    Matrix(IntegerModRing(7), [[1, 2], [3,4]]).inverse()

    Although Sage is huge to install and you have to use the version of python that comes with it which is a pain.

提交回复
热议问题