ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/nano_mpi/src/vectors.F90
Revision: 4
Committed: Mon Jun 10 17:18:36 2002 UTC (22 years, 1 month ago) by chuckv
File size: 1111 byte(s)
Log Message:
Import Root

File Contents

# Content
1 module vectors
2 use definitions, ONLY : DP
3 implicit none
4 PRIVATE
5
6 public :: cross_product
7 public :: determinant
8
9
10
11 contains
12
13 function cross_product(a,b) result(cross)
14 real ( kind = dp ), dimension(3) :: cross
15 real ( kind = dp ), dimension(:) :: a
16 real ( kind = dp ), dimension(:) :: b
17 integer :: component, i,j
18
19 do component = 1,3
20 i = modulo(component,3) + 1
21 j = modulo(i,3) + 1
22 cross(component) = a(i)*b(j) - b(i)*a(j)
23 end do
24
25
26 end function cross_product
27
28
29
30
31 function determinant(this_matrix) result(det)
32 real( kind = DP ), dimension(3,3) :: this_matrix
33 real( kind = DP ) :: a11,a12,a13
34 real( kind = DP ) :: det
35
36 a11 = this_matrix(1,1) * (this_matrix(2,2)*this_matrix(3,3) &
37 - this_matrix(2,3)*this_matrix(3,2))
38 a12 = this_matrix(2,1) * (this_matrix(1,3)*this_matrix(3,2) &
39 - this_matrix(1,2)*this_matrix(3,3))
40 a13 = this_matrix(3,1) * (this_matrix(1,2)*this_matrix(2,3) &
41 - this_matrix(1,3)*this_matrix(2,2))
42
43 det = a11 + a12 + a12
44
45 end function determinant
46
47
48 end module vectors