public static DenseSparseMatrix createDiagonal(SGDVector diagonal) {
        int dimension = diagonal.size();
        SparseVector[] newValues = new SparseVector[dimension];
        for (int i = 0; i < dimension; i++) {
            newValues[i] = new SparseVector(dimension, new int[]{i}, new double[]{diagonal.get(i)});
        }
        return new DenseSparseMatrix(newValues);
    }
@Test
    public void testCreateDiagonal() {
        DenseSparseMatrix diagonal = DenseSparseMatrix.createDiagonal(new DenseVector(new double[] {1.0, 2.0}));
        assertMatrixEquals(new DenseMatrix(new double[][]{new double[]{1.0, 0.0}, new double[]{0.0, 2.0}}),diagonal);
        diagonal = DenseSparseMatrix.createDiagonal(new DenseVector(new double[] {1.618033988749894, Math.E, Math.PI}));
        assertMatrixEquals(new DenseMatrix(new double[][]{new double[]{1.618033988749894, 0.0, 0.0}, new double[]{0.0, 2.718281828459045, 0.0}, new double[]{0.0, 0.0, 3.141592653589793}}),diagonal);
    }