1
$\begingroup$

I would like to use MKL to solve a sparse linear system. I chose the DSS (Direct Sparse Solver) interface, which implements the following steps:

//(1).define the non-zero structure of the matrix
dss_define_structure(handle, sym, rowIndex, nRows, nCols, columns, nNonZeros);
//(2).reorder the matrix
dss_reorder(handle, opt, 0);
//(3).factor the matrix
dss_factor_real(handle, type, values);
//(4).get the solution vector
dss_solve_real(handle, opt, rhs, nRhs, solValues);
//(5).deallocate solver storage
dss_delete(handle, opt);

According to my test, the DSS uses a column-major ordering. That means

//column = 3
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }

is equivalent to

{{1,  6,  11},
 {2,  7,  12},
 {3,  8,  13},
 {4,  9,  14}
 {5, 10,  15}}

For instance, there is a sparase linear system $\mathbf A_{5\times 5}\mathbf X_{5\times 3}=\mathbf B_{5\times 3}$

where $\mathbf A$ is symmetric sparse array

enter image description here

//A stored with CSR3 format
rowIndex = { 0, 5, 6, 7, 8, 9 };
columns = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
values = { 9, 1.5, 6, .75, 3, 0.5, 12, .625, 16 };
//B
rhs[5*3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
//X
solValues[15]

By calling the above DSS interface, the solValues is

{-326.333, 983, 163.417, 398, 61.5, 
 -844.667, 2548, 423, 1028, 159, 
-1363, 4113, 682.583, 1658, 256.5}

Namely

$$ \mathbf X_{5\times 3}=\left( \begin{array}{ccc} -326.333 & -844.667 & -1363 \\ 983 & 2548 & 4113 \\ 163.417 & 423 & 682.583 \\ 398 & 1028 & 1658 \\ 61.5 & 159 & 256.5 \\ \end{array} \right) $$

In my application, the matrix is row-major. How to deal with this problem?

$\endgroup$
4
  • 2
    $\begingroup$ The example you show is a dense matrix. The DSS (obviously) deals with the sparse matrix format (shown here: software.intel.com/en-us/node/…). How are you storing the sparse matrix in your software? $\endgroup$ Mar 21, 2017 at 12:19
  • $\begingroup$ @BillGreene In my application, I also stores the sparse matrix with CSR3 format via zero-based indexing. $\endgroup$
    – xyz
    Mar 22, 2017 at 6:45
  • $\begingroup$ @BillGreene In addition, for a linear system $\mathbf A_{n \times n}\mathbf X_{n \times c}=\mathbf B_{n \times c}$ , the storing of $\mathbf X$ and $\mathbf B $ are in row-major ordering $\endgroup$
    – xyz
    Mar 22, 2017 at 6:51
  • $\begingroup$ According to the DSS documentation page I referenced, it requires CSR format. So you should be all set. $\endgroup$ Mar 22, 2017 at 11:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.