如何将矩阵重塑为 MKL DSS 的行主要顺序?

计算科学 线性求解器 稀疏矩阵 英特尔-mkl
2021-12-17 22:49:09

我想使用 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}}

例如,有一个稀疏线性系统A5×5X5×3=B5×3

在哪里A是对称稀疏数组

在此处输入图像描述

//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}

X5×3=(326.333844.667136398325484113163.417423682.5833981028165861.5159256.5)

在我的应用程序中,矩阵是行优先的。如何处理这个问题?

0个回答
没有发现任何回复~