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