which( maximum( ($a->dummy == $b) ) != 0) #### which( maximum( $a->dummy == $b ) ) #### # The one I basically handed you. Catches duplicates. $c = which( $a == $b->dummy ) % $a->dim(0); # Switching up the dims. Basically same as above. $c = which( $a->dummy == $b ) / $b->dim(0); # Using summation. Like yours, ignores duplicates. $c = which( sumover( $a->dummy == $b ) );