Is there a convenient way to initialize a Numpy array defined in terms of a Kronecker delta? In an ideal world, there would be a function called, say kron_delta, such that if I set M=kron_delta('ij,kl',5), then M would be a 5x5x5x5 array where M[i,j,k,l]=1 whenever i=j and k=l, and 0 otherwise. My question is whether a function like kron_delta exists.
Followup: If not, is there still a convenient way to initialize the array delta(ijk) (i.e., an nxnxn array which is 1 whenever all indices are equal, and 0 otherwise)?