Module name: confusion
Author: Ian Stewart (University of Leicester, ims@star.le.ac.uk)
subroutine findConfusedSets(srcX, srcY, srcRadius, confSetNum) real(double), intent(in) :: srcX(:), srcY(size(srcX)) real(double), intent(in) :: srcRadius(size(srcX)) integer(int16), intent(out) :: confSetNum(size(srcX)) end subroutine findConfusedSets This subroutine takes as inputs a list of source positions $srcX$ and $srcY$ and nominal radii $srcRadius$ and returns a list of indices $confSetNum$. An index of zero indicates that the source is not confused with any other in the set. Two sources are defined to be confused if the sum of their radii exceeds their separation distance. If the returned index for any source is greater than zero, that indicates that the source is confused with at least one other having the same index. The index values are set such that (i) any source having $confSetNum=i$ is confused with at least one other source having the same value of $confSetNum$, and (ii) no source with $confSetNum=i$ is confused with any source for which $confSetNum \ne i$. In diagrammatic form each confusion group would appear as an island of interlinked circles. Note however that it is \emph{not} necessarily true that, if sources $p$ and $q$ are members of the same confusion group, then $p$ is confused with $q$ - they could for example be at either end of a long chain of confused sources. There are no gaps in the returned sequence of confusion indices. Ie for all valid confusion indices $i>1$, $i-1$ is also a valid confusion index.