Template class for searching an N-dimensional data set for M clusters