Small improvements

See the companion PR on the engine. Here are the improvements:

1) improved the numpy manipulation in scientific.event_based
2) added a boolean `return_loss_matrix` so that the loss_matrix is stored in memory only when needed
3) added a method `compute_output` so that the engine can compute one output at the time, thus saving memory