public double saxMinDist(char[] a,char[] b,double[][] distanceMatrix,int n,int w) throws SAXException {
  if (a.length == b.length) {
    double dist=0.0D;
    for (int i=0; i < a.length; i++) {
      if (Character.isLetter(a[i]) && Character.isLetter(b[i])) {
        int numA=Character.getNumericValue(a[i]) - 10;
        int numB=Character.getNumericValue(b[i]) - 10;
        int maxIdx=distanceMatrix[0].length;
        if (numA > (maxIdx - 1) || numA < 0 || numB > (maxIdx - 1) || numB < 0) {
          throw new SAXException("The character index greater than " + maxIdx + " or less than 0!");
        }
        double localDist=distanceMatrix[numA][numB];
        dist=dist + localDist * localDist;
      }
 else {
        throw new SAXException("Non-literal character found!");
      }
    }
    return Math.sqrt((double)n / (double)w) * Math.sqrt(dist);
  }
 else {
    throw new SAXException("Data arrays lengths are not equal!");
  }
}

public double saxMinDist ( char [ ] a , char [ ] b , double [ ] [ ] distanceMatrix , int n , int w ) throws SAXException { if ( a . length == b . length ) { double dist = 0.0D ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( Character . isLetter ( a [ i ] ) && Character . isLetter ( b [ i ] ) ) { int numA = Character . getNumericValue ( a [ i ] ) - 10 ; int numB = Character . getNumericValue ( b [ i ] ) - 10 ; int maxIdx = distanceMatrix [ 0 ] . length ; if ( numA > ( maxIdx - 1 ) || numA < 0 || numB > ( maxIdx - 1 ) || numB < 0 ) { throw new SAXException ( "The character index greater than " + maxIdx + " or less than 0!" ) ; } double localDist = distanceMatrix [ numA ] [ numB ] ; dist = dist + localDist * localDist ; } else { throw new SAXException ( "Non-literal character found!" ) ; } } return Math . sqrt ( ( double ) n / ( double ) w ) * Math . sqrt ( dist ) ; } else { throw new SAXException ( "Data arrays lengths are not equal!" ) ; } }
this function implements sax mindist function which uses alphabet based distance matrix .
