public double[] vectorize() {
        int nRows = getRowDimension();
        int nCols = getColumnDimension();
        /*
         * if ((nRows == 0) || (nCols == 0)) { throw new MatrixIndexException(
         * "Matrix: either number of rows or number of columns is 0."); }
         */

        double data[][] = getDataRef();

        double[] vector = new double[nRows * nCols];
        int i = 0;

        for (int c = 0; c < nCols; c++) {
            for (int r = 0; r < nRows; r++) {
                vector[i] = data[r][c];
                i++;
            }
        }

        return vector;
    }