Compute the Kronecker product of two multidimension NumPy arrays Last Updated : 03 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Given an m X n matrix A and a p X q matrix B, their Kronecker product is A ⊗ B, also called their matrix direct product, is an (m*p) X (n*q) matrix. A = | (a00) (a01) | | (a10) (a11) | B = | (b00) (b01) | | (b10) (b11) | A ⊗ B = | (a00)*(b00) (a00)*(b01) (a01)*(b00) (a01)*(b00) | | (a00)*(b01) (a00)*(b11) (a01)*(b01) (a01)*(b11) | | (a10)*(b00) (a10)*(b01) (a11)*(b00) (a11)*(b01) | | (a10)*(b10) (a10)*(b11) (a11)*(b10) (a11)*(b11) | The Kronecker product of two given multi-dimensional arrays can be computed using the kron() method in the NumPy module. The kron() method takes two arrays as an argument and returns the Kronecker product of those two arrays. Syntax: numpy.kron(array1, array2) Below are some programs which depict the implementation of kron() method in computing Kronecker product of two arrays: Example 1: Python3 # Importing required modules import numpy # Creating arrays array1 = numpy.array([[1, 2], [3, 4]]) print('Array1:\n', array1) array2 = numpy.array([[5, 6], [7, 8]]) print('\nArray2:\n', array2) # Computing the Kronecker Product kroneckerProduct = numpy.kron(array1, array2) print('\nArray1 ⊗ Array2:') print(kroneckerProduct) Output: Array1: [[1 2] [3 4]] Array2: [[5 6] [7 8]] Array1 ⊗ Array2: [[ 5 6 10 12] [ 7 8 14 16] [15 18 20 24] [21 24 28 32]] Example 2: Python3 # Importing required modules import numpy # Creating arrays array1 = numpy.array([[1, 2, 3]]) print('Array1:\n', array1) array2 = numpy.array([[3, 2, 1]]) print('\nArray2:\n', array2) # Computing the Kronecker Product kroneckerProduct = numpy.kron(array1, array2) print('\nArray1 ⊗ Array2:') print(kroneckerProduct) Output: Array1: [[1 2 3]] Array2: [[3 2 1]] Array1 ⊗ Array2: [[3 2 1 6 4 2 9 6 3]] Example 3: Python3 # Importing required modules import numpy # Creating arrays array1 = numpy.array([[1, 2, 3], [4, 5, 6]]) print('Array1:\n', array1) array2 = numpy.array([[1, 2], [3, 4], [5, 6]]) print('\nArray2:\n', array2) # Computing the Kronecker Product kroneckerProduct = numpy.kron(array1, array2) print('\nArray1 ⊗ Array2:') print(kroneckerProduct) Output: Array1: [[1 2 3] [4 5 6]] Array2: [[1 2] [3 4] [5 6]] Array1 ⊗ Array2: [[ 1 2 2 4 3 6] [ 3 4 6 8 9 12] [ 5 6 10 12 15 18] [ 4 8 5 10 6 12] Comment More infoAdvertise with us Next Article Compute the Kronecker product of two multidimension NumPy arrays R riturajsaha Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads Compute the covariance matrix of two given NumPy arrays In NumPy for computing the covariance matrix of two given arrays with help of numpy.cov(). In this, we will pass the two arrays and it will return the covariance matrix of two given arrays. Syntax: numpy.cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None) Example 1: Pyth 2 min read Compute the inner product of vectors for 1-D arrays using NumPy in Python Python has a popular package called NumPy which used to perform complex calculations on 1-D and multi-dimensional arrays. To find the inner product of two arrays, we can use the inner() function of the NumPy package. Syntax: numpy.inner(array1, array2) Parameters: array1, array2: arrays to be evalu 2 min read Compute the inner product of vectors for 1-D arrays using NumPy in Python Python has a popular package called NumPy which used to perform complex calculations on 1-D and multi-dimensional arrays. To find the inner product of two arrays, we can use the inner() function of the NumPy package. Syntax: numpy.inner(array1, array2) Parameters: array1, array2: arrays to be evalu 2 min read Generate a matrix product of two NumPy arrays We can multiply two matrices with the function np.matmul(a,b). When we multiply two arrays of order (m*n) and  (p*q ) in order to obtained matrix product then its output contains m rows and q columns where n is n==p is a necessary condition. Syntax: numpy.matmul(x1, x2, /, out=None, *, casting='same 2 min read Evaluate Einstein's summation convention of two multidimensional NumPy arrays In Python, we can use the einsum() function of the NumPy package to compute Einstein's summation convention of two given multidimensional arrays. Syntax: numpy.einsum(subscripts, *operands, out=None) Parameters: subscripts : str Specifies the subscripts for summation as comma separated list of sub 3 min read Like