## Problem using pdlapiv

Post here if you have a question about LAPACK or ScaLAPACK algorithm or data format

### Problem using pdlapiv

I'm new to scalapack and have a question about using routine PDLAPIV to apply a permutation matrix. I must be misunderstanding something because when I try to apply an identity permutation I get something other than the identity so I suspect I'm not constructing the permutation
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
_myrow = 0, _mycol = 0 : ipiv = 2
_myrow = 0, _mycol = 0 : ipiv = 5
_myrow = 0, _mycol = 0 : ipiv = 6

_myrow = 0, _mycol = 1 : ipiv = 3
_myrow = 0, _mycol = 1 : ipiv = 4
_myrow = 0, _mycol = 1 : ipiv = 7
_myrow = 0, _mycol = 1 : ipiv = 8

_myrow = 1, _mycol = 0 : ipiv = 1
_myrow = 1, _mycol = 0 : ipiv = 2
_myrow = 1, _mycol = 0 : ipiv = 5
_myrow = 1, _mycol = 0 : ipiv = 6

_myrow = 1, _mycol = 1 : ipiv = 3
_myrow = 1, _mycol = 1 : ipiv = 4
_myrow = 1, _mycol = 1 : ipiv = 7
_myrow = 1, _mycol = 1 : ipiv = 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
pcollins

Posts: 2
Joined: Mon Jun 09, 2014 10:57 am

### Re: Problem using pdlapiv

I have looked through pdlapiv.f and pdlapv2.f in an attempt to understand my problem and it appears to me that IPVWRK is set wrong. I hesitate to say that because I may not be understaning things correctly. For example, starting at line 246 in pdlapv2.f IPVWRK is set as:

Code: Select all
`            IPVWRK = NUMROC( DESCIP( N_ ), DESCIP( NB_ ), MYCOL,     \$                       DESCIP( CSRC_ ), NPCOL ) + 1 -      \$                       DESCIP( NB_ )`

I believe it should be:

Code: Select all
`           IPVWRK = NUMROC( DESCIP( N_ ), DESCIP( NB_ ), MYCOL,     \$                       DESCIP( CSRC_ ), NPCOL ) + 1 `

With the smaller IPVWRK broadcasting the pivot information seems to overwrite information that it shouldn't. If I make this change my problem goes away.
pcollins

Posts: 2
Joined: Mon Jun 09, 2014 10:57 am