Created
April 29, 2014 16:42
-
-
Save non/11405704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def genericCosineSimilarity[V, @sp(Double) A](v1: V, v2: V)(implicit ips: InnerProductSpace[V, A], nr: NRoot[A]): A = { | |
implicit val field = ips.scalar | |
implicit val nvs = ips.normed | |
(v1 dot v2) / (v1.norm * v2.norm) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment