scales a vector by a constant. uses unrolled loops for increment equal to one.
jack dongarra, linpack, 3/11/78.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
real(kind=wp), | intent(in) | :: | da | |||
real(kind=wp), | intent(inout) | :: | dx(*) | |||
integer, | intent(in) | :: | incx |
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