correctly. Any advice would be much appreciated.
A portion of the C code I use to initialize ipiv for an identity permutation of the columns is as follows:
- Code: Select all
descinit_(desc_ipiv, &one, &_n, &_mb, &_nb, &zero, &zero, &_context, &one, &info);
for (int i=1; i <=_n; i++) {
pielset_(ipiv, &one, &i, desc_ipiv, &i);
}
// Broadcast to all process rows
char scope = 'C';
char top = ' ';
if (_myrow == 0) {
Cigebs2d(_context, &scope, &top, one, _nc, (char *) ipiv, one);
} else {
Cigebr2d(_context, &scope, &top, one, _nc, (char *) ipiv, one, zero, _mycol);
}
for (int i=0; i<_nc; i++) {
std::cout << "_myrow = " << _myrow << ", _mycol = " << _mycol << " : ipiv[" << i+1 << "] = " << ipiv[i] << std::endl;
}
My simple test case uses a random matrix defined as follow:
Matrix _A (_m x _n) is 8x8, the block size (_mb x _nb) is 2 x 2 and the process grid is 2x2.
- Code: Select all
descinit_(_desc_A, &_m, &_n, &_mb, &_nb, &zero, &zero, &_context, &_lld, &info );
Here's the output for ipiv. It's what I expected but perhaps not what I want.
_myrow = 0, _mycol = 0 : ipiv[1] = 1
_myrow = 0, _mycol = 0 : ipiv[2] = 2
_myrow = 0, _mycol = 0 : ipiv[3] = 5
_myrow = 0, _mycol = 0 : ipiv[4] = 6
_myrow = 0, _mycol = 1 : ipiv[1] = 3
_myrow = 0, _mycol = 1 : ipiv[2] = 4
_myrow = 0, _mycol = 1 : ipiv[3] = 7
_myrow = 0, _mycol = 1 : ipiv[4] = 8
_myrow = 1, _mycol = 0 : ipiv[1] = 1
_myrow = 1, _mycol = 0 : ipiv[2] = 2
_myrow = 1, _mycol = 0 : ipiv[3] = 5
_myrow = 1, _mycol = 0 : ipiv[4] = 6
_myrow = 1, _mycol = 1 : ipiv[1] = 3
_myrow = 1, _mycol = 1 : ipiv[2] = 4
_myrow = 1, _mycol = 1 : ipiv[3] = 7
_myrow = 1, _mycol = 1 : ipiv[4] = 8
Here's the call I use it tp permute the matrix:
char direc = 'F';
char rowcol = 'C';
char pivroc = 'R';
pdlapiv_(&direc, &rowcol, &pivroc, &_m, &_n, _A, &one, &one, _desc_A, ipiv, &one, &one, desc_ipiv, iwork);
Here's the matrix before and after the permutation:
Before:
0.383 -0.649 -0.889 -0.738 -0.022 -0.229 -0.484 -0.369
-0.886 0.421 -0.325 -0.087 -0.058 -0.373 -0.111 -0.859
-0.894 -0.466 0.263 -0.419 -0.806 -0.094 -0.110 -0.890
-0.840 -0.548 -0.858 0.988 -0.801 -0.754 -0.663 -0.752
-0.793 -0.690 -0.390 -0.114 0.393 -0.784 -0.159 -0.970
-0.335 -0.059 -0.048 -0.759 -0.456 0.537 -0.930 -0.239
-0.645 -0.371 -0.932 -0.266 -0.084 -0.915 0.019 -0.459
-0.283 -0.809 -0.004 -0.707 -0.193 -0.452 -0.902 0.270
After:
0.383 -0.649 -0.484 -0.369 -0.889 -0.738 -0.022 -0.229
-0.886 0.421 -0.111 -0.859 -0.325 -0.087 -0.058 -0.373
-0.894 -0.466 -0.110 -0.890 0.263 -0.419 -0.806 -0.094
-0.840 -0.548 -0.663 -0.752 -0.858 0.988 -0.801 -0.754
-0.793 -0.690 -0.159 -0.970 -0.390 -0.114 0.393 -0.784
-0.335 -0.059 -0.930 -0.239 -0.048 -0.759 -0.456 0.537
-0.645 -0.371 0.019 -0.459 -0.932 -0.266 -0.084 -0.915
-0.283 -0.809 -0.902 0.270 -0.004 -0.707 -0.193 -0.452