[ 
https://issues.apache.org/jira/browse/MATH-545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005609#comment-13005609
 ] 

Gilles commented on MATH-545:
-----------------------------

Shall we add "cosine" to the "RealVector" interface?

And the implementation would go in "AbstractRealVector":
{noformat}
public double cosine(RealVector v) {
  final double norm = getNorm();
  final double vNorm = v.getNorm();
  if (norm == 0 || vNorm == 0) {
      throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
  }
  return dotProduct(v) / (norm * vNorm);
}
{noformat}


> Feature Request: RealVector cosine
> ----------------------------------
>
>                 Key: MATH-545
>                 URL: https://issues.apache.org/jira/browse/MATH-545
>             Project: Commons Math
>          Issue Type: New Feature
>            Reporter: Benjamin McCann
>
> I'd like a method to compute the cosine similarity between vectors.
> http://en.wikipedia.org/wiki/Cosine_similarity

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to