public static double operator *(Vector v1, Vector v2) { if (!Vector.AreCompatible(v1, v2)) { throw new ApplicationException("Vectors are not compatible"); } double num = 0.0; for (int index = 0; index < v1.nrows; ++index) { num += v1[index] * v2[index]; } return(num); }
public static double operator *(Vector v1, Vector v2) { if (!Vector.AreCompatible(v1, v2)) { throw new ApplicationException("Vectors are not compatible"); } double num = 0.0; for (int i = 0; i < v1.fNRows; i++) { num += v1[i] * v2[i]; } return(num); }
public Vector ElementDiv(Vector target, Vector source) { if (!source.IsValid()) { throw new ApplicationException("Source vector is not initialized"); } if (!target.IsValid()) { throw new ApplicationException("Target vector is not initialized"); } if (!Vector.AreCompatible(target, source)) { throw new ApplicationException("Vectors are not compatible"); } Vector vector = new Vector(target.fNRows); for (int i = 0; i < this.fNRows; i++) { vector[i] = target[i] / source[i]; } return(vector); }
public Vector ElementMult(Vector target, Vector source) { if (!source.IsValid()) { throw new ApplicationException("Source vector is not initialized"); } if (!target.IsValid()) { throw new ApplicationException("Target vector is not initialized"); } if (!Vector.AreCompatible(target, source)) { throw new ApplicationException("Vectors are not compatible"); } Vector vector = new Vector(target.nrows); for (int index = 0; index < this.nrows; ++index) { vector[index] = target[index] * source[index]; } return(vector); }