public void PointwiseMultiplySparseVector() { var zeroArray = new[] { 0.0, 1.0, 0.0, 1.0, 0.0 }; var vector1 = new SparseVector(Data); var vector2 = new SparseVector(zeroArray); var result = new SparseVector(vector1.Count); vector1.PointwiseMultiply(vector2, result); for (var i = 0; i < vector1.Count; i++) { Assert.AreEqual(Data[i] * zeroArray[i], result[i]); } Assert.AreEqual(2, result.NonZerosCount); }
public void PointwiseMultiplySparseVector() { var zeroArray = new[] { Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero }; var vector1 = new SparseVector(Data); var vector2 = new SparseVector(zeroArray); var result = new SparseVector(vector1.Count); vector1.PointwiseMultiply(vector2, result); for (var i = 0; i < vector1.Count; i++) { AssertHelpers.AreEqual(Data[i] * zeroArray[i], result[i]); } Assert.AreEqual(2, result.NonZerosCount); }
public void CanPointwiseMultiplySparseVector() { var zeroArray = new[] { 0.0, 1.0, 0.0, 1.0, 0.0 }; var vector1 = new SparseVector(Data); var vector2 = new SparseVector(zeroArray); var result = new SparseVector(vector1.Count); vector1.PointwiseMultiply(vector2, result); for (var i = 0; i < vector1.Count; i++) { Assert.AreEqual(Data[i] * zeroArray[i], result[i]); } Assert.AreEqual(2, result.NonZerosCount); }
public void CanPointwiseMultiplySparseVector() { var zeroArray = new[] { Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero }; var vector1 = new SparseVector(Data); var vector2 = new SparseVector(zeroArray); var result = new SparseVector(vector1.Count); vector1.PointwiseMultiply(vector2, result); for (var i = 0; i < vector1.Count; i++) { Assert.AreEqual(Data[i] * zeroArray[i], result[i]); } var resultStorage = (SparseVectorStorage<Complex32>)result.Storage; Assert.AreEqual(2, resultStorage.ValueCount); }
public void CanPointwiseMultiplySparseVector() { var zeroArray = new[] { 0.0, 1.0, 0.0, 1.0, 0.0 }; var vector1 = new SparseVector(Data); var vector2 = new SparseVector(zeroArray); var result = new SparseVector(vector1.Count); vector1.PointwiseMultiply(vector2, result); for (var i = 0; i < vector1.Count; i++) { Assert.AreEqual(Data[i] * zeroArray[i], result[i]); } var resultStorage = (SparseVectorStorage<double>)result.Storage; Assert.AreEqual(2, resultStorage.ValueCount); }