SymEigenValues2by2
Calculate the eigenvalues of 2 by 2 matrix.
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION SymEigenValues2by2(mat) RESULT(ans)
REAL(DFP), INTENT(IN) :: mat(2, 2)
REAL(DFP) :: ans(2)
END FUNCTION SymEigenValues2by2
END INTERFACE
PROGRAM main
USE easifemBase
REAL( DFP ) :: mat(2,2), w(2), e, exact(2)
REAL( DFP ), PARAMETER :: tol= 1.0E-12
Test 1
e = 0.5
exact = [1.0_DFP - e, 1.0_DFP + 4.0_DFP*e]
mat(1,1) = 1+3*e
mat(1,2) = 2*e
mat(2,1) = 2*e
mat(2,2) = 1
!!
w = SymEigenValues2by2(mat)
!!
CALL OK( ALL(SOFTEQ(w, exact, tol)), "e = "//tostring(e))
Test 2
e = 0.01
exact = [1.0_DFP - e, 1.0_DFP + 4.0_DFP*e]
mat(1,1) = 1+3*e
mat(1,2) = 2*e
mat(2,1) = 2*e
mat(2,2) = 1
!!
w = SymEigenValues2by2(mat)
!!
CALL OK( ALL(SOFTEQ(w, exact, tol)), "e = "//tostring(e))
END PROGRAM main