Return in b the adjoint of the 2x2 matrix a, together with the determinant of a. The inverse is defined as the adjoind divided by the determinant, so that inverse(a) = b/det
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | a(2,2) | |||
| real(kind=dp), | intent(out) | :: | b(2,2) | |||
| real(kind=dp), | intent(out) | :: | det |
subroutine utility_inv2(a, b, det) !================================================! ! !! Return in b the adjoint of the 2x2 matrix !! a, together with the determinant of a. !! The inverse is defined as the adjoind divided by the !! determinant, so that inverse(a) = b/det ! !================================================ implicit none real(kind=dp), intent(in) :: a(2, 2) real(kind=dp), intent(out) :: b(2, 2) real(kind=dp), intent(out) :: det det = a(1, 1)*a(2, 2) - a(1, 2)*a(2, 1) b(1, 1) = a(2, 2) b(1, 2) = -a(1, 2) b(2, 1) = -a(2, 1) b(2, 2) = a(1, 1) return end subroutine utility_inv2