public void mapInPlace ( Function < Double , Double > fn ) { for ( int i = 0 ; i < pointers . length ; i ++ ) { if ( pointers [ i ] == null ) continue ; if ( copyOnWrite [ i ] ) { copyOnWrite [ i ] = false ; pointers [ i ] = pointers [ i ] . clone ( ) ; } if ( sparse [ i ] ) { for ( int j = 0 ; j < pointers [ i ] . length / 2 ; j ++ ) { pointers [ i ] [ ( j * 2 ) + 1 ] = fn . apply ( pointers [ i ] [ ( j * 2 ) + 1 ] ) ; } } else { for ( int j = 0 ; j < pointers [ i ] . length ; j ++ ) { pointers [ i ] [ j ] = fn . apply ( pointers [ i ] [ j ] ) ; } } } }
Apply a function to every element of every component of this vector and replace with the result .