# you need to ensure your numpy matrix allows for complex numbers mat__ = np.zeros((k*nboxes,k*nboxes),dtype = 'complex_')