scales a vector by a constant.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
real(kind=wp) | :: | da | ||||
real(kind=wp) | :: | dx(*) | ||||
integer | :: | incx |
subroutine dscal(n,da,dx,incx) real(wp) da integer incx,n real(wp) dx(*) 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