dot Function

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

function that calculates the dot product of two real 3-dimensional vectors and

Arguments

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

Return Value real(kind=dp)


Source Code

    function dot(a, b) result(result)
        real(dp), dimension(:), intent(in) :: a, b
        real(dp) :: result
        integer :: i

        if (size(a) /= size(b)) stop "Error: Vectors must be of the same size."

        result = 0.0_dp
        do i = 1, size(a)
            result = result + a(i) * b(i)
        end do

    end function dot