コード例 #1
0
ファイル: AnyMatrix.cs プロジェクト: zyzhu/metanumerics
 /// <summary>
 /// Determines whether the given matrix equals the current matrix.
 /// </summary>
 /// <param name="other">The matrix to compare.</param>
 /// <returns>True if the <paramref name="other"/> is equal to the current matrix, otherwise false.</returns>
 public bool Equals(AnyMatrix <T> other)
 {
     if (Object.ReferenceEquals(other, null))
     {
         return(false);
     }
     else
     {
         return(InternalEquals(this, other));
     }
 }
コード例 #2
0
ファイル: AnyMatrix.cs プロジェクト: zyzhu/metanumerics
        // to speed access, IsReadOnly shouldn't be virtual

        // Equality testing
        // It's not worthwhile to re-implement for child classes, because people shouldn't be doing matrix
        // equality comparisons in any code except perhaps test code anyway.

        private static bool InternalEquals(AnyMatrix <T> A, AnyMatrix <T> B)
        {
            Debug.Assert(!Object.ReferenceEquals(A, null));
            Debug.Assert(!Object.ReferenceEquals(B, null));
            if (A.RowCount != B.RowCount)
            {
                return(false);
            }
            if (A.ColumnCount != B.ColumnCount)
            {
                return(false);
            }
            for (int r = 0; r < A.RowCount; r++)
            {
                for (int c = 0; c < A.ColumnCount; c++)
                {
                    if (!A[r, c].Equals(B[r, c]))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }