np.trace¶
- np.trace(x)¶
Returns the sum along the diagonal of a Galois field array.
References
Examples
In [1]: GF = galois.GF(31) In [2]: A = GF.Random((5,6)); A Out[2]: GF([[10, 16, 24, 2, 30, 13], [10, 22, 30, 2, 8, 21], [10, 12, 7, 1, 8, 17], [21, 26, 8, 19, 13, 15], [17, 27, 15, 3, 2, 3]], order=31) In [3]: np.trace(A) Out[3]: GF(29, order=31) In [4]: A[0,0] + A[1,1] + A[2,2] + A[3,3] + A[4,4] Out[4]: GF(29, order=31)
In [5]: np.trace(A, offset=1) Out[5]: GF(1, order=31) In [6]: A[0,1] + A[1,2] + A[2,3] + A[3,4] + A[4,5] Out[6]: GF(1, order=31)