ported train_machine to Eigen3