예제 #1
0
 public Vector(Vector copiedVector)
 {
     _vectorComponents = new double[copiedVector._vectorComponents.Length];
     for (var i = 0; i < _vectorComponents.Length; ++i)
     {
         _vectorComponents[i] = copiedVector._vectorComponents[i];
     }
 }
예제 #2
0
 public static double ScalarMultiply(Vector vector1, Vector vector2)
 {
     double sum = 0;
     var minLength = Math.Min(vector1._vectorComponents.Length, vector2._vectorComponents.Length);
     for (var i = 0; i < minLength; ++i)
     {
         sum += vector1._vectorComponents[i] * vector2._vectorComponents[i];
     }
     return sum;
 }
예제 #3
0
 public static Vector Addition(Vector vector1, Vector vector2)
 {
     var auxiliaryVector1 = vector1._vectorComponents.Length > vector2._vectorComponents.Length ?
         new Vector(vector1) : new Vector(vector2);
     var auxiliaryVector2 = vector1._vectorComponents.Length > vector2._vectorComponents.Length ?
         new Vector(ExtensionVector(vector2._vectorComponents, vector1._vectorComponents.Length)) :
         new Vector(ExtensionVector(vector1._vectorComponents, vector2._vectorComponents.Length));
     for (var i = 0; i < auxiliaryVector1._vectorComponents.Length; ++i)
     {
         auxiliaryVector1._vectorComponents[i] += auxiliaryVector2._vectorComponents[i];
     }
     return auxiliaryVector1;
 }
예제 #4
0
        public static void Main(string[] args)
        {
            double[] d1 = {1, 2, 3};
            double[] d2 = {1, 2, 3};

            var vector = new Vector(3, d1);
            var vector2 = new Vector(3, d2);

            Console.WriteLine(vector.Equals(vector2));
            Console.WriteLine(vector.Addition(vector2).ToString());
            Console.WriteLine(vector.GetLength());
            Console.WriteLine(vector.GetSize());
            Console.WriteLine(vector.GetVectorComponent(1));
            Console.WriteLine(vector.MultiplyByScalar(10));
            Console.WriteLine(vector.Turn());
            Console.ReadKey();
        }
예제 #5
0
 public Vector Subtraction(Vector deductibleVector)
 {
     _vectorComponents = Subtraction(this, deductibleVector)._vectorComponents;
     return this;
 }
예제 #6
0
 public Vector Addition(Vector addedVector)
 {
     _vectorComponents = Addition(this, addedVector)._vectorComponents;
     return this;
 }