I am trying to solve the following eigenvalue problem using lapack95:
program comp USE mkl95_lapack USE mkl95_PRECISION USE mkl95_BLAS implicit none real, dimension(2,2) :: A real, dimension(1) :: t real, dimension(2) :: c A = reshape((/-5., 2., 2., -2./),(/2,2/)) call sytrd(A, t) call orgtr(A, t) call rsteqr(c, t, A) write(*,*) c end program comp
But the results aren't correct. I only can deduce this implementation from the program's help for lapack95. What would be the correct way for doing this implementation?
链接已复制
When you use the "computational" routines in Lapack, you have greater control over the individual phases of the computation, but you also take on the responsibility to understand what each routine does and how to use them in the correct sequence. I do not know what your real objective is (beyond this simple 2 X 2 matrix example), but here is your program, corrected:
program comp USE lapack95 implicit none integer i real, dimension(2,2) :: A real, dimension(2) :: tau, d real, dimension(1) :: e A = reshape((/-5., 2., 2., -2./),(/2,2/)) call sytrd(A, tau) do i=1,2 d(i)=A(i,i) end do e(1)=A(1,2) call rsteqr(d, e) write(*,*) d end program comp
When run, it gives the eigenvalues as -1, -6, which I can check by hand.
Hi Babak,
If you'd like to try lapack driver function to Computes all eigenvalues and eigenvectors of a symmetric or Hermitian matrix
You may refer to the function list in setion of Symmetric Eigenproblems in mkl manual:
for example, you need eigenvalues only, it's more efficient to call sterf. If T is positive-definite, pteqr can compute small
eigenvalues more accurately than ?steqr.
To solve the problem by a single call, use one of the divide and conquer routines stevd, syevd, spevd, or
sbevd for real symmetric matrices or heevd, hpevd, or hbevd for complex Hermitian matrices.
Best Regards,
Ying