Exemplo n.º 1
0
        protected override Algebraic Add(Algebraic x)
        {
            if (x.IsScalar())
            {
                x = x.Promote(this);
            }

            if (x is Matrix && Equalsized(( Matrix )x))
            {
                var b = CreateRectangularArray <Algebraic>(a.Length, a[0].Length);

                for (int i = 0; i < a.Length; i++)
                {
                    for (int k = 0; k < a[0].Length; k++)
                    {
                        b[i][k] = a[i][k] + (( Matrix )x).a[i][k];
                    }
                }

                return(new Matrix(b));
            }

            throw new SymbolicException("Wrong arguments for add:" + this + "," + x);
        }