The Elk Code
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:
9 subroutine 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
20 implicit none
21 ! arguments
22 integer, intent(in) :: a(3,3)
23 integer, intent(out) :: b(3,3)
24 ! local variables
25 integer m
26 m=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))
29 if ((m /= 1).and.(m /= -1)) then
30  write(*,*)
31  write(*,'("Error(i3minv): cannot invert matrix")')
32  write(*,'(" Determinant : ",I8)') m
33  write(*,*)
34  stop
35 end if
36 b(1,1)=m*(a(2,2)*a(3,3)-a(2,3)*a(3,2))
37 b(2,1)=m*(a(2,3)*a(3,1)-a(2,1)*a(3,3))
38 b(3,1)=m*(a(2,1)*a(3,2)-a(2,2)*a(3,1))
39 b(1,2)=m*(a(1,3)*a(3,2)-a(1,2)*a(3,3))
40 b(2,2)=m*(a(1,1)*a(3,3)-a(1,3)*a(3,1))
41 b(3,2)=m*(a(1,2)*a(3,1)-a(1,1)*a(3,2))
42 b(1,3)=m*(a(1,2)*a(2,3)-a(1,3)*a(2,2))
43 b(2,3)=m*(a(1,3)*a(2,1)-a(1,1)*a(2,3))
44 b(3,3)=m*(a(1,1)*a(2,2)-a(1,2)*a(2,1))
45 end subroutine
46 !EOC
47 
subroutine i3minv(a, b)
Definition: i3minv.f90:10