The Elk Code
r3minv.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2005 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: r3minv
8 ! !INTERFACE:
9 subroutine r3minv(a,b)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! a : input matrix (in,real(3,3))
12 ! b : output matrix (out,real(3,3))
13 ! !DESCRIPTION:
14 ! Computes the inverse of a real $3\times 3$ matrix.
15 !
16 ! !REVISION HISTORY:
17 ! Created April 2003 (JKD)
18 !EOP
19 !BOC
20 implicit none
21 ! arguments
22 real(8), intent(in) :: a(3,3)
23 real(8), intent(out) :: b(3,3)
24 ! local variables
25 real(8) t1
26 t1=a(1,2)*a(2,3)*a(3,1)-a(1,3)*a(2,2)*a(3,1)+a(1,3)*a(2,1)*a(3,2) &
27  -a(1,1)*a(2,3)*a(3,2)+a(1,1)*a(2,2)*a(3,3)-a(1,2)*a(2,1)*a(3,3)
28 if (abs(t1) < 1.d-40) then
29  write(*,*)
30  write(*,'("Error(r3minv): singular matrix")')
31  write(*,*)
32  stop
33 end if
34 t1=1.d0/t1
35 b(1,1)=t1*(a(2,2)*a(3,3)-a(2,3)*a(3,2))
36 b(2,1)=t1*(a(2,3)*a(3,1)-a(2,1)*a(3,3))
37 b(3,1)=t1*(a(2,1)*a(3,2)-a(2,2)*a(3,1))
38 b(1,2)=t1*(a(1,3)*a(3,2)-a(1,2)*a(3,3))
39 b(2,2)=t1*(a(1,1)*a(3,3)-a(1,3)*a(3,1))
40 b(3,2)=t1*(a(1,2)*a(3,1)-a(1,1)*a(3,2))
41 b(1,3)=t1*(a(1,2)*a(2,3)-a(1,3)*a(2,2))
42 b(2,3)=t1*(a(1,3)*a(2,1)-a(1,1)*a(2,3))
43 b(3,3)=t1*(a(1,1)*a(2,2)-a(1,2)*a(2,1))
44 end subroutine
45 !EOC
46 
subroutine r3minv(a, b)
Definition: r3minv.f90:10