-
Notifications
You must be signed in to change notification settings - Fork 11
/
MODULE_MATHUTILITY.f90
30 lines (26 loc) · 1.23 KB
/
MODULE_MATHUTILITY.f90
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
26
27
28
29
30
!=================================================================================================
!> CARTESIAN ADAPTIVE FIVE EQUATION MODEL
!> AUTHOR: VAN-DAT THANG
!> E-MAIL: [email protected]
!> E-MAIL: [email protected]
!> SOURCE CODE LINK: https://github.com/dattv/2D_CARFIVE
!=================================================================================================
MODULE MODULE_MATHUTILITY
use MODULE_PRECISION
contains
!==================================================================================================
!==>COMPUTE INVERSE MATRIX OF 2X2 MATRIX<==========================================================
function inv(A) result(res)
implicit none
! in/out variables
real(rp), dimensiON(2,2), intent(in) :: A
real(rp), dimension(2,2) :: res
! body
res(1,1) = A(2,2)/(A(1,1)*A(2,2) - A(1,2)*A(2,1))
res(1,2) = -A(1,2)/(A(1,1)*A(2,2) - A(1,2)*A(2,1))
res(2,1) = -A(2,1)/(A(1,1)*A(2,2) - A(1,2)*A(2,1))
res(2,2) = A(1,1)/(A(1,1)*A(2,2) - A(1,2)*A(2,1))
return
end function inv
!==================================================================================================
END MODULE MODULE_MATHUTILITY