我正在尝试通过使用 ScaLAPACK 的 MKL-Intel 库的pdpotrf()进行 Cholesky 分解。我正在读取主节点中的整个矩阵,然后像本例中那样分发它。当 SPD 矩阵的维数是偶数时,一切正常。但是,当它很奇怪时,pdpotrf()
认为矩阵不是正定的。
可能是因为子矩阵不是 SPD 吗?我正在使用这个矩阵:
子矩阵是(有 4 个进程和大小为 2x2 的块):
A_loc on node 0
4 1 2
1 0.5 0
2 0 16
nrows = 3, ncols = 2
A_loc on node 1
2 0.5
0 0
0 0
nrows = 2, ncols = 3
A_loc on node 2
2 0 0
0.5 0 0
nrows = 2, ncols = 2
A_loc on node 3
3 0
0 0.625
在这里,每个子矩阵都不是 SPD,但是,整个矩阵是 SPD(已检查运行 1 个进程)。我该怎么办?还是我无能为力,pdpotrf()
也不能处理奇数大小的矩阵?
这是我调用例程的方式:
int iZERO = 0;
int descA[9];
// N, M dimensions of matrix. lda = N
// Nb, Mb dimensions of block
descinit_(descA, &N, &M, &Nb, &Mb, &iZERO, &iZERO, &ctxt, &lda, &info);
...
pdpotrf((char*)"L", &ord, A_loc, &IA, &JA, descA, &info);
我也试过这个:
// nrows/ncols is the number of rows/columns a submatrix has
descinit_(descA, &N, &M, &nrows, &ncols, &iZERO, &iZERO, &ctxt, &lda, &info);
但我收到一个错误:
{ 0, 0}:进入 { 0, 1}:进入 PDPOTR{ 1, 0}:进入 PDPOTRF 参数编号 605 时具有非法值 { 1, 1}:进入 PDPOTRF 参数编号 605 时具有非法值 F 参数号 605 具有非法值
PDPOTRF 参数编号 605 具有非法值 info < 0:如果第 i 个参数是一个数组并且第 j 项具有非法值,则 INFO = -(i*100+j),如果第 i 个参数是一个标量并且有一个非法值,那么 INFO = -i。信息 = -605
从我的回答中,您可以看到函数的参数是什么意思。
代码基于这个问题。输出:
gsamaras@pythagoras:~/konstantis/check_examples$ ../../mpich-install/bin/mpic++ -o test minor.cpp -I../../intel/mkl/include ../../intel/mkl/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group ../../intel/mkl/lib/intel64/libmkl_intel_lp64.a ../../intel/mkl/lib/intel64/libmkl_core.a ../../intel/mkl/lib/intel64/libmkl_sequential.a -Wl,--end-group ../../intel/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a -lpthread -lm -ldl
gsamaras@pythagoras:~/konstantis/check_examples$ mpiexec -n 4 ./test
Processes grid pattern:
0 1
2 3
nrows = 3, ncols = 3
A_loc on node 0
4 1 2
1 0.5 0
2 0 16
nrows = 3, ncols = 2
A_loc on node 1
2 0.5
0 0
0 0
nrows = 2, ncols = 3
A_loc on node 2
2 0 0
0.5 0 0
nrows = 2, ncols = 2
A_loc on node 3
3 0
0 0.625
Description init sucesss!
matrix is not positive definte
Matrix A result:
2 1 2 0.5 2
0.5 0.5 0 0 0
1 0 1 0 -0.25
0.25 -1 -0.5 0.625 0
1 -1 -2 -0.5 14