protected double measureCartesianAngularOverlap(ComplexVector other){
  toCartesian();
  other.toCartesian();
  double cumulativeCosine=0;
  int nonZeroDimensionPairs=0;
  for (int i=0; i < dimension * 2; i+=2) {
    double resultThisPair=coordinates[i] * other.coordinates[i];
    resultThisPair+=coordinates[i + 1] * other.coordinates[i + 1];
    double norm1=coordinates[i] * coordinates[i];
    norm1+=coordinates[i + 1] * coordinates[i + 1];
    double norm2=other.coordinates[i] * other.coordinates[i];
    norm2+=other.coordinates[i + 1] * other.coordinates[i + 1];
    norm1=Math.sqrt(norm1);
    norm2=Math.sqrt(norm2);
    if (norm1 > 0 && norm2 > 0) {
      cumulativeCosine+=resultThisPair / (norm1 * norm2);
      ++nonZeroDimensionPairs;
    }
  }
  return (nonZeroDimensionPairs != 0) ? (cumulativeCosine / nonZeroDimensionPairs) : 0;
}

protected double measureCartesianAngularOverlap ( ComplexVector other ) { toCartesian ( ) ; other . toCartesian ( ) ; double cumulativeCosine = 0 ; int nonZeroDimensionPairs = 0 ; for ( int i = 0 ; i < dimension * 2 ; i += 2 ) { double resultThisPair = coordinates [ i ] * other . coordinates [ i ] ; resultThisPair += coordinates [ i + 1 ] * other . coordinates [ i + 1 ] ; double norm1 = coordinates [ i ] * coordinates [ i ] ; norm1 += coordinates [ i + 1 ] * coordinates [ i + 1 ] ; double norm2 = other . coordinates [ i ] * other . coordinates [ i ] ; norm2 += other . coordinates [ i + 1 ] * other . coordinates [ i + 1 ] ; norm1 = Math . sqrt ( norm1 ) ; norm2 = Math . sqrt ( norm2 ) ; if ( norm1 > 0 && norm2 > 0 ) { cumulativeCosine += resultThisPair / ( norm1 * norm2 ) ; ++ nonZeroDimensionPairs ; } } return ( nonZeroDimensionPairs != 0 ) ? ( cumulativeCosine / nonZeroDimensionPairs ) : 0 ; }
measure overlap , again using the sum of cosines of phase angle difference . note that this is different from the hermitian scalar product .
