np.multiply¶
- np.multiply(x, y)[source]¶
Multiplies two Galois field arrays element-wise.
References
Examples
Multiplying two Galois field arrays results in field multiplication.
In [1]: GF = galois.GF(31) In [2]: x = GF.Random(10); x Out[2]: GF([23, 8, 21, 1, 4, 16, 22, 7, 2, 24], order=31) In [3]: y = GF.Random(10); y Out[3]: GF([ 6, 11, 22, 8, 2, 25, 28, 19, 26, 25], order=31) In [4]: np.multiply(x, y) Out[4]: GF([14, 26, 28, 8, 8, 28, 27, 9, 21, 11], order=31) In [5]: x * y Out[5]: GF([14, 26, 28, 8, 8, 28, 27, 9, 21, 11], order=31)
Multiplying a Galois field array with an integer results in scalar multiplication.
In [6]: GF = galois.GF(31) In [7]: x = GF.Random(10); x Out[7]: GF([18, 13, 19, 28, 11, 13, 28, 29, 30, 15], order=31) In [8]: np.multiply(x, 3) Out[8]: GF([23, 8, 26, 22, 2, 8, 22, 25, 28, 14], order=31) In [9]: x * 3 Out[9]: GF([23, 8, 26, 22, 2, 8, 22, 25, 28, 14], order=31)
In [10]: print(GF.properties) GF(31): characteristic: 31 degree: 1 order: 31 # Adding `characteristic` copies of any element always results in zero In [11]: x * GF.characteristic Out[11]: GF([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], order=31)