Ejemplo n.º 1
0
 /// <summary>
 /// creates a clone of this vector
 /// </summary>
 /// <returns>the cloned vector</returns>
 public Vector Clone()
 {
     Vector buffer = new Vector(Dimensions);
     for (int i = 0; i < Dimensions; i++)
     {
         buffer[i] = this[i];
     }
     return buffer;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// calculates the scalar product of this vector with another vector
 /// </summary>
 /// <param name="other">the other vector of the product</param>
 /// <returns>the calculated scalar</returns>
 public double ScalarProduct(Vector other)
 {
     if (Dimensions != other.Dimensions)
         throw new DimensionMismatchException(
             "The scalar product can only be calculated for vectors of the same length");
     double result = 0;
     for (int i = 0; i < Dimensions; i++)
     {
         result += this[i]*other[i];
     }
     return result;
 }
Ejemplo n.º 3
0
 public static Vector operator -(Vector v)
 {
     Vector buffer = new Vector(v.Dimensions);
     for (int i = 0; i < v.Dimensions; i++)
     {
         buffer[i] = -v[i];
     }
     return buffer;
 }