|
|
@ -137,6 +137,584 @@ subroutine psb_cqsort(x,ix,dir,flag)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end subroutine psb_cqsort
|
|
|
|
end subroutine psb_cqsort
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Init stack pointer
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
istp = 1
|
|
|
|
|
|
|
|
istack(1,istp) = 1
|
|
|
|
|
|
|
|
istack(2,istp) = n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
if (istp <= 0) exit
|
|
|
|
|
|
|
|
ilx = istack(1,istp)
|
|
|
|
|
|
|
|
iux = istack(2,istp)
|
|
|
|
|
|
|
|
istp = istp - 1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Choose a pivot with median-of-three heuristics, leave it
|
|
|
|
|
|
|
|
! in the LPIV location
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
i = ilx
|
|
|
|
|
|
|
|
j = iux
|
|
|
|
|
|
|
|
lpiv = (i+j)/2
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
if (piv < x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
idx(i) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv > x(j)) then
|
|
|
|
|
|
|
|
xt = x(j)
|
|
|
|
|
|
|
|
ixt = idx(j)
|
|
|
|
|
|
|
|
x(j) = x(lpiv)
|
|
|
|
|
|
|
|
idx(j) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv < x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
idx(i) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! now piv is correct; place it into first location
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
idx(i) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i = ilx - 1
|
|
|
|
|
|
|
|
j = iux + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outer_up: do
|
|
|
|
|
|
|
|
in_up1: do
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
xk = x(i)
|
|
|
|
|
|
|
|
if (xk >= piv) exit in_up1
|
|
|
|
|
|
|
|
end do in_up1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Ensure finite termination for next loop
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
xt = xk
|
|
|
|
|
|
|
|
x(i) = piv
|
|
|
|
|
|
|
|
in_up2:do
|
|
|
|
|
|
|
|
j = j - 1
|
|
|
|
|
|
|
|
xk = x(j)
|
|
|
|
|
|
|
|
if (xk <= piv) exit in_up2
|
|
|
|
|
|
|
|
end do in_up2
|
|
|
|
|
|
|
|
x(i) = xt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (j > i) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(j)
|
|
|
|
|
|
|
|
idx(i) = idx(j)
|
|
|
|
|
|
|
|
x(j) = xt
|
|
|
|
|
|
|
|
idx(j) = ixt
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
exit outer_up
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
end do outer_up
|
|
|
|
|
|
|
|
if (i == ilx) then
|
|
|
|
|
|
|
|
if (x(i) /= piv) then
|
|
|
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,&
|
|
|
|
|
|
|
|
& r_name='psi_cqsrx',a_err='impossible pivot condition')
|
|
|
|
|
|
|
|
call psb_error()
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n1 = (i-1)-ilx+1
|
|
|
|
|
|
|
|
n2 = iux-(i)+1
|
|
|
|
|
|
|
|
if (n1 > n2) then
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_up(n1,x(ilx:i-1),idx(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_up(n2,x(i:iux),idx(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_up(n2,x(i:iux),idx(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_up(n1,x(ilx:i-1),idx(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_up(n,x,idx)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
end subroutine psi_cqsrx_up
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine psi_cqsrx_dw(n,x,idx)
|
|
|
|
|
|
|
|
use psb_c_sort_mod, psb_protect_name => psi_cqsrx_dw
|
|
|
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
complex(psb_spk_), intent(inout) :: x(:)
|
|
|
|
|
|
|
|
integer(psb_ipk_), intent(inout) :: idx(:)
|
|
|
|
|
|
|
|
integer(psb_ipk_), intent(in) :: n
|
|
|
|
|
|
|
|
! .. Local Scalars ..
|
|
|
|
|
|
|
|
complex(psb_spk_) :: piv, xk, xt
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Init stack pointer
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
istp = 1
|
|
|
|
|
|
|
|
istack(1,istp) = 1
|
|
|
|
|
|
|
|
istack(2,istp) = n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
if (istp <= 0) exit
|
|
|
|
|
|
|
|
ilx = istack(1,istp)
|
|
|
|
|
|
|
|
iux = istack(2,istp)
|
|
|
|
|
|
|
|
istp = istp - 1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Choose a pivot with median-of-three heuristics, leave it
|
|
|
|
|
|
|
|
! in the LPIV location
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
i = ilx
|
|
|
|
|
|
|
|
j = iux
|
|
|
|
|
|
|
|
lpiv = (i+j)/2
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
if (piv > x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
idx(i) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv < x(j)) then
|
|
|
|
|
|
|
|
xt = x(j)
|
|
|
|
|
|
|
|
ixt = idx(j)
|
|
|
|
|
|
|
|
x(j) = x(lpiv)
|
|
|
|
|
|
|
|
idx(j) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv > x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
idx(i) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! now piv is correct; place it into first location
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
idx(i) = idx(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
idx(lpiv) = ixt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i = ilx - 1
|
|
|
|
|
|
|
|
j = iux + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outer_dw: do
|
|
|
|
|
|
|
|
in_dw1: do
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
xk = x(i)
|
|
|
|
|
|
|
|
if (xk <= piv) exit in_dw1
|
|
|
|
|
|
|
|
end do in_dw1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Ensure finite termination for next loop
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
xt = xk
|
|
|
|
|
|
|
|
x(i) = piv
|
|
|
|
|
|
|
|
in_dw2:do
|
|
|
|
|
|
|
|
j = j - 1
|
|
|
|
|
|
|
|
xk = x(j)
|
|
|
|
|
|
|
|
if (xk >= piv) exit in_dw2
|
|
|
|
|
|
|
|
end do in_dw2
|
|
|
|
|
|
|
|
x(i) = xt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (j > i) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
ixt = idx(i)
|
|
|
|
|
|
|
|
x(i) = x(j)
|
|
|
|
|
|
|
|
idx(i) = idx(j)
|
|
|
|
|
|
|
|
x(j) = xt
|
|
|
|
|
|
|
|
idx(j) = ixt
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
exit outer_dw
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
end do outer_dw
|
|
|
|
|
|
|
|
if (i == ilx) then
|
|
|
|
|
|
|
|
if (x(i) /= piv) then
|
|
|
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,&
|
|
|
|
|
|
|
|
& r_name='psi_cqsrx',a_err='impossible pivot condition')
|
|
|
|
|
|
|
|
call psb_error()
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n1 = (i-1)-ilx+1
|
|
|
|
|
|
|
|
n2 = iux-(i)+1
|
|
|
|
|
|
|
|
if (n1 > n2) then
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_dw(n1,x(ilx:i-1),idx(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_dw(n2,x(i:iux),idx(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_dw(n2,x(i:iux),idx(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_dw(n1,x(ilx:i-1),idx(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisrx_dw(n,x,idx)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end subroutine psi_cqsrx_dw
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine psi_cqsr_up(n,x)
|
|
|
|
|
|
|
|
use psb_c_sort_mod, psb_protect_name => psi_cqsr_up
|
|
|
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
complex(psb_spk_), intent(inout) :: x(:)
|
|
|
|
|
|
|
|
integer(psb_ipk_), intent(in) :: n
|
|
|
|
|
|
|
|
! ..
|
|
|
|
|
|
|
|
! .. Local Scalars ..
|
|
|
|
|
|
|
|
complex(psb_spk_) :: piv, xt, xk
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Init stack pointer
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
istp = 1
|
|
|
|
|
|
|
|
istack(1,istp) = 1
|
|
|
|
|
|
|
|
istack(2,istp) = n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
if (istp <= 0) exit
|
|
|
|
|
|
|
|
ilx = istack(1,istp)
|
|
|
|
|
|
|
|
iux = istack(2,istp)
|
|
|
|
|
|
|
|
istp = istp - 1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Choose a pivot with median-of-three heuristics, leave it
|
|
|
|
|
|
|
|
! in the LPIV location
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
i = ilx
|
|
|
|
|
|
|
|
j = iux
|
|
|
|
|
|
|
|
lpiv = (i+j)/2
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
if (piv < x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv > x(j)) then
|
|
|
|
|
|
|
|
xt = x(j)
|
|
|
|
|
|
|
|
x(j) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv < x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! now piv is correct; place it into first location
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i = ilx - 1
|
|
|
|
|
|
|
|
j = iux + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outer_up: do
|
|
|
|
|
|
|
|
in_up1: do
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
xk = x(i)
|
|
|
|
|
|
|
|
if (xk >= piv) exit in_up1
|
|
|
|
|
|
|
|
end do in_up1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Ensure finite termination for next loop
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
xt = xk
|
|
|
|
|
|
|
|
x(i) = piv
|
|
|
|
|
|
|
|
in_up2:do
|
|
|
|
|
|
|
|
j = j - 1
|
|
|
|
|
|
|
|
xk = x(j)
|
|
|
|
|
|
|
|
if (xk <= piv) exit in_up2
|
|
|
|
|
|
|
|
end do in_up2
|
|
|
|
|
|
|
|
x(i) = xt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (j > i) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(j)
|
|
|
|
|
|
|
|
x(j) = xt
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
exit outer_up
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
end do outer_up
|
|
|
|
|
|
|
|
if (i == ilx) then
|
|
|
|
|
|
|
|
if (x(i) /= piv) then
|
|
|
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,&
|
|
|
|
|
|
|
|
& r_name='psi_cqsr',a_err='impossible pivot condition')
|
|
|
|
|
|
|
|
call psb_error()
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n1 = (i-1)-ilx+1
|
|
|
|
|
|
|
|
n2 = iux-(i)+1
|
|
|
|
|
|
|
|
if (n1 > n2) then
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_up(n1,x(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_up(n2,x(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_up(n2,x(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_up(n1,x(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_up(n,x)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end subroutine psi_cqsr_up
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subroutine psi_cqsr_dw(n,x)
|
|
|
|
|
|
|
|
use psb_c_sort_mod, psb_protect_name => psi_cqsr_dw
|
|
|
|
|
|
|
|
use psb_error_mod
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
complex(psb_spk_), intent(inout) :: x(:)
|
|
|
|
|
|
|
|
integer(psb_ipk_), intent(in) :: n
|
|
|
|
|
|
|
|
! ..
|
|
|
|
|
|
|
|
! .. Local Scalars ..
|
|
|
|
|
|
|
|
complex(psb_spk_) :: piv, xt, xk
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Init stack pointer
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
istp = 1
|
|
|
|
|
|
|
|
istack(1,istp) = 1
|
|
|
|
|
|
|
|
istack(2,istp) = n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
if (istp <= 0) exit
|
|
|
|
|
|
|
|
ilx = istack(1,istp)
|
|
|
|
|
|
|
|
iux = istack(2,istp)
|
|
|
|
|
|
|
|
istp = istp - 1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Choose a pivot with median-of-three heuristics, leave it
|
|
|
|
|
|
|
|
! in the LPIV location
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
i = ilx
|
|
|
|
|
|
|
|
j = iux
|
|
|
|
|
|
|
|
lpiv = (i+j)/2
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
if (piv > x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv < x(j)) then
|
|
|
|
|
|
|
|
xt = x(j)
|
|
|
|
|
|
|
|
x(j) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (piv > x(i)) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
piv = x(lpiv)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! now piv is correct; place it into first location
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(lpiv)
|
|
|
|
|
|
|
|
x(lpiv) = xt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i = ilx - 1
|
|
|
|
|
|
|
|
j = iux + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outer_dw: do
|
|
|
|
|
|
|
|
in_dw1: do
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
xk = x(i)
|
|
|
|
|
|
|
|
if (xk <= piv) exit in_dw1
|
|
|
|
|
|
|
|
end do in_dw1
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
! Ensure finite termination for next loop
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
xt = xk
|
|
|
|
|
|
|
|
x(i) = piv
|
|
|
|
|
|
|
|
in_dw2:do
|
|
|
|
|
|
|
|
j = j - 1
|
|
|
|
|
|
|
|
xk = x(j)
|
|
|
|
|
|
|
|
if (xk >= piv) exit in_dw2
|
|
|
|
|
|
|
|
end do in_dw2
|
|
|
|
|
|
|
|
x(i) = xt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (j > i) then
|
|
|
|
|
|
|
|
xt = x(i)
|
|
|
|
|
|
|
|
x(i) = x(j)
|
|
|
|
|
|
|
|
x(j) = xt
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
exit outer_dw
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
end do outer_dw
|
|
|
|
|
|
|
|
if (i == ilx) then
|
|
|
|
|
|
|
|
if (x(i) /= piv) then
|
|
|
|
|
|
|
|
call psb_errpush(psb_err_internal_error_, &
|
|
|
|
|
|
|
|
& r_name='psi_cqsr',a_err='impossible pivot condition')
|
|
|
|
|
|
|
|
call psb_error()
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n1 = (i-1)-ilx+1
|
|
|
|
|
|
|
|
n2 = iux-(i)+1
|
|
|
|
|
|
|
|
if (n1 > n2) then
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_dw(n1,x(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_dw(n2,x(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if (n2 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = i
|
|
|
|
|
|
|
|
istack(2,istp) = iux
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_dw(n2,x(i:iux))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (n1 > ithrs) then
|
|
|
|
|
|
|
|
istp = istp + 1
|
|
|
|
|
|
|
|
istack(1,istp) = ilx
|
|
|
|
|
|
|
|
istack(2,istp) = i-1
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_dw(n1,x(ilx:i-1))
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
call psi_cisr_dw(n,x)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end subroutine psi_cqsr_dw
|
|
|
|
|
|
|
|
@REALE@
|
|
|
|
|
|
|
|
|
|
|
|
subroutine psi_clqsrx_up(n,x,idx)
|
|
|
|
subroutine psi_clqsrx_up(n,x,idx)
|
|
|
|
use psb_c_sort_mod, psb_protect_name => psi_clqsrx_up
|
|
|
|
use psb_c_sort_mod, psb_protect_name => psi_clqsrx_up
|
|
|
@ -152,7 +730,7 @@ subroutine psi_clqsrx_up(n,x,idx)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
@ -308,7 +886,7 @@ subroutine psi_clqsrx_dw(n,x,idx)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
@ -463,7 +1041,7 @@ subroutine psi_clqsr_up(n,x)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -604,7 +1182,7 @@ subroutine psi_clqsr_dw(n,x)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -746,7 +1324,7 @@ subroutine psi_calqsrx_up(n,x,idx)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
@ -901,7 +1479,7 @@ subroutine psi_calqsrx_dw(n,x,idx)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
@ -1056,7 +1634,7 @@ subroutine psi_calqsr_up(n,x)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1196,7 +1774,7 @@ subroutine psi_calqsr_dw(n,x)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
integer(psb_ipk_) :: n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1337,7 +1915,7 @@ subroutine psi_caqsrx_up(n,x,idx)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
@ -1493,7 +2071,7 @@ subroutine psi_caqsrx_dw(n,x,idx)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
|
!
|
|
|
|
!
|
|
|
@ -1646,7 +2224,7 @@ subroutine psi_caqsr_up(n,x)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
@ -1786,7 +2364,7 @@ subroutine psi_caqsr_dw(n,x)
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: i, j, ilx, iux, istp, lpiv
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
integer(psb_ipk_) :: ixt, n1, n2
|
|
|
|
|
|
|
|
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=16
|
|
|
|
integer(psb_ipk_), parameter :: maxstack=64,nparms=3,ithrs=32
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
integer(psb_ipk_) :: istack(nparms,maxstack)
|
|
|
|
|
|
|
|
|
|
|
|
if (n > ithrs) then
|
|
|
|
if (n > ithrs) then
|
|
|
|