public double distance ( double [ ] v1 , double [ ] v2 ) { final int dim1 = v1 . length , dim2 = v2 . length ; final int mindim = dim1 < dim2 ? dim1 : dim2 ; double agg = preDistance ( v1 , v2 , 0 , mindim ) ; if ( dim1 > mindim ) { agg += preNorm ( v1 , mindim , dim1 ) ; } else if ( dim2 > mindim ) { agg += preNorm ( v2 , mindim , dim2 ) ; } return agg ; }
Special version for double arrays .