/** * Returns the index of the target landmark closest to the input point as well * as the distance to that landmark. * * @param target the point * @return a pair containing the closest landmark point and its squared * distance to that landmark */ public IndexDistancePair closestTargetLandmarkAndDistance( final double[] target ) { int idx = -1; double distSqr = Double.MAX_VALUE; double thisDist = 0.0; final double[] err = new double[ this.ndims ]; for ( int l = 0; l < this.nLandmarks; l++ ) { tgtPtDisplacement( l, target, err ); thisDist = normSqrd( err ); if ( thisDist < distSqr ) { distSqr = thisDist; idx = l; } } return new IndexDistancePair( idx, distSqr ); }