SBGVX computes a few eigenvalues/eigenvectors of a real symmetric matrix so it should be very useful for FEA where we want only a few eigenvalues/vectors of a very large matrix. So, I implemented a test example following the documentations but I cannot get it to work. I get an access violation.
Does anyone has a working example using this routine?
Here is mine:
program Console1
implicit none
! Variables
! http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/index.htm#GUID-659297EE-D35B-428C-ABBE-1A7EBE2B0F6E.htm#GUID-659297EE-D35B-428C-ABBE-1A7EBE2B0F6E
!
! N: matrix size
! NJ: number of upper diagonals + 1
integer, parameter :: N=3, NJ=2, ku=NJ-1, kl=0, ldab=ku+1, iwork=7*N
!compute eigenvalues with index il to iu included
integer, parameter :: il=1, iu=2, ldz=N, ldq=N
integer info, m
integer, dimension (N) :: ifail
doubleprecision, dimension (N,N) :: KG, KM
doubleprecision, dimension (ldab,N) :: KGB, KMB
doubleprecision, dimension (N) :: W !eigenvalues
doubleprecision, dimension (N,N) :: q, z
doubleprecision vl, vu !not referenced if range="I"
doubleprecision, parameter :: abstol=0.0D-3 !absolute error tolerance for eigenvalues
doubleprecision, dimension (iwork) :: work
character*1, parameter :: jobz="V" !compute eigenvalues
character*1, parameter :: range="I" !compute in interval il--iu
character*1, parameter :: uplo="U" !upper triangular symmetric
!local
integer i,j
m = iu-il+1
!test matrix
KG = 0
KM = 0
KG(1,1) = 100
KG(2,2) = 100
KG(1,2) = 25
KG(2,1) = 25
do i=1,N
KM(i,i) = 1
enddo
print *, "KG"
write(*,"(3G9.3)") ((KG(i,j),j=1,N),i=1,N)
!copy to band form using
!http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/index.htm#GUID-659297EE-D35B-428C-ABBE-1A7EBE2B0F6E.htm#GUID-659297EE-D35B-428C-ABBE-1A7EBE2B0F6E
KGB = 0
KMB = 0
do i=1,N
do j=1,N
if (i.ge.max(1,j-ku).and.i.le.min(N,j+kl)) KGB(ku+1+i-j,j) = KG(i,j)
if (i.ge.max(1,j-ku).and.i.le.min(N,j+kl)) KMB(ku+1+i-j,j) = KM(i,j)
enddo
enddo
print *, "KGB"
write(*,"(3G9.3)") ((KGB(i,j),j=1,N),i=1,ku+1)
print *, "KGM"
write(*,"(3G9.3)") ((KMB(i,j),j=1,N),i=1,ku+1)
!call sbgvx(KGB, KMB, w)
! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
call dsbgvx(jobz, range, uplo, N, ku, ku, KGB, ldab, KMB, ldab, q, ldq, vl, vu, il, iu, abstol, m, w, z, ldz, work, iwork, ifail, info)
print *, "Eigenvalues found=",m
print *, "Eigenvalues. Info=",info
write(*,*) W
pause "Hit ENTER to continue"
end program Console1