sdot Function

public pure function sdot(n, sx, incx, sy, incy)

NAME

sdot(3f) - [BLAS:SINGLE_BLAS_LEVEL1] SDOT := SUM SX * SY (vector dot product)

SYNOPSIS

 real function sdot(n,sx,incx,sy,incy)

   .. Scalar Arguments ..
   integer,intent(in) :: incx,incy,n
   ..
   .. Array Arguments ..
   real,intent(in) :: sx(*),sy(*)
   ..

DEFINITION

 SDOT forms the dot product of two vectors.
 uses unrolled loops for increments equal to one.

OPTIONS

N

       N is INTEGER
      number of elements in input vector(s)

SX

       SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )

INCX

       INCX is INTEGER
      storage spacing between elements of SX

SY

       SY is REAL array, dimension ( 1 + ( N - 1 )*abs( INCY ) )

INCY

       INCY is INTEGER
      storage spacing between elements of SY

AUTHORS

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

date:November 2017

FURTHER DETAILS

  jack dongarra, linpack, 3/11/78.
  modified 12/3/93, array(1) declarations changed to array(*)

SEE ALSO

Online html documentation available at
http://www.netlib.org/lapack/explore-html/

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real, intent(in) :: sx(*)
integer, intent(in) :: incx
real, intent(in) :: sy(*)
integer, intent(in) :: incy

Return Value real


Contents

Source Code


Variables

Type Visibility Attributes Name Initial
integer, public :: i
integer, public :: ix
integer, public :: iy
integer, public :: m
integer, public :: mp1
real, public :: stemp

Source Code

pure real function sdot(n,sx,incx,sy,incy)
implicit none
!
!  -- Reference BLAS level1 routine (version 3.8.0) --
!  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
!  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
!     November 2017
!
!     .. Scalar Arguments ..
      integer,intent(in) :: incx,incy,n
!     ..
!     .. Array Arguments ..
      real,intent(in) :: sx(*),sy(*)
!     ..
!
!  =====================================================================
!
!     .. Local Scalars ..
      real stemp
      integer i,ix,iy,m,mp1
!     ..
!     .. Intrinsic Functions ..
      intrinsic mod
!     ..
      stemp = 0.0e0
      sdot = 0.0e0
      if (n.le.0) return
      if (incx.eq.1 .and. incy.eq.1) then
!
!        code for both increments equal to 1
!
!
!        clean-up loop
!
         m = mod(n,5)
         if (m.ne.0) then
            do i = 1,m
               stemp = stemp + sx(i)*sy(i)
            enddo
            if (n.lt.5) then
               sdot=stemp
            return
            endif
         endif
         mp1 = m + 1
         do i = mp1,n,5
          stemp = stemp + sx(i)*sy(i) + sx(i+1)*sy(i+1) + sx(i+2)*sy(i+2) + sx(i+3)*sy(i+3) + sx(i+4)*sy(i+4)
         enddo
      else
!
!        code for unequal increments or equal increments
!          not equal to 1
!
         ix = 1
         iy = 1
         if (incx.lt.0) ix = (-n+1)*incx + 1
         if (incy.lt.0) iy = (-n+1)*incy + 1
         do i = 1,n
            stemp = stemp + sx(ix)*sy(iy)
            ix = ix + incx
            iy = iy + incy
         enddo
      endif
      sdot = stemp

end function sdot