The Elk Code
 
Loading...
Searching...
No Matches
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:
9subroutine 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
20implicit none
21! arguments
22real(8), intent(in) :: a(3,3)
23real(8), intent(out) :: b(3,3)
24! local variables
25real(8) t1
26t1=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)
28if (abs(t1) < 1.d-40) then
29 write(*,*)
30 write(*,'("Error(r3minv): singular matrix")')
31 write(*,*)
32 stop
33end if
34t1=1.d0/t1
35b(1,1)=t1*(a(2,2)*a(3,3)-a(2,3)*a(3,2))
36b(2,1)=t1*(a(2,3)*a(3,1)-a(2,1)*a(3,3))
37b(3,1)=t1*(a(2,1)*a(3,2)-a(2,2)*a(3,1))
38b(1,2)=t1*(a(1,3)*a(3,2)-a(1,2)*a(3,3))
39b(2,2)=t1*(a(1,1)*a(3,3)-a(1,3)*a(3,1))
40b(3,2)=t1*(a(1,2)*a(3,1)-a(1,1)*a(3,2))
41b(1,3)=t1*(a(1,2)*a(2,3)-a(1,3)*a(2,2))
42b(2,3)=t1*(a(1,3)*a(2,1)-a(1,1)*a(2,3))
43b(3,3)=t1*(a(1,1)*a(2,2)-a(1,2)*a(2,1))
44end subroutine
45!EOC
46
subroutine r3minv(a, b)
Definition r3minv.f90:10