Adding the forward algorithm in log space