×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Fortran FAQ

LAPACK

 eigen vector by HRn4 faq214-8785 Posted: 15 Feb 24 Hi every one. I need o calculate eigen vector. i have this code but it just work foe 1 loop. when I re to apply it into a loop it does not give me correct answer. can you help me please? Program EigenVectors INTEGER:: nv, lda, ldvl, ldvr, lwork, lwmax, info INTEGER ::KK,LL,kL,NX,NY ! parameter(n = 2, lwmax = 1000) parameter(NX=3,NY=3,nv=2, lwmax = 1000) parameter(lda = nv, ldvl = nv, ldvr= nv) double precision :: A1(NX+2,NY+2,lda,nv),VL(NX+2,NY+2,ldvl,nv), VR(NX+2,NY+2,ldvl,nv), & WR(NX+2,NY+2,nv), WI(NX+2,NY+2,nv), work(lwmax),norm ! matrix A do KK = 1, NX+2 do LL = 1, NY+2 A1(KK,LL,1,:)=(/1.0d0, 0.0d0/) A1(KK,LL,2,:)=(/0.0d0, 1.0d0/) ! workspace query: calculates the optimal size of the WORK array lwork = -1 call DGEEV('Vectors', 'Vectors', nv, A1, lda, WR, WI, VL, LDVL, & VR, LDVR, work, lwork, info) ! compute workspace size lwork = min(lwmax, int(work(1))) write(*,*) 'lwork = ', lwork ! solve call DGEEV('Vectors', 'Vectors', nv, A1, lda, WR, WI, VL, LDVL, & VR, LDVR, work, lwork, info) write(*,*) 'info = ', info if (info .eq. 0) then write(*,*) 'Solution was succesfully computed:' ! Normalize eigenvectors ! do I = 1, NX+2 ! do J = 1, NY+2 do II = 1, 2 do JJ = 1, 2 norm = sqrt(VR(I,J,1,II)**2 + VR(I,J,2,JJ)**2) VR(I,J,1,II) = VR(I,J,1,II) / norm VR(I,J,2,JJ) = VR(I,J,2,JJ) / norm end do end do ! end do ! end do ! print the solution else write(*,*) '* Error computing solution!' end if ! end do ! end do ! Output eigenvalues write(*,*) 'Eigenvalues:' do II = 1, nv write(*,*) 'Eigenvalue ', II, ': ', WR(:,:, II), WI(:,:, II),WR(:,:, II), WI(:,:, II),VL(:,:, II), VR(:,:, II) end do End Program EigenVectors Back to Fortran FAQ Index Back to Fortran Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!