### PZGESVD routine

Posted:

**Thu Dec 02, 2010 1:40 pm**Dear all I am using scalapack to perform a singular value decomposition on a big matrix

I compare the results from ScaLAPACK with the LAPACK code that I have and I see that when I use the PZGESVD routine for singular value decomposition the

routine gives the same singular values as the LAPACK routine ZGESVD but I obtain different left and right singular vectors U and VT.

Does any body experience a similar problem?

Here is the piece of code that I wrote

ESIZE = MIN( M, N )

allocate( S(ESIZE) )

LDA = NUMROC( M , MB , MYROW , 0 , NPROW )

LDA = max( 1, LDA )

LDU = LDA

LDVT = NUMROC( N , MB , MYROW , 0 , NPROW )

LDVT = max( 1, LDVT )

CALL DESCINIT( DESCA , M , N , MB , NB ,

& RSRC , CSRC , ICTXT , LDA , INFO )

CALL DESCINIT( DESCU , M , M , MB , NB ,

& RSRC , CSRC , ICTXT , LDU , INFO )

CALL DESCINIT( DESCVT , N , N , MB , NB ,

& RSRC , CSRC , ICTXT , LDVT , INFO )

A = M/NPROW + MB

B = N/NPROW + NB

allocate( A1(A,B) , A2(A,B) )

allocate( WORKA1( A + MB + 1 ) , WORKA2( A + MB + 1 ) )

A = M/NPROW + MB

B = M/NPROW + NB

allocate( U(A,B) )

allocate( WORKU( A + MB + 1 ) )

A = N/NPROW + MB

B = N/NPROW + NB

allocate( VT(A,B) )

allocate( WORKVT( A + MB + 1 ) )

CALL DASSIGN_MATRIX( A1 , A2 , M , N , DESCA ,

& 0 , 0 , WORKA1 , WORKA2 )

LWORK1 = -1

ALLOCATE( WORK(1) , RWORK(1) )

CALL PZGESVD( 'V' , 'V' , M , N , A1 , 1 , 1 , DESCA , S ,

& U , 1 , 1 , DESCU ,

& VT , 1 , 1 , DESCVT,

& WORK , LWORK1 , RWORK , INFO )

LWORK1 = INT(dble(WORK(1)))

LWORK2 = INT(dble(RWORK(1)))

DEALLOCATE( WORK , RWORK )

ALLOCATE( WORK(LWORK1) , RWORK(LWORK2) )

CALL PZGESVD( 'V' , 'V' , M , N , A1 , 1 , 1 , DESCA , S ,

& U , 1 , 1 , DESCU ,

& VT , 1 , 1 , DESCVT,

& WORK , LWORK1 , RWORK , INFO )

DEALLOCATE(WORK,RWORK)

I compare the results from ScaLAPACK with the LAPACK code that I have and I see that when I use the PZGESVD routine for singular value decomposition the

routine gives the same singular values as the LAPACK routine ZGESVD but I obtain different left and right singular vectors U and VT.

Does any body experience a similar problem?

Here is the piece of code that I wrote

ESIZE = MIN( M, N )

allocate( S(ESIZE) )

LDA = NUMROC( M , MB , MYROW , 0 , NPROW )

LDA = max( 1, LDA )

LDU = LDA

LDVT = NUMROC( N , MB , MYROW , 0 , NPROW )

LDVT = max( 1, LDVT )

CALL DESCINIT( DESCA , M , N , MB , NB ,

& RSRC , CSRC , ICTXT , LDA , INFO )

CALL DESCINIT( DESCU , M , M , MB , NB ,

& RSRC , CSRC , ICTXT , LDU , INFO )

CALL DESCINIT( DESCVT , N , N , MB , NB ,

& RSRC , CSRC , ICTXT , LDVT , INFO )

A = M/NPROW + MB

B = N/NPROW + NB

allocate( A1(A,B) , A2(A,B) )

allocate( WORKA1( A + MB + 1 ) , WORKA2( A + MB + 1 ) )

A = M/NPROW + MB

B = M/NPROW + NB

allocate( U(A,B) )

allocate( WORKU( A + MB + 1 ) )

A = N/NPROW + MB

B = N/NPROW + NB

allocate( VT(A,B) )

allocate( WORKVT( A + MB + 1 ) )

CALL DASSIGN_MATRIX( A1 , A2 , M , N , DESCA ,

& 0 , 0 , WORKA1 , WORKA2 )

LWORK1 = -1

ALLOCATE( WORK(1) , RWORK(1) )

CALL PZGESVD( 'V' , 'V' , M , N , A1 , 1 , 1 , DESCA , S ,

& U , 1 , 1 , DESCU ,

& VT , 1 , 1 , DESCVT,

& WORK , LWORK1 , RWORK , INFO )

LWORK1 = INT(dble(WORK(1)))

LWORK2 = INT(dble(RWORK(1)))

DEALLOCATE( WORK , RWORK )

ALLOCATE( WORK(LWORK1) , RWORK(LWORK2) )

CALL PZGESVD( 'V' , 'V' , M , N , A1 , 1 , 1 , DESCA , S ,

& U , 1 , 1 , DESCU ,

& VT , 1 , 1 , DESCVT,

& WORK , LWORK1 , RWORK , INFO )

DEALLOCATE(WORK,RWORK)