  A scheme is presented to perform an entangling gate between two atomic
ensembles or Bose-Einstein condensates in a optical cavity with a common
optical mode. The method involves using a generalized Stimulated Raman
Adiabatic Passage (STIRAP) to adiabatically evolve the ground state. We show
that dark states exist for any atom number within the cavities, and find that
the operation produces an unusual type of evolution where the minimum of the
number of atoms between two levels transitions to another state. This produces
a unconventional type of entangling Hamiltonian which creates a phase depending
on the minimum operation. We analyze its reliability under a variety of
conditions ranging from the ideal decoherence-free case to that including
photon loss and spontaneous emission. Ways of combating decoherence are
analyzed and the amount of entanglement that is generated is calculated.
