stdlib_cdotc Function

public pure function stdlib_cdotc(n, cx, incx, cy, incy)

CDOTC forms the dot product of two complex vectors CDOTC = X^H * Y

Arguments

Type IntentOptional Attributes Name
integer(kind=ilp), intent(in) :: n
complex(kind=sp), intent(in) :: cx(*)
integer(kind=ilp), intent(in) :: incx
complex(kind=sp), intent(in) :: cy(*)
integer(kind=ilp), intent(in) :: incy

Return Value complex(kind=sp)


Source Code

     pure complex(sp) function stdlib_cdotc(n,cx,incx,cy,incy)
     !! CDOTC forms the dot product of two complex vectors
     !! CDOTC = X^H * Y
        ! -- reference blas level1 routine --
        ! -- reference blas is a software package provided by univ. of tennessee,    --
        ! -- univ. of california berkeley, univ. of colorado denver and nag ltd..--
           ! Scalar Arguments 
           integer(ilp), intent(in) :: incx, incy, n
           ! Array Arguments 
           complex(sp), intent(in) :: cx(*), cy(*)
        ! =====================================================================
           ! Local Scalars 
           complex(sp) :: ctemp
           integer(ilp) :: i, ix, iy
           ! Intrinsic Functions 
           intrinsic :: conjg
           ctemp = (0.0_sp,0.0_sp)
           stdlib_cdotc = (0.0_sp,0.0_sp)
           if (n<=0) return
           if (incx==1 .and. incy==1) then
              ! code for both increments equal to 1
              do i = 1,n
                 ctemp = ctemp + conjg(cx(i))*cy(i)
              end do
           else
              ! code for unequal increments or equal increments
                ! not equal to 1
              ix = 1
              iy = 1
              if (incx<0) ix = (-n+1)*incx + 1
              if (incy<0) iy = (-n+1)*incy + 1
              do i = 1,n
                 ctemp = ctemp + conjg(cx(ix))*cy(iy)
                 ix = ix + incx
                 iy = iy + incy
              end do
           end if
           stdlib_cdotc = ctemp
           return
     end function stdlib_cdotc