vectorised viterbi.