Matrix traversal using iterators at HMMTrainer