mirror of
https://github.com/github/semantic.git
synced 2024-12-19 12:51:52 +03:00
📝 vmagnitude.
This commit is contained in:
parent
cf6a5d77a6
commit
9632bea377
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user