forward algorithm using rcpp/rcpparmadillo