SymEigenValues
This function calculates eigenvalues of a symmetric matrix.
note
- For
n=2
it calls SymEigenValues2y2 - For
n=3
it calls SymEigenValues3by3 - For
n>=4
it callsSYEV
routine from Lapack95
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE FUNCTION SymEigenValues(mat) RESULT(ans)
REAL(DFP), INTENT(IN) :: mat(:, :)
!! for n=2, we call SymEigenValues2by2
!! for n=3, we call SymEigenValues3by3
!! for n>=4, we call Lapack or JacobiMethod
REAL(DFP) :: ans(SIZE(mat, 1))
END FUNCTION SymEigenValues
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])
!!
w = SymEigenValues(mat)
!!
exact = [-11.07, -6.23, 0.86, 8.87, 16.09]
!!
CALL OK( ALL(SOFTEQ(w, exact, tol)), "")
END PROGRAM main