Search code examples
csparse-matrixintel-mkl

Convert COO to CSR format in c++


I have a matrix in the COO format. More specifically, there are three matrices row_index, column_index, value. Can you help me to convert this matrix format in CSR format with an efficient, not computationally expensive way, using C language? Are there libraries for this purpose?

Example:

enter image description here

COO format:

       row_index col_index value
          1         1         1
          1         2        -1
          1         3        -3   
          2         1        -2
          2         2         5
          3         3         4
          3         4         6
          3         5         4
          4         1        -4
          4         3         2
          4         4         7     
          5         2         8
          5         5        -5 

Solution

  • Intel MKL documentation (for mkl_csrcoo) states:

    Converts a sparse matrix in the CSR format to the coordinate format and vice versa.

    And according to the above link you should set job:

    if job(1)=1, the matrix in the coordinate format is converted to the CSR format.