cross Function

public function cross(a, b) result(result)

function that calculates the cross product between two real 3-dimensional vectors and 1


  1. the wedge notation can sometimes be used to denote the vector product. 

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in), dimension(3) :: a
real(kind=dp), intent(in), dimension(3) :: b

Return Value real(kind=dp), dimension(3)


Source Code

    function cross(a, b) result(result)

        real(dp), dimension(3), intent(in) :: a, b
        real(dp), dimension(3) :: result

        result(1) = a(2) * b(3) - b(2) * a(3)
        result(2) = -(a(1) * b(3) - b(1) * a(3))
        result(3) = a(1) * b(2) - b(1) * a(2)

    end function cross