sw_trace_nd: explicitly take the real part of the determinants to avoid a possibly incorrect logarithm of a complex number due to roundoff effects