Routine to compute XY where X and Y are vectors author: Jack Dongarra, Linpack author: P J Knight, CCFE, Culham Science Centre n : input integer : order of the matrices sx, sy sx(nincx) : input real array : first vector incx : input integer : interval in storage between sx array elements sy(nincy) : input real array : second vector incy : input integer : interval in storage between sy array elements This routine performs the dot product of two vectors, i.e. calculates the sum from i=1 to N, of X(i)Y(i). !
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
real(kind=dp), | intent(in), | dimension(:) | :: | sx | ||
integer, | intent(in) | :: | incx | |||
real(kind=dp), | intent(in), | dimension(:) | :: | sy | ||
integer, | intent(in) | :: | incy |
function sdot(n,sx,incx,sy,incy)
!! Routine to compute X*Y where X and Y are vectors
!! author: Jack Dongarra, Linpack
!! author: P J Knight, CCFE, Culham Science Centre
!! n : input integer : order of the matrices sx, sy
!! sx(n*incx) : input real array : first vector
!! incx : input integer : interval in storage between sx array elements
!! sy(n*incy) : input real array : second vector
!! incy : input integer : interval in storage between sy array elements
!! This routine performs the dot product of two vectors, i.e.
!! calculates the sum from i=1 to N, of X(i)*Y(i).
!! !
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
real(dp) :: sdot
! Arguments
integer, intent(in) :: n,incx,incy
real(dp), dimension(:), intent(in) :: sx
real(dp), dimension(:), intent(in) :: sy
! Local variables
integer :: ix,i,iy
real(dp) :: sw
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sw = 0.0D0
ix = 1
iy = 1
do i = 1,n
sw = sw + (sx(ix) * sy(iy))
ix = ix + incx
iy = iy + incy
end do
sdot = sw
end function sdot