The Elk Code
 
Loading...
Searching...
No Matches
i3minv.f90
Go to the documentation of this file.
1
2! Copyright (C) 2003-2007 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3! This file is distributed under the terms of the GNU Lesser General Public
4! License. See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: i3minv
8! !INTERFACE:
9subroutine i3minv(a,b)
10! !INPUT/OUTPUT PARAMETERS:
11! a : input matrix (in,integer(3,3))
12! b : output matrix (in,integer(3,3))
13! !DESCRIPTION:
14! Computes the inverse of a integer $3\times 3$ matrix: $B=A^{-1}$.
15!
16! !REVISION HISTORY:
17! Created November 2003 (JKD)
18!EOP
19!BOC
20implicit none
21! arguments
22integer, intent(in) :: a(3,3)
23integer, intent(out) :: b(3,3)
24! local variables
25integer m
26m=a(1,1)*(a(2,2)*a(3,3)-a(3,2)*a(2,3)) &
27 +a(2,1)*(a(3,2)*a(1,3)-a(1,2)*a(3,3)) &
28 +a(3,1)*(a(1,2)*a(2,3)-a(2,2)*a(1,3))
29if ((m /= 1).and.(m /= -1)) then
30 write(*,*)
31 write(*,'("Error(i3minv): cannot invert matrix")')
32 write(*,'(" Determinant : ",I8)') m
33 write(*,*)
34 stop
35end if
36b(1,1)=m*(a(2,2)*a(3,3)-a(2,3)*a(3,2))
37b(2,1)=m*(a(2,3)*a(3,1)-a(2,1)*a(3,3))
38b(3,1)=m*(a(2,1)*a(3,2)-a(2,2)*a(3,1))
39b(1,2)=m*(a(1,3)*a(3,2)-a(1,2)*a(3,3))
40b(2,2)=m*(a(1,1)*a(3,3)-a(1,3)*a(3,1))
41b(3,2)=m*(a(1,2)*a(3,1)-a(1,1)*a(3,2))
42b(1,3)=m*(a(1,2)*a(2,3)-a(1,3)*a(2,2))
43b(2,3)=m*(a(1,3)*a(2,1)-a(1,1)*a(2,3))
44b(3,3)=m*(a(1,1)*a(2,2)-a(1,2)*a(2,1))
45end subroutine
46!EOC
47
subroutine i3minv(a, b)
Definition i3minv.f90:10