pure function generator_sign(i, j, k, l) result(sgn)
integer, intent(in) :: i, j, k, l
real(dp) :: sgn
! standard value. only for double raising and lowering a -1 can happen
sgn = 1.0_dp
if (i < j .and. k < l) then
! double raising
! make rudimentary now.. think of increasing speed later
if (i < k) then
if (l < j) then
sgn = -1.0_dp
end if
else if (k < i) then
if (j < l) then
sgn = -1.0_dp
end if
end if
else if (j < i .and. l < k) then
! double lowering
if (j < l) then
if (k < i) then
sgn = -1.0_dp
end if
else if (l < j) then
if (i < k) then
sgn = -1.0_dp
end if
end if
end if
end function generator_sign