daxpy Subroutine

public subroutine daxpy(n, da, dx, incx, dy, incy)

constant times a vector plus a vector. uses unrolled loops for increments equal to one.

Author

jack dongarra, linpack, 3/11/78.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real(kind=wp), intent(in) :: da
real(kind=wp), intent(in) :: dx(*)
integer, intent(in) :: incx
real(kind=wp), intent(inout) :: dy(*)
integer, intent(in) :: incy

Called by

proc~~daxpy~~CalledByGraph proc~daxpy lbfgsb_blas_module::daxpy proc~cauchy lbfgsb_module::cauchy proc~cauchy->proc~daxpy proc~bmv lbfgsb_module::bmv proc~cauchy->proc~bmv proc~dtrsl lbfgsb_linpack_module::dtrsl proc~dtrsl->proc~daxpy proc~bmv->proc~dtrsl proc~formk lbfgsb_module::formk proc~formk->proc~dtrsl proc~mainlb lbfgsb_module::mainlb proc~mainlb->proc~cauchy proc~mainlb->proc~formk proc~subsm lbfgsb_module::subsm proc~mainlb->proc~subsm proc~cmprlb lbfgsb_module::cmprlb proc~mainlb->proc~cmprlb proc~subsm->proc~dtrsl proc~cmprlb->proc~bmv proc~setulb lbfgsb_module::setulb proc~setulb->proc~mainlb

Source Code

      subroutine daxpy(n,da,dx,incx,dy,incy)
      implicit none

      integer,intent(in) :: n
      real(wp),intent(in) :: da
      real(wp),intent(in)  :: dx(*)
      integer,intent(in)  :: incx
      real(wp),intent(inout) :: dy(*)
      integer,intent(in)  :: incy

      integer :: i , ix , iy , m , mp1

      if ( n<=0 ) return
      if ( da==zero ) return
      if ( incx==1 .and. incy==1 ) then

        ! code for both increments equal to 1

        ! clean-up loop

         m = mod(n,4)
         if ( m/=0 ) then
            do i = 1 , m
               dy(i) = dy(i) + da*dx(i)
            end do
            if ( n<4 ) return
         end if
         mp1 = m + 1
         do i = mp1 , n , 4
            dy(i) = dy(i) + da*dx(i)
            dy(i+1) = dy(i+1) + da*dx(i+1)
            dy(i+2) = dy(i+2) + da*dx(i+2)
            dy(i+3) = dy(i+3) + da*dx(i+3)
         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
            dy(iy) = dy(iy) + da*dx(ix)
            ix = ix + incx
            iy = iy + incy
         end do

      end if

      end subroutine daxpy