private double [ ] [ ] concatenateArrays ( double [ ] [ ] first , double [ ] [ ] second ) { // I am sure as hell that should be a better way to do this... double [ ] [ ] result = new double [ first . length ] [ first [ 0 ] . length + second [ 0 ] . length ] ; for ( int i = 0 ; i < first . length ; i ++ ) { for ( int j = 0 ; j < ( first [ i ] . length + second [ i ] . length ) ; j ++ ) { if ( j < first [ i ] . length ) { result [ i ] [ j ] = first [ i ] [ j ] ; } else { result [ i ] [ j ] = second [ i ] [ j - first [ i ] . length ] ; } } } return result ; }
Concatenate two two dimensional arrays . Both arrays must have the same dimensions .