def matrix2numpy(m, dtype=object):
 from numpy import empty
 a = empty(m.shape, dtype)
 for i in range(m.rows):
  for j in range(m.cols):
   a[(i, j)] = m[(i, j)]
 return a

def matrix2numpy ( m , dtype = object ) : from numpy import empty a = empty ( m . shape , dtype ) for i in range ( m . rows ) : for j in range ( m . cols ) : a [ ( i , j ) ] = m [ ( i , j ) ] return a
converts sympys matrix to a numpy array .