[Test()] public void TestRowDifference() { var matrix1 = new Matrix <float>(5, 5); float[] row = { 1, 2, 3, 4, 5 }; for (int i = 0; i < 5; i++) { matrix1.SetRow(i, row); } var matrix2 = new Matrix <float>(5, 5); for (int i = 0; i < 5; i++) { matrix2.SetRow(i, row); } var result = MatrixExtensions.RowDifference(matrix1, 2, matrix2, 3); for (int i = 0; i < 5; i++) { Assert.AreEqual(0, result[0]); } }
private float GetItemSimilarity(int itemBought, int newItem) { IList <float> rowDiff = MatrixExtensions.RowDifference(item_factors, itemBought, item_factors, newItem); return((float)rowDiff.EuclideanNorm()); }
private float GetUserSimilarity(int user, int newUser) { IList <float> rowDiff = MatrixExtensions.RowDifference(user_factors, user, user_factors, newUser); return((float)rowDiff.EuclideanNorm()); }