| 1 |
module linearAlgebra |
| 2 |
|
| 3 |
use definitions |
| 4 |
implicit none |
| 5 |
|
| 6 |
CONTAINS |
| 7 |
|
| 8 |
function cross_product(vec1,vec2) |
| 9 |
|
| 10 |
real(kind=dp), dimension(3) :: cross_product |
| 11 |
real(kind=dp), dimension(3),intent(in) :: vec1, vec2 |
| 12 |
|
| 13 |
cross_product(1) = vec1(2) * vec2(3) - vec1(3) * vec2(2) |
| 14 |
cross_product(2) = vec1(3) * vec2(1) - vec1(1) * vec2(3) |
| 15 |
cross_product(3) = vec1(1) * vec2(2) - vec1(2) * vec2(1) |
| 16 |
|
| 17 |
end function cross_product |
| 18 |
|
| 19 |
function length(vec1) |
| 20 |
|
| 21 |
real(kind=dp) :: length |
| 22 |
real(kind=dp), dimension(3),intent(in) :: vec1 |
| 23 |
|
| 24 |
length = sqrt(dot_product(vec1, vec1)) |
| 25 |
end function length |
| 26 |
|
| 27 |
end module linearAlgebra |