public IArrayVector Sum(IArrayVector anotherVector) { int n; if (vector.Length > anotherVector.GetSize()) { n = anotherVector.GetSize(); } else { n = vector.Length; } double[] another = anotherVector.Get(); double[] sum = new double[n]; for (int i = 0; i < n; i++) { sum[i] = vector[i] + another[i]; } anotherVector.Set(sum); return(anotherVector); }
public double ScalarMult(IArrayVector anotherVector) { int n; if (vector.Length > anotherVector.GetSize()) { n = anotherVector.GetSize(); } else { n = vector.Length; } double[] another = anotherVector.Get(); double scalarMult = 0; for (int i = 0; i < n; i++) { scalarMult += vector[i] * another[i]; } return(scalarMult); }