  We present a solution of the problem of the optimal unambiguous comparison of
two ensembles of unknown quantum states (psi_1)^k and (psi_2)^l. We consider
two cases: 1) The two unknown states psi_1 and psi_2 are arbitrary states of
qudits. 2) Alternatively, they are coherent states of a harmonic oscillator.
For the case of coherent states we propose a simple experimental realization of
the optimal "comparison" machine composed of a finite number of beam-splitters
and a single photodetector.
