Skip to content

Instantly share code, notes, and snippets.

@non
Created April 29, 2014 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non/11405704 to your computer and use it in GitHub Desktop.
Save non/11405704 to your computer and use it in GitHub Desktop.
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