dswap Subroutine

public subroutine dswap(n, dx, incx, dy, incy)

DSWAP interchanges two vectors. uses unrolled loops for increments equal to 1.

Arguments

Type IntentOptional Attributes Name
integer(kind=ip) :: n
real(kind=wp) :: dx(*)
integer(kind=ip) :: incx
real(kind=wp) :: dy(*)
integer(kind=ip) :: incy

Called by

proc~~dswap~~CalledByGraph proc~dswap bspline_blas_module::dswap proc~dh12 bspline_defc_module::dh12 proc~dh12->proc~dswap proc~dlsei bspline_defc_module::dlsei proc~dlsei->proc~dswap proc~dlsei->proc~dh12 proc~dlsi bspline_defc_module::dlsi proc~dlsei->proc~dlsi proc~dlsi->proc~dswap proc~dlsi->proc~dh12 proc~dhfti bspline_defc_module::dhfti proc~dlsi->proc~dhfti proc~dlpdp bspline_defc_module::dlpdp proc~dlsi->proc~dlpdp proc~dwnlit bspline_defc_module::dwnlit proc~dwnlit->proc~dswap proc~dwnlit->proc~dh12 proc~dwnlt3 bspline_defc_module::dwnlt3 proc~dwnlit->proc~dwnlt3 proc~dwnlsm bspline_defc_module::dwnlsm proc~dwnlsm->proc~dswap proc~dwnlsm->proc~dh12 proc~dwnlsm->proc~dwnlit proc~dwnlt3->proc~dswap proc~dbndac bspline_defc_module::dbndac proc~dbndac->proc~dh12 proc~dfcmn bspline_defc_module::dfcmn proc~dfcmn->proc~dlsei proc~dfcmn->proc~dbndac proc~dhfti->proc~dh12 proc~dwnnls bspline_defc_module::dwnnls proc~dwnnls->proc~dwnlsm proc~defcmn bspline_defc_module::defcmn proc~defcmn->proc~dbndac proc~dfc bspline_defc_module::dfc proc~dfc->proc~dfcmn proc~dlpdp->proc~dwnnls proc~defc bspline_defc_module::defc proc~defc->proc~defcmn

Source Code

   subroutine dswap(n, dx, incx, dy, incy)
         !! DSWAP interchanges two vectors.
         !! uses unrolled loops for increments equal to 1.

      integer(ip) :: incx, incy, n
      real(wp) :: dx(*), dy(*)

      real(wp) :: dtemp
      integer(ip) :: i, ix, iy, m, mp1

      if (n <= 0_ip) return
      if (incx == 1_ip .and. incy == 1_ip) then
         ! code for both increments equal to 1
         ! clean-up loop
         m = mod(n, 3_ip)
         if (m /= 0_ip) then
            do i = 1_ip, m
               dtemp = dx(i)
               dx(i) = dy(i)
               dy(i) = dtemp
            end do
            if (n < 3_ip) return
         end if
         mp1 = m + 1_ip
         do i = mp1, n, 3_ip
            dtemp = dx(i)
            dx(i) = dy(i)
            dy(i) = dtemp
            dtemp = dx(i + 1_ip)
            dx(i + 1_ip) = dy(i + 1_ip)
            dy(i + 1_ip) = dtemp
            dtemp = dx(i + 2_ip)
            dx(i + 2_ip) = dy(i + 2_ip)
            dy(i + 2_ip) = dtemp
         end do
      else
         ! code for unequal increments or equal increments not equal
         ! to 1
         ix = 1
         iy = 1
         if (incx < 0_ip) ix = (-n + 1_ip)*incx + 1_ip
         if (incy < 0_ip) iy = (-n + 1_ip)*incy + 1_ip
         do i = 1_ip, n
            dtemp = dx(ix)
            dx(ix) = dy(iy)
            dy(iy) = dtemp
            ix = ix + incx
            iy = iy + incy
         end do
      end if

   end subroutine dswap