dscal Subroutine

public subroutine dscal(n, da, dx, incx)

scales a vector by a constant. uses unrolled loops for increment 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(inout) :: dx(*)
integer, intent(in) :: incx

Called by

proc~~dscal~~CalledByGraph proc~dscal lbfgsb_blas_module::dscal proc~cauchy lbfgsb_module::cauchy proc~cauchy->proc~dscal proc~mainlb lbfgsb_module::mainlb proc~mainlb->proc~dscal proc~mainlb->proc~cauchy proc~subsm lbfgsb_module::subsm proc~mainlb->proc~subsm proc~subsm->proc~dscal proc~setulb lbfgsb_module::setulb proc~setulb->proc~mainlb

Source Code

    subroutine dscal(n,da,dx,incx)

      implicit none

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

      integer :: i , m , mp1 , nincx

      if ( n<=0 .or. incx<=0 ) return
      if ( incx==1 ) then

         ! code for increment equal to 1

         ! clean-up loop

         m = mod(n,5)
         if ( m/=0 ) then
            do i = 1 , m
               dx(i) = da*dx(i)
            end do
            if ( n<5 ) return
         end if
         mp1 = m + 1
         do i = mp1 , n , 5
            dx(i) = da*dx(i)
            dx(i+1) = da*dx(i+1)
            dx(i+2) = da*dx(i+2)
            dx(i+3) = da*dx(i+3)
            dx(i+4) = da*dx(i+4)
         end do
      else

         ! code for increment not equal to 1

         nincx = n*incx
         do i = 1 , nincx , incx
            dx(i) = da*dx(i)
         end do

      end if

      end subroutine dscal