Sparse matrix in C interface (Documentation bug?)


I tried to understand csc-format used in the C interface for the P and A matrix. And with all my understanding I have right now, I think that there is a bug in the documentation.

The documentation claims, that the matrix [[4, 1], [1, 2]] is represented by:

   c_float P_x[3] = {4.0, 1.0, 2.0, };
    c_int P_nnz = 3;
    c_int P_i[3] = {0, 0, 1, };
    c_int P_p[3] = {0, 1, 3, };

But in this representation P_x has less elements than nonzero values exists in the matrix.
I think it should be like the manual for v0.3:

c_float P_x[4] = {4.00, 1.00, 1.00, 2.00, };
c_int P_nnz = 4;
c_int P_i[4] = {0, 1, 0, 1, };
c_int P_p[3] = {0, 2, 4, };

Am I wrong?

Best regards

As of version 0.6.0 (the current version is 0.6.2), the P matrix is assumed to be symmetric and so it is specified using the upper triangular part only (previously you could either specify only the upper triangular part or the full matrix, but if you specified the full matrix it just ignored the lower triangular portion and reflected the upper triangular portion across the diagonal).

This means that you need to pass a matrix with only the upper triangular non-zeros, so the P matrix in the example you give should have 3 non-zeros that you pass in, and then the solver automatically adds the 4th non-zero value as needed in the computations.

Ah ok! Thanks for clarification!!