我在使用英特尔MKL PARDISO
时遇到问题。我可以运行库提供的实对称矩阵pardiso_sym_c.c
的示例,如下所示。
MKL_INT n = 8;
MKL_INT ia[9] = { 1, 5, 8, 10, 12, 15, 17, 18, 19 };
MKL_INT ja[18] =
{ 1, 3, 6, 7,
2, 3, 5,
3, 8,
4, 7,
5, 6, 7,
6, 8,
7,
8
};
double a[18] =
{ 7.0, 1.0, 2.0, 7.0,
-4.0, 8.0, 2.0,
1.0, 5.0,
7.0, 9.0,
5.0, 1.0, 5.0,
-1.0, 5.0,
11.0,
5.0
};
MKL_INT mtype = -2; /* Real symmetric matrix */
MKL_INT nrhs = 1; /* Number of right hand sides. */
/* Internal solver memory pointer pt, */
/* 32-bit: int pt[64]; 64-bit: long int pt[64] */
/* or void *pt[64] should be OK on both architectures */
void *pt[64];
/* Pardiso control parameters. */
MKL_INT iparm[64];
MKL_INT maxfct, mnum, phase, error, msglvl;
/* Auxiliary variables. */
MKL_INT i;
double ddum; /* Double dummy */
MKL_INT idum; /* Integer dummy. */
/* -------------------------------------------------------------------- */
/* .. Setup Pardiso control parameters. */
/* -------------------------------------------------------------------- */
for (i = 0; i < 64; i++)
{
iparm[i] = 0;
}
iparm[0] = 1; /* No solver default */
iparm[1] = 2; /* Fill-in reordering from METIS */
iparm[3] = 0; /* No iterative-direct algorithm */
iparm[4] = 0; /* No user fill-in reducing permutation */
iparm[5] = 0; /* Write solution into x */
iparm[6] = 0; /* Not in use */
iparm[7] = 2; /* Max numbers of iterative refinement steps */
iparm[8] = 0; /* Not in use */
iparm[9] = 13; /* Perturb the pivot elements with 1E-13 */
iparm[10] = 1; /* Use nonsymmetric permutation and scaling MPS */
iparm[11] = 0; /* Not in use */
iparm[12] = 0; /* Maximum weighted matching algorithm is switched-off (default for symmetric). Try iparm[12] = 1 in case of inappropriate accuracy */
iparm[13] = 0; /* Output: Number of perturbed pivots */
iparm[14] = 0; /* Not in use */
iparm[15] = 0; /* Not in use */
iparm[16] = 0; /* Not in use */
iparm[17] = -1; /* Output: Number of nonzeros in the factor LU */
iparm[18] = -1; /* Output: Mflops for LU factorization */
iparm[19] = 0; /* Output: Numbers of CG Iterations */
maxfct = 1; /* Maximum number of numerical factorizations. */
mnum = 1; /* Which factorization to use. */
msglvl = 1; /* Print statistical information in file */
error = 0; /* Initialize error flag */
/* -------------------------------------------------------------------- */
/* .. Initialize the internal solver memory pointer. This is only */
/* necessary for the FIRST call of the PARDISO solver. */
/* -------------------------------------------------------------------- */
for (i = 0; i < 64; i++)
{
pt[i] = 0;
}
/* -------------------------------------------------------------------- */
/* .. Reordering and Symbolic Factorization. This step also allocates */
/* all memory that is necessary for the factorization. */
/* -------------------------------------------------------------------- */
phase = 11; // Analysis phase: https://software.intel.com/en-us/mkl-developer-reference-c-pardiso#BEA1BEA6-A0C0-46C4-A8EC-EC42BA473E1D
pardiso(pt, &maxfct, &mnum, &mtype, &phase,
&n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error);
上面的代码运行没有问题。
在我的方程组中,Ax=b
,A
也是一个实对称矩阵,大小为18x18
。 A
的上三角矩阵以CSR
格式存储:
MKL_INT n = 18;
double a[72] = {1.948975, 0.066884, -0.150949, -0.261933, -0.325631, -0.180171, -0.051572, -0.318613, -0.353708, -0.131304, 2.330696, -0.261933, -0.471526, -0.347310, -0.488919, 0.073609, -0.504371, 0.103671, 0.110624, 0.008506, -0.425317, 1.948975, 0.066884, -0.051572, -0.353708, -0.318613, -0.325631, -0.180171, -0.131304, 1.625462, 0.103671, -0.417045, -0.326084, 2.330696, -0.504371, 0.008506, 0.110624, -0.488919, -0.471526, 0.073609, -0.425317, 1.578165, -0.247065, -0.391888, 0.120848, 1.687572, -0.410749, 0.120848, 1.817920, -0.448414, 1.687572, -0.417045, -0.410749, 0.120848, 1.425970, -0.170845, -0.247065, 1.708300, -0.391888, -0.448414, 1.425970, -0.170845, 1.578165, 0.120848, 1.625462, -0.326084, 1.708300, -0.448414, 1.817920, -0.448414, 1.710851, 1.710851};
MKL_INT ja[72] = {0, 1, 2, 4, 9, 10, 12, 14, 15, 17, 1, 2, 3, 4, 5, 7, 8, 13, 14, 15, 17, 2, 4, 5, 7, 10, 11, 14, 16, 3, 4, 6, 7, 4, 6, 7, 10, 12, 13, 15, 16, 5, 11, 14, 17, 6, 7, 16, 7, 16, 8, 13, 15, 17, 9, 10, 12, 10, 12, 16, 11, 14, 12, 16, 13, 15, 14, 17, 15, 17, 16, 17};
MKL_INT ia[19] = {0, 10, 21, 29, 33, 41, 45, 48, 50, 54, 57, 60, 62, 64, 66, 68, 70, 71, 72};
我已经确认了上述CSR数据的有效性,该数据代表了MATLAB中大小为18x18
的稀疏对称矩阵(请参见下图,该图显示了上部三角形部分)
pardiso_sym_c.c
中的稀疏矩阵被替换为另一个大小不同的实对称矩阵。我正在使用Visual Studio 2017,在PARDISO
算法(即phase = 11
)的分析阶段收到以下错误消息。当sprase矩阵是pardiso_sym_c.c
中提供的矩阵时,不会发生此错误。我只更改了输入矩阵,并想使用其余的PARDISO
设置。
pardiso(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error);
Access violation writing location
有人可以帮我解决这个问题吗?