np.copy¶
- np.copy(a)¶
Returns a copy of a given Galois field array.
See: https://numpy.org/doc/stable/reference/generated/numpy.copy.html
Warning
This function returns an
numpy.ndarray
, not an instance of the subclass. To return a copy of the subclass, passsubok=True
(for numpy version 1.19 and above) or usea.copy()
.Examples
In [1]: GF = galois.GF(2**3) In [2]: a = GF.Random(5, low=1); a Out[2]: GF([7, 1, 4, 4, 4], order=2^3) # NOTE: b is an ndarray In [3]: b = np.copy(a); b Out[3]: array([7, 1, 4, 4, 4], dtype=uint8) In [4]: type(b) Out[4]: numpy.ndarray In [5]: a[0] = 0; a Out[5]: GF([0, 1, 4, 4, 4], order=2^3) # b is unmodified In [6]: b Out[6]: array([7, 1, 4, 4, 4], dtype=uint8)
In [7]: a.copy() Out[7]: GF([0, 1, 4, 4, 4], order=2^3)