예제 #1
0
        public static MatrixR operator -(MatrixR m1, MatrixR m2)
        {
            if (!MatrixR.CompareDimension(m1, m2))
            {
                throw new ArgumentOutOfRangeException(
                          "Dimension", m1, "The dimensions of two matrices must be the same!");
            }
            MatrixR result = new MatrixR(m1.GetRows(), m1.GetCols());

            for (int i = 0; i < m1.GetRows(); i++)
            {
                for (int j = 0; j < m1.GetCols(); j++)
                {
                    result[i, j] = m1[i, j] - m2[i, j];
                }
            }
            return(result);
        }