Esempio n. 1
0
        public override bool Equals(object o)
        {
            if (ReferenceEquals(o, this))
            {
                return(true);
            }

            if (ReferenceEquals(o, null) || o.GetType() != GetType())
            {
                return(false);
            }

            Vector v = (Vector)o;

            if (coordinates.Length != v.GetSize())
            {
                return(false);
            }

            for (int i = 0; i < coordinates.Length; i++)
            {
                if (coordinates[i] != v.GetCoordinate(i))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public static double GetScalarMultiplication(Vector vector1, Vector vector2)
        {
            double scalar = 0;

            int smallerVectorSize = Math.Min(vector1.GetSize(), vector2.GetSize());

            for (int i = 0; i < smallerVectorSize; i++)
            {
                scalar += vector1.GetCoordinate(i) * vector2.GetCoordinate(i);
            }

            return(scalar);
        }