fortran - Matrix reconstruction after SVD decomposition -


i having strange results when verifying svd decomposition lapack. routines robust believe bug on side. highly appreciated. matrix pentadiagonal, size n*n , code looks :

! compute real bi-diag complex pentadiag call zgbbrd('b', n, n, 0, 2, 2, ab, 5, &         d, e, q, n, pt, n, dummy_argc, 1, work, rwork, info) if (info.ne.0)   print *,'call *gbbrd failed, info : ',info   call exit(0) endif  ! compute diagonal matrix bi-diagonal 1 call dbdsdc('u', 'i', n, d, e, u, n, vt, n, &             dummy_argr, 1, work_big, iwork, info) if (info.ne.0)   print *,'call *bdsdc failed, info : ',info   call exit(0) endif  print *,'singular values min/max : ',minval(d),maxval(d)  ii=1,n jj=1,n   tmpqu(ii,jj)=0.   kk=1,n     tmpqu(ii,jj)=tmpqu(ii,jj)+q(ii,kk)*u(kk,jj) ! q*u   enddo enddo enddo ii=1,n jj=1,n   tmpqu(ii,jj)=tmpqu(ii,jj)*d(jj) ! q*u*sigma enddo enddo ii=1,n jj=1,n   tmptot(ii,jj)=0.   kk=1,n     tmptot(ii,jj) = tmptot(ii,jj) + & ! q*u*sigma*vt          tmpqu(ii,kk)*vt(kk,jj)   enddo enddo enddo tmpqu=tmptot ii=1,n jj=1,n   tmptot(ii,jj)=0.   kk=1,n     tmptot(ii,jj) = tmptot(ii,jj) + & ! q*u*sigma*vt*p          tmpqu(ii,kk)*pt(kk,jj)   enddo enddo enddo  tmpa=0. ii=1,n   tmpa(ii,ii)=ab(3,ii) ! diag enddo ii=2,n   tmpa(ii-1,ii)=ab(2,ii) ! diag+1 enddo ii=3,n   tmpa(ii-2,ii)=ab(1,ii) ! diag+2 enddo ii=1,n-1   tmpa(ii+1,ii)=ab(4,ii) ! diag-1 enddo ii=1,n-2   tmpa(ii+2,ii)=ab(5,ii) ! diag-2 enddo  print *, 'maxabs delta',maxval(abs(tmptot-tmpa)), maxloc(abs(tmptot-tmpa)) 

edit : add variable declaration :

! local variables integer :: i,j,k integer :: info, info2, code ! pentadiagonale bi-diagonale complex(mytype), dimension(5,n) :: ab !  matrice pentadiagonale real(mytype), dimension(n) :: d ! diagonale matrice bidiagonale real(mytype), dimension(n-1) :: e !  diag+1 matrice bidiagonale complex(mytype), dimension(n,n) :: q  ! unitary matrix q complex(mytype), dimension(n,n) :: pt ! unitary matrix p' complex(mytype) :: dummy_argc complex(mytype), dimension(n) :: work real(mytype), dimension(n) :: rwork ! bi-diagonale svd real(mytype), dimension(n,n) :: u  ! left singular vectors real(mytype), dimension(n,n) :: vt ! right singular vectors real(mytype) :: dummy_argr real(mytype), dimension(3*n*n+4*n) :: work_big integer, dimension(8*n) :: iwork ! temp verif sigma integer :: ii,jj,kk complex(mytype), dimension(n,n) :: tmpa, tmpqu, tmptot 

thanks

the routine zgbbrd modify input array ab. should saved in array before calling routine. looks works using precaution. thanks.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -