dot Function

public function dot(x, y) result(prod)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x(:)
real(kind=real64), intent(in) :: y(:)

Return Value real(kind=real64)


Source Code

    function dot(x, y) result(prod)
        real(real64), intent(in) :: x(:)
        real(real64), intent(in) :: y(:)
        real(real64) :: prod

        ! 配列のサイズが異なる場合はエラーとして停止
        if (size(x) /= size(y)) then
            write (*, '(A)') "Error: dot - array sizes do not match."
            error stop 1
        end if

#ifdef _MKL
        prod = ddot(int(size(x), int32), x, 1, y, 1)
#else
        ! 手動ループやOpenMPよりも、dot_product組込み関数が推奨される
        prod = dot_product(x, y)
#endif
    end function dot