How to avoid overflow in calculation matrix determinant with large elements

I am going to calculate the determinant of a random 2D-matrix (G) in Python. The matrix is of size about 30 by 30, where each element is chosen randomly from a large prime field with characteristic P using random.randrange(0,P) (e.g. P= 2^160 - 47). The problem is that when I use det command of both scipy and numpy they return inf. After finding determinant, I want to find the answer in the prime field, that is det(G)% P.

Is there any way to calculate this? Thank you in advance.

Here is a sample code:

import numpy as np
import random
from scipy.linalg import det
N= 30
p = 2**160 - 47
G = np.zeros((N, N))
    
for i in range(N):
   for j in range(N):
      G[i][j] = random.randrange(0, p)

ans = det(G)%p


from Recent Questions - Stack Overflow https://ift.tt/34oAkor
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation