我想使用 MKL 来解决稀疏线性系统。我选择了DSS(Direct Sparse Solver)接口,它实现了以下步骤:
//(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);
根据我的测试,DSS 使用列优先排序。这意味着
//column = 3
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
相当于
{{1, 6, 11},
{2, 7, 12},
{3, 8, 13},
{4, 9, 14}
{5, 10, 15}}
例如,有一个稀疏线性系统
在哪里是对称稀疏数组
//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]
通过调用上面的DSS接口,solValues
就是
{-326.333, 983, 163.417, 398, 61.5,
-844.667, 2548, 423, 1028, 159,
-1363, 4113, 682.583, 1658, 256.5}
即
在我的应用程序中,矩阵是行优先的。如何处理这个问题?