Flexible multidimensional pattern recognition in C and Java.