public static LinearScale [ ] calcScales ( Relation < ? extends SpatialComparable > rel ) { int dim = RelationUtil . dimensionality ( rel ) ; DoubleMinMax [ ] minmax = DoubleMinMax . newArray ( dim ) ; LinearScale [ ] scales = new LinearScale [ dim ] ; // analyze data for ( DBIDIter iditer = rel . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { SpatialComparable v = rel . get ( iditer ) ; if ( v instanceof NumberVector ) { for ( int d = 0 ; d < dim ; d ++ ) { final double mi = v . getMin ( d ) ; if ( mi != mi ) { // NaN continue ; } minmax [ d ] . put ( mi ) ; } } else { for ( int d = 0 ; d < dim ; d ++ ) { final double mi = v . getMin ( d ) ; if ( mi == mi ) { // No NaN minmax [ d ] . put ( mi ) ; } final double ma = v . getMax ( d ) ; if ( ma == ma ) { // No NaN minmax [ d ] . put ( ma ) ; } } } } // generate scales for ( int d = 0 ; d < dim ; d ++ ) { scales [ d ] = new LinearScale ( minmax [ d ] . getMin ( ) , minmax [ d ] . getMax ( ) ) ; } return scales ; }
Compute a linear scale for each dimension .