public void TestNorm() { var instance = new SparseIntegerVector(new[] { 0, 0, 2 }); var result = instance.Norm(); Assert.Equal(expected: 2.0, actual: result); }
public void TestCosineSimilarity() { var other = new SparseIntegerVector(new[] { 0, 1, 2, 3 }); var instance = new SparseIntegerVector(new[] { 1, 2, 0, 0 }); var expectedResult = instance.DotProduct(other) / (instance.Norm() * other.Norm()); var result = instance.CosineSimilarity(other); Assert.Equal(expected: expectedResult, actual: result); }