General Implementation of Approximate Message Passing