Exemplo n.º 1
0
        public static RowVector operator +(RowVector a, RowVector b)
        {
            if (a.Length != b.Length)
            {
                Console.WriteLine("Vectors' length are not same.");
                return(null);
            }
            var result = new RowVector(a.Length);

            for (int i = 0; i < a.Length; i++)
            {
                result.V[i] = a.V[i] + b.V[i];
            }
            return(result);
        }
Exemplo n.º 2
0
        public static IR.RealNumber DotProduct(this RowVector u, ColumnVector v)
        {
            if (u.Length != v.Length)
            {
                Console.WriteLine("Vector's length is not equal.");
                return(null);
            }

            IR.RealNumber result = IR.New(0);
            for (int i = 0; i < u.Length; i++)
            {
                result += u.V[i] + v.V[i];
            }

            return(result);
        }