cdm/src/main/java/ucar/ma2/MAVector.java
public double cos(MAVector v) {

    if (nelems != v.getNelems())
      throw new IllegalArgumentException("MAVector.cos "+nelems+" != "+ v.getNelems());

    double norm = norm();
    double normV = v.norm();
    if ((norm == 0.0) || (normV == 0.0))
      return 0.0;
    else
      return dot(v)/(norm*normV);
  }
public double cos(MAVector v) {

    if (nelems != v.getNelems())
      throw new IllegalArgumentException("MAVector.cos "+nelems+" != "+ v.getNelems());

    double norm = norm();
    double normV = v.norm();
    if ((norm == 0.0) || (normV == 0.0))
      return 0.0;
    else
      return dot(v)/(norm*normV);
  }
public double cos ( MAVector v ) { if ( nelems != v . getNelems ( ) ) throw new IllegalArgumentException ( "MAVector.cos " + nelems + " != " + v . getNelems ( ) ) ; double norm = norm ( ) ; double normV = v . norm ( ) ; if ( ( norm == 0.0 ) || ( normV == 0.0 ) ) return 0.0 ; else return dot ( v ) / ( norm * normV ) ; }
Cos between two vectors = dot(v) / norm() * norm(v)
@param v cosine with this vector
@return double result: cos between this and v
@exception IllegalArgumentException if nelems != v.getNelems().
Cos between two vectors = dot ( v ) / norm () * norm ( v )