コード例 #1
0
        public static MyMatrix <T> operator +(MyMatrix <T> obj1, MyMatrix <T> obj2) //cложение матриц
        {
            MyMatrix <T> obj3 = new MyMatrix <T>(obj1._rows, obj1._cols);

            for (int x = 0; x < obj1._rows; x++)
            {
                for (int y = 0; y < obj1._cols; y++)
                {
                    obj3._matrix[x, y] = Sum(obj1._matrix[x, y], obj2._matrix[x, y]);
                }
            }
            return(obj3);
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() != this.GetType())
            {
                return(false);
            }

            MyMatrix <T> result = obj as MyMatrix <T>;

            for (int x = 0; x < result._rows; x++)
            {
                if (result._matrix[x, 0].CompareTo(_matrix[x, 0]) != 0)
                {
                    return(false);
                }
            }
            return(true);
        }