Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

solving eigenvalue problem

BABAK
初学者
1,888 次查看

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?

0 项奖励
3 回复数
mecej4
名誉分销商 III
1,888 次查看

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.

0 项奖励
Ying_H_Intel
主持人
1,888 次查看

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 

0 项奖励
BABAK
初学者
1,888 次查看

Hi Mecej4, 

How can I now compute the eigenvectors? I use the subroutine "call rsteqr(d,e,z)" with z as a (n,n) matrix, but the results are not correct.

0 项奖励
回复