dpnp.kron
- dpnp.kron(a, b)[source]
Kronecker product of two arrays.
Computes the Kronecker product, a composite array made of blocks of the second array scaled by the first.
For full documentation refer to
numpy.kron
.- Parameters:
a ({dpnp.ndarray, usm_ndarray, scalar}) -- First input array. Both inputs a and b can not be scalars at the same time.
b ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array. Both inputs a and b can not be scalars at the same time.
- Returns:
out -- Returns the Kronecker product.
- Return type:
dpnp.ndarray
See also
dpnp.outer
Returns the outer product of two arrays.
Examples
>>> import dpnp as np >>> a = np.array([1, 10, 100]) >>> b = np.array([5, 6, 7]) >>> np.kron(a, b) array([ 5, 6, 7, ..., 500, 600, 700]) >>> np.kron(b, a) array([ 5, 50, 500, ..., 7, 70, 700])
>>> np.kron(np.eye(2), np.ones((2,2))) array([[1., 1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 1., 1.]])
>>> a = np.arange(100).reshape((2,5,2,5)) >>> b = np.arange(24).reshape((2,3,4)) >>> c = np.kron(a,b) >>> c.shape (2, 10, 6, 20) >>> I = (1,3,0,2) >>> J = (0,2,1) >>> J1 = (0,) + J # extend to ndim=4 >>> S1 = (1,) + b.shape >>> K = tuple(np.array(I) * np.array(S1) + np.array(J1)) >>> c[K] == a[I]*b[J] array(True)