protected static HyperBoundingBox computeBounds ( NumberVector [ ] samples ) { assert ( samples . length > 0 ) : "Cannot compute bounding box of empty set." ; // Compute bounds: final int dimensions = samples [ 0 ] . getDimensionality ( ) ; final double [ ] min = new double [ dimensions ] ; final double [ ] max = new double [ dimensions ] ; NumberVector first = samples [ 0 ] ; for ( int d = 0 ; d < dimensions ; d ++ ) { min [ d ] = max [ d ] = first . doubleValue ( d ) ; } for ( int i = 1 ; i < samples . length ; i ++ ) { NumberVector v = samples [ i ] ; for ( int d = 0 ; d < dimensions ; d ++ ) { final double c = v . doubleValue ( d ) ; min [ d ] = c < min [ d ] ? c : min [ d ] ; max [ d ] = c > max [ d ] ? c : max [ d ] ; } } return new HyperBoundingBox ( min , max ) ; }
Compute the bounding box for some samples .