public static Vector operator /(Vector one, double param)
 {
     Vector newV = new Vector(one);
     for (int i = 0; i < one.Dim; i++)
         newV[i] /= param;
     return newV;
 }
 public static Vector operator *(Matrix one, Vector other)
 {
     if (one.Width != other.Dim)
         throw new Exception("Dim Error");
     Vector newV = new Vector(one.Height);
     for (int i = 0; i < newV.Dim; i++)
         newV[i] = other * one.Row(i);
     return newV;
 }
        public Vector(Vector other)
        {
            field = new double[other.Dim];

            for (int i = 0; i < other.Dim; i++)
                field[i] = other[i];
        }
 public static Vector operator -(Vector one, Vector other)
 {
     if (one.Dim != other.Dim)
         throw new Exception("Vector lengths aren't the same");
     Vector newV = new Vector(one);
     for (int i = 0; i < other.Dim; i++)
         newV[i] -= other[i];
     return newV;
 }
 public void SetRow(int position, Vector row)
 {
     if (Width != row.Dim)
         throw new Exception("Dim Error");
     for (int i = 0; i < Width; i++)
         field[i, position] = row[i];
 }
 public void SetColumn(int position, Vector column)
 {
     if (Height != column.Dim)
         throw new Exception("Dim Error");
     for (int i = 0; i < Height; i++)
         field[position, i] = column[i];
 }
 /// <summary>
 /// Returns a row at the given postion as a vector, intial index is 0
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public Vector Row(int position)
 {
     Vector newV = new Vector(Width);
     for (int i = 0; i < Width; i++)
         newV[i] = field[i, position];
     return newV;
 }
 /// <summary>
 /// Return a new matrix after GaussianElimination (row reduction) of the original matrix
 /// </summary>
 /// <returns></returns>
 public Matrix GaussianElimination()
 {
     //if (Height != Width)
     //    throw new Exception();
     Matrix newM = new Matrix(this);
     int position = -1;
     double param = 0;
     int count = 0;
     Vector positionV = new Vector(Width);
     for (int i = 0; i < Width; i++)
     {
         if (position != -1)
         {
             newM.SwitchRow(position, count);
             count++;
             position = -1;
         }
         for (int j = count; j < Height; j++)
         {
             if (newM.field[i, j] != 0)
             {
                 if (position != -1)
                     newM.SetRow(j, newM.Row(j) - positionV * newM[i, j] / param);
                 else
                 {
                     position = j;
                     param = newM[i, j];
                     newM.SetRow(j, newM.Row(j));
                     positionV = newM.Row(j);
                 }
             }
         }
     }
     return newM;
 }
 /// <summary>
 /// Return a column at the given position as a vector, initial index is 0
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public Vector Column(int position)
 {
     Vector newV = new Vector(Height);
     for (int i = 0; i < Height; i++)
         newV[i] = field[position, i];
     return newV;
 }