stdlib_caxpy Subroutine

public pure subroutine stdlib_caxpy(n, ca, cx, incx, cy, incy)

CAXPY constant times a vector plus a vector.

Arguments

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

Source Code

     pure subroutine stdlib_caxpy(n,ca,cx,incx,cy,incy)
     !! CAXPY constant times a vector plus a vector.
        ! -- 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 
           complex(sp), intent(in) :: ca
           integer(ilp), intent(in) :: incx, incy, n
           ! Array Arguments 
           complex(sp), intent(in) :: cx(*)
           complex(sp), intent(inout) :: cy(*)
        ! =====================================================================
           ! Local Scalars 
           integer(ilp) :: i, ix, iy
           if (n<=0) return
           if (stdlib_cabs1(ca)==0.0e+0_sp) return
           if (incx==1 .and. incy==1) then
              ! code for both increments equal to 1
              do i = 1,n
                 cy(i) = cy(i) + ca*cx(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
                 cy(iy) = cy(iy) + ca*cx(ix)
                 ix = ix + incx
                 iy = iy + incy
              end do
           end if
           return
     end subroutine stdlib_caxpy