public static bool EqualTo(this Matrix <double> a, Matrix <double> b) { if (a.Dim != b.Dim) { throw new InvalidOperationException(String.Format("Cannot compare matrix A={0} and matrix B={1}", a.Dim, b.Dim)); } bool eq = true; a.ForeachCoord(crd => eq &= a[crd] == b[crd]); return(eq); }