added Viterbi and Mackay algorithms