Hot answers tagged

3

mats_row=np.array([[A1,A2,A3,...,A_n]]) #Create array of matrices with shape (1,M,N,N) mats_column=np.transpose(mats_row,(1,0,2,3)) #Make a copy with shape (M,1,N,N) block=.5*(mats_row+mats_column) #Add, broadcasting to a (M,M,N,N) array This works by utilizing Numpy's broadcasting capabilities. The basic idea is similar to if you added a matrix where each ...


Only top voted, non community-wiki answers of a minimum length are eligible