From 9632bea377f0bd8c931c27c67e835d9cfe552023 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 5 Jul 2016 09:26:34 -0400 Subject: [PATCH] :memo: vmagnitude. --- src/Data/RandomWalkSimilarity.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/RandomWalkSimilarity.hs b/src/Data/RandomWalkSimilarity.hs index 5bbb6b82f..6b1cea492 100644 --- a/src/Data/RandomWalkSimilarity.hs +++ b/src/Data/RandomWalkSimilarity.hs @@ -88,6 +88,7 @@ featureVector d bag = sumVectors $ unitDVector . hash <$> bag normalize vec = fmap (/ vmagnitude vec) vec sumVectors = DList.foldr (Vector.zipWith (+)) (Vector.replicate d 0) +-- | The magnitude of a Euclidean vector, i.e. its distance from the origin. vmagnitude :: Vector.Vector Double -> Double vmagnitude = sqrtDouble . Vector.sum . fmap (** 2)