示例#1
0
        public IArrayVector Sum(IArrayVector anotherVector)
        {
            int n;

            if (vector.Length > anotherVector.GetSize())
            {
                n = anotherVector.GetSize();
            }
            else
            {
                n = vector.Length;
            }

            double[] another = anotherVector.Get();
            double[] sum     = new double[n];

            for (int i = 0; i < n; i++)
            {
                sum[i] = vector[i] + another[i];
            }

            anotherVector.Set(sum);

            return(anotherVector);
        }
示例#2
0
        public double ScalarMult(IArrayVector anotherVector)
        {
            int n;

            if (vector.Length > anotherVector.GetSize())
            {
                n = anotherVector.GetSize();
            }
            else
            {
                n = vector.Length;
            }

            double[] another    = anotherVector.Get();
            double   scalarMult = 0;

            for (int i = 0; i < n; i++)
            {
                scalarMult += vector[i] * another[i];
            }

            return(scalarMult);
        }