public static double [ ] pairwiseMax ( double [ ] vector1 , double [ ] vector2 ) { // Initialize the return value: final double [ ] retval = new double [ vector1 . length ] ; // Iterate over values and get maxs: for ( int i = 0 ; i < retval . length ; i ++ ) { retval [ i ] = Math . max ( vector1 [ i ] , vector2 [ i ] ) ; } // Done, return: return retval ; }
Computes a vector as the max of respective pairs from two arrays .