public static int [ ] getInt2DColumnSum ( int [ ] [ ] apsp ) { int [ ] colSum = new int [ apsp . length ] ; int sum ; for ( int i = 0 ; i < apsp . length ; i ++ ) { sum = 0 ; for ( int j = 0 ; j < apsp . length ; j ++ ) { sum += apsp [ i ] [ j ] ; } colSum [ i ] = sum ; } return colSum ; }
Sums up the columns in a 2D int matrix .