@Override
    public SparseVector getColumn(int i) {
        if (i < 0 || i > dim2) {
            throw new IllegalArgumentException("Invalid column index, must be [0,"+dim2+"), received " + i);
        }
        List<Integer> indexList = new ArrayList<>();
        List<Double> valueList = new ArrayList<>();
        for (int j = 0; j < dim1; j++) {
            double tmp = values[j].get(i);
            if (tmp != 0) {
                indexList.add(j);
                valueList.add(tmp);
            }
        }

        int[] indicesArr = new int[valueList.size()];
        double[] valuesArr = new double[valueList.size()];
        for (int j = 0; j < valueList.size(); j++) {
            indicesArr[j] = indexList.get(j);
            valuesArr[j] = valueList.get(j);
        }
        return new SparseVector(dim1, indicesArr, valuesArr);
    }
@Test
    public void testGetColumn() {
        DenseSparseMatrix diagonal = DenseSparseMatrix.createDiagonal(new DenseVector(new double[] {1.618033988749894, Math.E, Math.PI}));
        SparseVector column = diagonal.getColumn(1);
        assertEquals(3, column.size());
        assertEquals(0, column.get(0));
        assertEquals(Math.E, column.get(1));
        assertEquals(0, column.get(2));
    }