Refactor: Nonlinearity object

`nonlinearity` is now a class that knows how to apply a nonlinearity or its gradient.  This will be important for the `mrf` class.