np.kron()

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2024 Sep 22 23:1
Editor
Edited
Edited
2026 Jan 28 23:47
Refs
Refs
If a.shape = (r0,r1,..,rN) and b.shape = (s0,s1,...,sN), the Kronecker product has shape (r0*s0, r1*s1, ..., rN*SN).
np.einsum('ij,kl->ikjl', A, B).reshape(A.shape[0] * B.shape[0], A.shape[1] * B.shape[1])
p.kron([[1,2],[3,4]], [[0,5],[6,7]]) # [[1*[[0,5],[6,7]], 2*[[0,5],[6,7]]], → (2,2) ⊗ (2,2) = (4,4) # [3*[[0,5],[6,7]], 4*[[0,5],[6,7]]]]
 
 
 
numpy.kron — NumPy v2.1 Manual
Computes the Kronecker product, a composite array made of blocks of the second array scaled by the first.
 
 
 

Recommendations