我想进行行透视以使用PSLAPIV生成排列的分布式矩阵。我有三个问题。
1-如何初始化和分发IPIV向量?
2-如果我只想置换矩阵A的行,为ROWCOL和PIVROC选择哪个值?
3-以下代码是否正确?
Cblacs_get(-1, 0, &icontxt);
Cblacs_gridinit( &icontxt, "Row", prow, pcol );
Cblacs_gridinfo(icontxt, &prow, &pcol, &myrow, &mycol);
// Get the local size and make memeory allocation
int i0 = 0; int q1=1; int one=1;
myArows = numroc_(&MF, &nb, &myrow, &i0, &prow );
myAcols = numroc_(&NF, &nb, &mycol, &i0, &pcol );
//For pivoting the rows of sub( A ), IPIV should be distributed along a process column and replicated over all process rows.
myIProws = numroc_(&one, &one, &myrow, &i0, &prow); //since it is vector
myIPcols = numroc_(&MF, &nb, &mycol, &i0, &pcol);
int A_size = myArows * myAcols;
int IP_size = myIProws * myIPcols;
itempA = max( 1, myArows );
itempIP = max(1, myIProws);
descinit_(descA, &MF, &NF, &nb, &nb, &i0, &i0, &icontxt, &itempA, &info );
printf("\n A info:%d\n", info);
descinit_(descIP, &one, &MF, &one, &nb, &i0, &i0, &icontxt, &itempIP, &info );
printf("\n IP info:%d\n", info);
A = (float *) malloc (A_size*sizeof(float));
if (A == NULL){
printf("\n malloc() A failed \n");
fflush(stdout);
MPI_Finalize();
return -1;
}
IPIV = (int *) malloc ((myArows+nb)* sizeof(int));
if (IPIV == NULL){
printf("\n malloc() IPIV failed \n");
fflush(stdout);
MPI_Finalize();
return -1;
}
lwork= myArows+nb;
pslapiv_('F', 'R', 'C', &M, &N, A, &ia, &ja, descA, IPIV, &ia, &ja, descIP , &lwork );