function varargout = rootfinder(varargin)
    %ROOTFINDER Create a solver for rootfinding problems Takes a function where one of the
    %
    %  Function = ROOTFINDER(char name, char solver, Function f, struct opts)
    %
    %inputs is unknown and one of the outputs is a residual function that is
    %always zero, defines a new function where the the unknown input has been
    %replaced by a guess for the unknown and the residual output has been
    %replaced by the calculated value for the input.
    %
    %For a function [y0, y1, ...,yi, .., yn] = F(x0, x1, ..., xj, ..., xm), where
    %xj is unknown and yi=0, defines a new function [y0, y1, ...,xj, .., yn] =
    %G(x0, x1, ..., xj_guess, ..., xm),
    %
    %xj and yi must have the same dimension and d(yi)/d(xj) must be invertable.
    %
    %By default, the first input is unknown and the first output is the residual.
    %
    %General information
    %===================
    %
    %
    %
    %>List of available options
    %
    %+-----------------+-----------------+-----------------+-----------------+
    %|       Id        |      Type       |   Description   |     Used in     |
    %+=================+=================+=================+=================+
    %| constraints     | OT_INTVECTOR    | Constrain the   | casadi::Rootfin |
    %|                 |                 | unknowns. 0     | der             |
    %|                 |                 | (default): no   |                 |
    %|                 |                 | constraint on   |                 |
    %|                 |                 | ui, 1: ui >=    |                 |
    %|                 |                 | 0.0, -1: ui <=  |                 |
    %|                 |                 | 0.0, 2: ui >    |                 |
    %|                 |                 | 0.0, -2: ui <   |                 |
    %|                 |                 | 0.0.            |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %| implicit_input  | OT_INT          | Index of the    | casadi::Rootfin |
    %|                 |                 | input that      | der             |
    %|                 |                 | corresponds to  |                 |
    %|                 |                 | the actual      |                 |
    %|                 |                 | root-finding    |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %| implicit_output | OT_INT          | Index of the    | casadi::Rootfin |
    %|                 |                 | output that     | der             |
    %|                 |                 | corresponds to  |                 |
    %|                 |                 | the actual      |                 |
    %|                 |                 | root-finding    |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %| jacobian_functi | OT_FUNCTION     | Function object | casadi::Rootfin |
    %| on              |                 | for calculating | der             |
    %|                 |                 | the Jacobian    |                 |
    %|                 |                 | (autogenerated  |                 |
    %|                 |                 | by default)     |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %| linear_solver   | OT_STRING       | User-defined    | casadi::Rootfin |
    %|                 |                 | linear solver   | der             |
    %|                 |                 | class. Needed   |                 |
    %|                 |                 | for             |                 |
    %|                 |                 | sensitivities.  |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %| linear_solver_o | OT_DICT         | Options to be   | casadi::Rootfin |
    %| ptions          |                 | passed to the   | der             |
    %|                 |                 | linear solver.  |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %| monitor         | OT_STRINGVECTOR | Set of user     | casadi::OracleF |
    %|                 |                 | problem         | unction         |
    %|                 |                 | functions to be |                 |
    %|                 |                 | monitored       |                 |
    %+-----------------+-----------------+-----------------+-----------------+
    %
    %List of plugins
    %===============
    %
    %
    %
    %- kinsol
    %
    %- nlpsol
    %
    %- newton
    %
    %Note: some of the plugins in this list might not be available on your
    %system. Also, there might be extra plugins available to you that are not
    %listed here. You can obtain their documentation with
    %Rootfinder.doc("myextraplugin")
    %
    %
    %
    %--------------------------------------------------------------------------------
    %
    %kinsol
    %------
    %
    %
    %
    %KINSOL interface from the Sundials suite
    %
    %>List of available options
    %
    %+------------------------+------------------------+------------------------+
    %|           Id           |          Type          |      Description       |
    %+========================+========================+========================+
    %| abstol                 | OT_DOUBLE              | Stopping criterion     |
    %|                        |                        | tolerance              |
    %+------------------------+------------------------+------------------------+
    %| disable_internal_warni | OT_BOOL                | Disable KINSOL         |
    %| ngs                    |                        | internal warning       |
    %|                        |                        | messages               |
    %+------------------------+------------------------+------------------------+
    %| exact_jacobian         | OT_BOOL                | Use exact Jacobian     |
    %|                        |                        | information            |
    %+------------------------+------------------------+------------------------+
    %| f_scale                | OT_DOUBLEVECTOR        | Equation scaling       |
    %|                        |                        | factors                |
    %+------------------------+------------------------+------------------------+
    %| iterative_solver       | OT_STRING              | gmres|bcgstab|tfqmr    |
    %+------------------------+------------------------+------------------------+
    %| linear_solver_type     | OT_STRING              | dense|banded|iterative |
    %|                        |                        | |user_defined          |
    %+------------------------+------------------------+------------------------+
    %| lower_bandwidth        | OT_INT                 | Lower bandwidth for    |
    %|                        |                        | banded linear solvers  |
    %+------------------------+------------------------+------------------------+
    %| max_iter               | OT_INT                 | Maximum number of      |
    %|                        |                        | Newton iterations.     |
    %|                        |                        | Putting 0 sets the     |
    %|                        |                        | default value of       |
    %|                        |                        | KinSol.                |
    %+------------------------+------------------------+------------------------+
    %| max_krylov             | OT_INT                 | Maximum Krylov space   |
    %|                        |                        | dimension              |
    %+------------------------+------------------------+------------------------+
    %| pretype                | OT_STRING              | Type of preconditioner |
    %+------------------------+------------------------+------------------------+
    %| strategy               | OT_STRING              | Globalization strategy |
    %+------------------------+------------------------+------------------------+
    %| u_scale                | OT_DOUBLEVECTOR        | Variable scaling       |
    %|                        |                        | factors                |
    %+------------------------+------------------------+------------------------+
    %| upper_bandwidth        | OT_INT                 | Upper bandwidth for    |
    %|                        |                        | banded linear solvers  |
    %+------------------------+------------------------+------------------------+
    %| use_preconditioner     | OT_BOOL                | Precondition an        |
    %|                        |                        | iterative solver       |
    %+------------------------+------------------------+------------------------+
    %
    %--------------------------------------------------------------------------------
    %
    %
    %
    %--------------------------------------------------------------------------------
    %
    %nlpsol
    %------
    %
    %
    %
    %
    %
    %--------------------------------------------------------------------------------
    %
    %
    %
    %
    %
    %--------------------------------------------------------------------------------
    %
    %newton
    %------
    %
    %
    %
    %Implements simple newton iterations to solve an implicit function.
    %
    %>List of available options
    %
    %+------------------------+------------------------+------------------------+
    %|           Id           |          Type          |      Description       |
    %+========================+========================+========================+
    %| abstol                 | OT_DOUBLE              | Stopping criterion     |
    %|                        |                        | tolerance on max(|F|)  |
    %+------------------------+------------------------+------------------------+
    %| abstolStep             | OT_DOUBLE              | Stopping criterion     |
    %|                        |                        | tolerance on step size |
    %+------------------------+------------------------+------------------------+
    %| max_iter               | OT_INT                 | Maximum number of      |
    %|                        |                        | Newton iterations to   |
    %|                        |                        | perform before         |
    %|                        |                        | returning.             |
    %+------------------------+------------------------+------------------------+
    %| print_iteration        | OT_BOOL                | Print information      |
    %|                        |                        | about each iteration   |
    %+------------------------+------------------------+------------------------+
    %
    %--------------------------------------------------------------------------------
    %
    %
    %
    %Joel Andersson
    %
    %
    %
  [varargout{1:nargout}] = casadiMEX(869, varargin{:});
end
