commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin McCann (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (MATH-545) Feature Request: RealVector cosine
Date Fri, 11 Mar 2011 06:37:59 GMT

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

Benjamin McCann edited comment on MATH-545 at 3/11/11 6:36 AM:
---------------------------------------------------------------

I guess it's pretty simple, but it still might be nice as a convenience method:
{noformat} 
  public double cosine(double[] a1, double[] a2) {
    ArrayRealVector v1 = new ArrayRealVector(a1);
    ArrayRealVector v2 = new ArrayRealVector(a2);
    return v1.dotProduct(v2) / (v1.getNorm() * v2.getNorm());
  }
{noformat}

      was (Author: bmccann):
    I guess it's pretty simple, but it still might be nice as a convenience method:

    public double cosine(double[] a1, double[] a2) {
      ArrayRealVector v1 = new ArrayRealVector(a1);
      ArrayRealVector v2 = new ArrayRealVector(a2);
      return v1.dotProduct(v2) / (v1.getNorm() * v2.getNorm());
    }
  
> 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

Mime
View raw message