mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-22 03:23:29 +01:00
Binary search in det to configuration
This commit is contained in:
parent
7e4d08f51f
commit
9ea755c757
@ -319,7 +319,7 @@ BEGIN_PROVIDER [ integer, det_to_configuration, (N_det) ]
|
|||||||
! Returns the index of the configuration for each determinant
|
! Returns the index of the configuration for each determinant
|
||||||
END_DOC
|
END_DOC
|
||||||
integer :: i,j,k,r,l
|
integer :: i,j,k,r,l
|
||||||
integer*8 :: key
|
integer*8 :: key, key2
|
||||||
integer(bit_kind) :: occ(N_int,2)
|
integer(bit_kind) :: occ(N_int,2)
|
||||||
logical :: found
|
logical :: found
|
||||||
integer*8, allocatable :: bit_tmp(:)
|
integer*8, allocatable :: bit_tmp(:)
|
||||||
@ -340,36 +340,23 @@ BEGIN_PROVIDER [ integer, det_to_configuration, (N_det) ]
|
|||||||
|
|
||||||
key = configuration_search_key(occ,N_int)
|
key = configuration_search_key(occ,N_int)
|
||||||
|
|
||||||
! TODO: Binary search
|
l = 0
|
||||||
l = 1
|
r = N_configuration+1
|
||||||
r = N_configuration
|
j = shiftr(r-l,1)
|
||||||
! do while(r-l > 32)
|
do while (j>=1)
|
||||||
! j = shiftr(r+l,1)
|
j = j+l
|
||||||
! if (bit_tmp(j) < key) then
|
key2 = configuration_search_key(psi_configuration(1,1,j),N_int)
|
||||||
! l = j
|
if (key2 == key) then
|
||||||
! else
|
|
||||||
! r = j
|
|
||||||
! endif
|
|
||||||
! enddo
|
|
||||||
do j=l,r
|
|
||||||
found = .True.
|
|
||||||
do k=1,N_int
|
|
||||||
if ( (occ(k,1) /= psi_configuration(k,1,j)) &
|
|
||||||
.or. (occ(k,2) /= psi_configuration(k,2,j)) ) then
|
|
||||||
found = .False.
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
enddo
|
|
||||||
if (found) then
|
|
||||||
det_to_configuration(i) = j
|
det_to_configuration(i) = j
|
||||||
exit
|
exit
|
||||||
|
else if (key2 > key) then
|
||||||
|
r = j
|
||||||
|
else
|
||||||
|
l = j
|
||||||
endif
|
endif
|
||||||
|
j = shiftr(r-l,1)
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
if (.not.found) then
|
|
||||||
print *, '3 bug in ', irp_here
|
|
||||||
stop -1
|
|
||||||
endif
|
|
||||||
enddo
|
enddo
|
||||||
!$OMP END PARALLEL DO
|
!$OMP END PARALLEL DO
|
||||||
deallocate(bit_tmp)
|
deallocate(bit_tmp)
|
||||||
|
Loading…
Reference in New Issue
Block a user