public void setColumn(int index, SGDVector vector) {
        if (index < 0 || index > dim2) {
            throw new IllegalArgumentException("Invalid column index, must be [0,"+dim2+"), received " + index);
        }
        if (vector.size() == dim1) {
            if (vector instanceof DenseVector) {
                for (int i = 0; i < dim1; i++) {
                    values[i][index] = vector.get(i);
                }
            } else {
                for (VectorTuple t : vector) {
                    values[t.index][index] = t.value;
                }
            }
        } else {
            throw new IllegalArgumentException("Vector size mismatch, expected " + dim1 + " found " + vector.size());
        }
    }
@Test
    public void setColumnTest() {
        //create a 2x3 matrix
        DenseMatrix a = new DenseMatrix(new double[][] {new double[] {1.0, 2.0, 3.0}, new double[] {4.0, 5.0, 6.0}});
        assertEquals(2, a.getDimension1Size());
        assertEquals(3, a.getDimension2Size());
        a.setColumn(2, new DenseVector(new double[] {7.0, 8.0}));
        assertEquals(7.0, a.get(0,2));
        assertEquals(8.0, a.get(1,2));
        double[][] d = a.toArray();
        assertArrayEquals(new double[] {1.0, 2.0, 7.0}, d[0]);
        assertArrayEquals(new double[] {4.0, 5.0, 8.0}, d[1]);
    }