code: public static RealMatrix colSubtract (RealMatrix matrix, double[] vector) {
          // Declare and initialize the new matrix:
          double[][] retval = new double[matrix.getRowDimension()][matrix.getColumnDimension()];
  
          // Iterate over rows:
          for (int col = 0; col < retval.length; col++) {
              // Iterate over columns:
              for (int row = 0; row < retval[0].length; row++) {
                  retval[row][col] = matrix.getEntry(row, col) - vector[row];
              }
          }
  
          // Done, return a new matrix:
          return MatrixUtils.createRealMatrix(retval);
      }
docs: Returns a new matrix by subtracting elements column by column.
  
  @param matrix The input matrix
  @param vector The vector to be subtracted from columns
  @return A new matrix of which the vector is subtracted column by column