public double trace() { double t = 0; for (int i = 0; i < Math.Min(m, n); i++) { t += A[i][i]; } return t; }