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 static bool TestClone2() { //arrange IArrayVector expected = new ArrayVector(new double[] { 1, 2, 3, 4 }); double[] expected1 = expected.Get(); //act IArrayVector actual = expected.Clone(); actual.Set(2, 6); //assert return(Enumerable.SequenceEqual(expected.Get(), expected1)); }