GetSymEigenValues
This subroutine calculates eigenvalues of a symmetric matrix.
- For
n=2
it calls SymEigenValues2y2 - For
n=3
it calls SymEigenValues3by3 - For
n>=4
it callsSYEV
routine from Lapack95
note
In this routine a copy of matrix mat
is formed and passed to Lapack library. If you do not want to save mat
then please call GetSymEigenValues_
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE SUBROUTINE GetSymEigenValues(mat, eigenValues)
REAL(DFP), INTENT(IN) :: mat(:, :)
REAL(DFP), INTENT(OUT) :: eigenValues(:)
END SUBROUTINE GetSymEigenValues
END INTERFACE
PROGRAM main
USE easifemBase
REAL( DFP ), ALLOCATABLE :: mat(:,:), w(:), exact(:)
REAL( DFP ), PARAMETER :: tol= 1.0E-2
mat =RESHAPE( &
[ 1.96, -6.49, -0.47, -7.20, -0.65, &
& -6.49, 3.80, -6.39, 1.50, -6.34, &
& -0.47,-6.39, 4.17, -1.51, 2.67, &
& -7.20, 1.50,-1.51, 5.70, 1.80, &
& -0.65,-6.34, 2.67, 1.80,-7.10 &
], [5,5])
!!
CALL Reallocate(w, SIZE(mat,1))
CALL GetSymEigenValues(mat=mat, eigenValues=w)
!!
exact = [-11.07, -6.23, 0.86, 8.87, 16.09]
!!
CALL OK( ALL(SOFTEQ(w, exact, tol)), "")
END PROGRAM main