Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs	(revision 16221)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs	(revision 16222)
@@ -609,4 +609,43 @@
 
     #region interpretation
+
+    // the following uses auto-diff to calculate the gradient w.r.t. the parameters forward in time.
+    // this is basically the method described in Gronwall T. Note on the derivatives with respect to a parameter of the solutions of a system of differential equations. Ann. Math. 1919;20:292–296.
+
+    // a comparison of three potential calculation methods for the gradient is given in:
+    // Sengupta, B., Friston, K. J., & Penny, W. D. (2014). Efficient gradient computation for dynamical models. Neuroimage, 98(100), 521–527. http://doi.org/10.1016/j.neuroimage.2014.04.040
+    // "Our comparison establishes that the adjoint method is computationally more efficient for numerical estimation of parametric gradients
+    // for state-space models — both linear and non-linear, as in the case of a dynamical causal model (DCM)"
+
+    // for a solver with the necessary features see: https://computation.llnl.gov/projects/sundials/cvodes
+    /*
+     * SUNDIALS: SUite of Nonlinear and DIfferential/ALgebraic Equation Solvers
+     * CVODES
+     * CVODES is a solver for stiff and nonstiff ODE systems (initial value problem) given in explicit 
+     * form y’ = f(t,y,p) with sensitivity analysis capabilities (both forward and adjoint modes). CVODES
+     * is a superset of CVODE and hence all options available to CVODE (with the exception of the FCVODE 
+     * interface module) are also available for CVODES. Both integration methods (Adams-Moulton and BDF) 
+     * and the corresponding nonlinear iteration methods, as well as all linear solver and preconditioner
+     * modules, are available for the integration of the original ODEs, the sensitivity systems, or the 
+     * adjoint system. Depending on the number of model parameters and the number of functional outputs, 
+     * one of two sensitivity methods is more appropriate. The forward sensitivity analysis (FSA) method 
+     * is mostly suitable when the gradients of many outputs (for example the entire solution vector) with 
+     * respect to relatively few parameters are needed. In this approach, the model is differentiated with 
+     * respect to each parameter in turn to yield an additional system of the same size as the original 
+     * one, the result of which is the solution sensitivity. The gradient of any output function depending
+     * on the solution can then be directly obtained from these sensitivities by applying the chain rule
+     * of differentiation. The adjoint sensitivity analysis (ASA) method is more practical than the 
+     * forward approach when the number of parameters is large and the gradients of only few output 
+     * functionals are needed. In this approach, the solution sensitivities need not be computed 
+     * explicitly. Instead, for each output functional of interest, an additional system, adjoint to the 
+     * original one, is formed and solved. The solution of the adjoint system can then be used to evaluate
+     * the gradient of the output functional with respect to any set of model parameters. The FSA module 
+     * in CVODES implements a simultaneous corrector method as well as two flavors of staggered corrector
+     * methods–for the case when sensitivity right hand sides are generated all at once or separated for
+     * each model parameter. The ASA module provides the infrastructure required for the backward 
+     * integration in time of systems of differential equations dependent on the solution of the original
+     * ODEs. It employs a checkpointing scheme for efficient interpolation of forward solutions during the
+     * backward integration.
+     */
     private static IEnumerable<Tuple<double, Vector>[]> Integrate(
       ISymbolicExpressionTree[] trees, IDataset dataset, string[] inputVariables, string[] targetVariables, string[] latentVariables, IEnumerable<IntRange> episodes,
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes.h	(revision 16222)
@@ -0,0 +1,1994 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the interface file for the main CVODES integrator.
+ * -----------------------------------------------------------------
+ *
+ * CVODES is used to solve numerically the ordinary initial value    
+ * problem:                                                          
+ *                                                                   
+ *                 y' = f(t,y),                                      
+ *                 y(t0) = y0,                                       
+ *                                                                   
+ * where t0, y0 in R^N, and f: R x R^N -> R^N are given.             
+ *                                                                   
+ * Optionally, CVODES can perform forward or adjoint sensitivity 
+ * analysis to find sensitivities of the solution y with respect 
+ * to parameters in the right hand side f and/or in the initial         
+ * conditions y0.                                                    
+ *
+ * -----------------------------------------------------------------
+ *
+ *  1: CONSTANTS
+ *     input constants
+ *     return flags
+ *
+ *  2: FUNCTION TYPES
+ *     CVRhsFn CVQuadRhsFn CVSensRhsFn CVSensRhs1Fn CVQuadSensRhsFn
+ *     CVRootFn
+ *     CVEwtFn
+ *     CVErrHandlerFn
+ *     CVRhsFnB     CVRhsFnBS
+ *     CVQuadRhsFnB CVQuadRhsFnBS
+ *     
+ *  3: INITIALIZATION AND DEALLOCATION FUNCTIONS FOR FORWARD PROBLEMS
+ *     CVodeCreate
+ *     CVodeInit        CVodeReInit
+ *     CVodeQuadInit    CVodeQuadReInit
+ *     CVodeSensInit    CVodeSensReInit
+ *     CVodeRootInit
+ *     CVodeFree          CVodeQuadFree      CVodeSensFree
+ *    
+ *  4: OPTIONAL INPUT FUNCTIONS FOR FORWARD PROBLEMS   
+ *    
+ *  5: MAIN SOLVER FUNCTION FOR FORWARD PROBLEMS
+ *     CVode
+ *
+ *  6: EXTRACTION AND DENSE OUTPUT FUNCTIONS FOR FORWARD PROBLEMS
+ *     CVodeGetDky
+ *     CVodeGetQuad
+ *     CVodeGetQuadDky
+ *     CVodeGetSens      CVodeGetSens1
+ *     CVodeGetSensDky   CVodeGetSensDky1
+ *     CVodeGetQuadSens      CVodeGetQuadSens1
+ *     CVodeGetQuadSensDky   CVodeGetQuadSensDky1
+ *    
+ *  7: OPTIONAL OUTPUT FUNCTIONS FOR FORWARD PROBLEMS
+ *    
+ *  8: INITIALIZATION AND DEALLOCATION FUNCTIONS FOR BACKWARD PROBLEMS  
+ *     CVodeAdjInit    CVodeAdjReInit
+ *     CVodeAdjFree
+ *     CVodeInitB      CVodeInitBS       CVodeReInitB
+ *     CVodeQuadInitB  CVodeQuadInitBS   CVodeQuadReInitB
+ *     
+ *  9  MAIN SOLVER FUNCTIONS FOR FORWARD PROBLEMS
+ *     CVodeF
+ *     CVodeB
+ *    
+ * 10: OPTIONAL INPUT FUNCTIONS FOR BACKWARD PROBLEMS  
+ *    
+ * 11: EXTRACTION AND DENSE OUTPUT FUNCTIONS FOR BACKWARD PROBLEMS  
+ *     CVodeGetB
+ *     CVodeGetQuadB
+ *    
+ * 12: OPTIONAL OUTPUT FUNCTIONS FOR BACKWARD PROBLEMS   
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVODES_H
+#define _CVODES_H
+
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ *
+ * CVODES CONSTANTS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Enumerations for inputs to:
+ * CVodeCreate (lmm, iter),
+ * CVodeSensInit, CvodeSensinit1, CVodeSensReInit (ism),
+ * CVodeAdjInit (interp),
+ * CVode (itask)
+ * -----------------------------------------------------------------
+ * Symbolic constants for the lmm and iter parameters to CVodeCreate
+ * the input parameter itask to CVode, and the input parameter interp
+ * to CVodeAdjInit, are given below.
+ *
+ * lmm:   The user of the CVODES package specifies whether to use
+ *        the CV_ADAMS or CV_BDF (backward differentiation formula)
+ *        linear multistep method. The BDF method is recommended
+ *        for stiff problems, and the CV_ADAMS method is recommended
+ *        for nonstiff problems.
+ *
+ * iter:  At each internal time step, a nonlinear equation must
+ *        be solved. The user can specify either CV_FUNCTIONAL
+ *        iteration, which does not require linear algebra, or a
+ *        CV_NEWTON iteration, which requires the solution of linear
+ *        systems. In the CV_NEWTON case, the user also specifies a
+ *        CVODE linear solver. CV_NEWTON is recommended in case of
+ *        stiff problems.
+ *
+ * ism:   This parameter specifies the sensitivity corrector type
+ *        to be used. In the CV_SIMULTANEOUS case, the nonlinear
+ *        systems for states and all sensitivities are solved
+ *        simultaneously. In the CV_STAGGERED case, the nonlinear
+ *        system for states is solved first and then, the
+ *        nonlinear systems for all sensitivities are solved
+ *        at the same time. Finally, in the CV_STAGGERED1 approach
+ *        all nonlinear systems are solved in a sequence.
+ *
+ * itask: The itask input parameter to CVode indicates the job
+ *        of the solver for the next user step. The CV_NORMAL
+ *        itask is to have the solver take internal steps until
+ *        it has reached or just passed the user specified tout
+ *        parameter. The solver then interpolates in order to
+ *        return an approximate value of y(tout). The CV_ONE_STEP
+ *        option tells the solver to just take one internal step
+ *        and return the solution at the point reached by that step.
+ *
+ * interp: Specifies the interpolation type used to evaluate the
+ *        forward solution during the backward integration phase.
+ *        CV_HERMITE specifies cubic Hermite interpolation.
+ *        CV_POYNOMIAL specifies the polynomial interpolation
+ * -----------------------------------------------------------------
+ */
+
+/* lmm */
+#define CV_ADAMS          1
+#define CV_BDF            2
+
+/* iter */
+#define CV_FUNCTIONAL     1
+#define CV_NEWTON         2
+
+/* itask */
+#define CV_NORMAL         1
+#define CV_ONE_STEP       2
+
+/* ism */
+#define CV_SIMULTANEOUS   1
+#define CV_STAGGERED      2
+#define CV_STAGGERED1     3
+
+/* DQtype */
+#define CV_CENTERED       1
+#define CV_FORWARD        2
+
+/* interp */
+#define CV_HERMITE        1
+#define CV_POLYNOMIAL     2
+
+/* 
+ * ----------------------------------------
+ * CVODES return flags
+ * ----------------------------------------
+ */
+
+#define CV_SUCCESS               0
+#define CV_TSTOP_RETURN          1
+#define CV_ROOT_RETURN           2
+
+#define CV_WARNING              99
+
+#define CV_TOO_MUCH_WORK        -1
+#define CV_TOO_MUCH_ACC         -2
+#define CV_ERR_FAILURE          -3
+#define CV_CONV_FAILURE         -4
+
+#define CV_LINIT_FAIL           -5
+#define CV_LSETUP_FAIL          -6
+#define CV_LSOLVE_FAIL          -7
+#define CV_RHSFUNC_FAIL         -8
+#define CV_FIRST_RHSFUNC_ERR    -9
+#define CV_REPTD_RHSFUNC_ERR    -10
+#define CV_UNREC_RHSFUNC_ERR    -11
+#define CV_RTFUNC_FAIL          -12
+#define CV_CONSTR_FAIL          -13
+
+#define CV_MEM_FAIL             -20
+#define CV_MEM_NULL             -21
+#define CV_ILL_INPUT            -22
+#define CV_NO_MALLOC            -23
+#define CV_BAD_K                -24
+#define CV_BAD_T                -25
+#define CV_BAD_DKY              -26
+#define CV_TOO_CLOSE            -27
+
+#define CV_NO_QUAD              -30
+#define CV_QRHSFUNC_FAIL        -31
+#define CV_FIRST_QRHSFUNC_ERR   -32
+#define CV_REPTD_QRHSFUNC_ERR   -33
+#define CV_UNREC_QRHSFUNC_ERR   -34
+
+#define CV_NO_SENS              -40
+#define CV_SRHSFUNC_FAIL        -41
+#define CV_FIRST_SRHSFUNC_ERR   -42
+#define CV_REPTD_SRHSFUNC_ERR   -43
+#define CV_UNREC_SRHSFUNC_ERR   -44
+
+#define CV_BAD_IS               -45
+
+#define CV_NO_QUADSENS          -50
+#define CV_QSRHSFUNC_FAIL       -51
+#define CV_FIRST_QSRHSFUNC_ERR  -52
+#define CV_REPTD_QSRHSFUNC_ERR  -53
+#define CV_UNREC_QSRHSFUNC_ERR  -54
+
+/* 
+ * ----------------------------------------
+ * CVODEA return flags
+ * ----------------------------------------
+ */
+
+#define CV_NO_ADJ              -101
+#define CV_NO_FWD              -102
+#define CV_NO_BCK              -103
+#define CV_BAD_TB0             -104
+#define CV_REIFWD_FAIL         -105
+#define CV_FWD_FAIL            -106
+#define CV_GETY_BADT           -107
+
+/*
+ * =================================================================
+ *
+ * FUNCTION TYPES
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVRhsFn
+ * -----------------------------------------------------------------
+ * The f function which defines the right hand side of the ODE
+ * system y' = f(t,y) must have type CVRhsFn.
+ * f takes as input the independent variable value t, and the
+ * dependent variable vector y.  It stores the result of f(t,y)
+ * in the vector ydot.  The y and ydot arguments are of type
+ * N_Vector.
+ * (Allocation of memory for ydot is handled within CVODES)
+ * The user_data parameter is the same as the user_data
+ * parameter set by the user through the CVodeSetUserData routine.
+ * This user-supplied pointer is passed to the user's f function
+ * every time it is called.
+ *
+ * A CVRhsFn should return 0 if successful, a negative value if
+ * an unrecoverable error occured, and a positive value if a 
+ * recoverable error (e.g. invalid y values) occured. 
+ * If an unrecoverable occured, the integration is halted. 
+ * If a recoverable error occured, then (in most cases) CVODES
+ * will try to correct and retry.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVRhsFn)(realtype t, N_Vector y,
+		       N_Vector ydot, void *user_data);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVRootFn
+ * -----------------------------------------------------------------
+ * A function g, which defines a set of functions g_i(t,y) whose
+ * roots are sought during the integration, must have type CVRootFn.
+ * The function g takes as input the independent variable value
+ * t, and the dependent variable vector y.  It stores the nrtfn
+ * values g_i(t,y) in the realtype array gout.
+ * (Allocation of memory for gout is handled within CVODE.)
+ * The user_data parameter is the same as that passed by the user
+ * to the CVodeSetUserData routine.  This user-supplied pointer is
+ * passed to the user's g function every time it is called.
+ *
+ * A CVRootFn should return 0 if successful or a non-zero value
+ * if an error occured (in which case the integration will be halted).
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVRootFn)(realtype t, N_Vector y, realtype *gout, void *user_data);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVEwtFn
+ * -----------------------------------------------------------------
+ * A function e, which sets the error weight vector ewt, must have
+ * type CVEwtFn.
+ * The function e takes as input the current dependent variable y.
+ * It must set the vector of error weights used in the WRMS norm:
+ * 
+ *   ||y||_WRMS = sqrt [ 1/N * sum ( ewt_i * y_i)^2 ]
+ *
+ * Typically, the vector ewt has components:
+ * 
+ *   ewt_i = 1 / (reltol * |y_i| + abstol_i)
+ *
+ * The user_data parameter is the same as that passed by the user
+ * to the CVodeSetUserData routine.  This user-supplied pointer is
+ * passed to the user's e function every time it is called.
+ * A CVEwtFn e must return 0 if the error weight vector has been
+ * successfuly set and a non-zero value otherwise.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVEwtFn)(N_Vector y, N_Vector ewt, void *user_data);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVErrHandlerFn
+ * -----------------------------------------------------------------
+ * A function eh, which handles error messages, must have type
+ * CVErrHandlerFn.
+ * The function eh takes as input the error code, the name of the
+ * module reporting the error, the error message, and a pointer to
+ * user data, the same as that passed to CVodeSetUserData.
+ * 
+ * All error codes are negative, except CV_WARNING which indicates 
+ * a warning (the solver continues).
+ *
+ * A CVErrHandlerFn has no return value.
+ * -----------------------------------------------------------------
+ */
+  
+typedef void (*CVErrHandlerFn)(int error_code, 
+			       const char *module, const char *function, 
+			       char *msg, void *user_data); 
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVQuadRhsFn
+ * -----------------------------------------------------------------
+ * The fQ function which defines the right hand side of the
+ * quadrature equations yQ' = fQ(t,y) must have type CVQuadRhsFn.
+ * fQ takes as input the value of the independent variable t,
+ * the vector of states y and must store the result of fQ in
+ * yQdot. (Allocation of memory for yQdot is handled by CVODES).
+ * The user_data parameter is the same as the user_data parameter
+ * set by the user through the CVodeSetUserData routine and is
+ * passed to the fQ function every time it is called.
+ *
+ * If the quadrature RHS also depends on the sensitivity variables,
+ * i.e., yQ' = fQs(t,y,yS), then fQ must be of type CVodeQuadRhsFnS.
+ *
+ * A CVQuadRhsFn or CVodeQuadRhsFnS should return 0 if successful,
+ * a negative value if an unrecoverable error occured, and a positive
+ * value if a recoverable error (e.g. invalid y values) occured. 
+ * If an unrecoverable occured, the integration is halted. 
+ * If a recoverable error occured, then (in most cases) CVODES
+ * will try to correct and retry.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVQuadRhsFn)(realtype t, N_Vector y,
+                           N_Vector yQdot,
+			   void *user_data);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVSensRhsFn
+ * -----------------------------------------------------------------
+ * The fS function which defines the right hand side of the
+ * sensitivity ODE systems s' = f_y * s + f_p must have type
+ * CVSensRhsFn.
+ * fS takes as input the number of sensitivities Ns, the
+ * independent variable value t, the states y and the
+ * corresponding value of f(t,y) in ydot, and the dependent
+ * sensitivity vectors yS. It stores the result of fS in ySdot.
+ * (Allocation of memory for ySdot is handled within CVODES)
+ * The user_data parameter is the same as the user_data parameter
+ * set by the user through the CVodeSetUserData routine and is
+ * passed to the fS function every time it is called.
+ *
+ * A CVSensRhsFn should return 0 if successful, a negative value if
+ * an unrecoverable error occured, and a positive value if a 
+ * recoverable error (e.g. invalid y or yS values) occured. 
+ * If an unrecoverable occured, the integration is halted. 
+ * If a recoverable error occured, then (in most cases) CVODES
+ * will try to correct and retry.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSensRhsFn)(int Ns, realtype t,
+			   N_Vector y, N_Vector ydot,
+			   N_Vector *yS, N_Vector *ySdot,
+			   void *user_data,
+			   N_Vector tmp1, N_Vector tmp2);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVSensRhs1Fn
+ * -----------------------------------------------------------------
+ * The fS1 function which defines the right hand side of the i-th
+ * sensitivity ODE system s_i' = f_y * s_i + f_p must have type
+ * CVSensRhs1Fn.
+ * fS1 takes as input the number of sensitivities Ns, the current
+ * sensitivity iS, the independent variable value t, the states y
+ * and the corresponding value of f(t,y) in ydot, and the
+ * dependent sensitivity vector yS. It stores the result of fS in
+ * ySdot.
+ * (Allocation of memory for ySdot is handled within CVODES)
+ * The user_data parameter is the same as the user_data parameter
+ * set by the user through the CVodeSetUserData routine and is
+ * passed to the fS1 function every time it is called.
+ *
+ * A CVSensRhs1Fn should return 0 if successful, a negative value if
+ * an unrecoverable error occured, and a positive value if a 
+ * recoverable error (e.g. invalid y or yS values) occured. 
+ * If an unrecoverable occured, the integration is halted. 
+ * If a recoverable error occured, then (in most cases) CVODES
+ * will try to correct and retry.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSensRhs1Fn)(int Ns, realtype t,
+			    N_Vector y, N_Vector ydot,
+			    int iS, N_Vector yS, N_Vector ySdot,
+			    void *user_data,
+			    N_Vector tmp1, N_Vector tmp2);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVQuadSensRhsFn
+ * -----------------------------------------------------------------
+ * The fQS function which defines the right hand side of the
+ * sensitivity ODE systems for quadratures, yQS' = fQ_y * yS + fQ_p
+ * must have type CVQuadSensRhsFn.
+ *
+ * fQS takes as input the number of sensitivities Ns (the same as
+ * that passed to CVodeQuadSensInit), the independent variable 
+ * value t, the states y and the dependent sensitivity vectors yS,
+ * as well as the current value of the quadrature RHS yQdot.
+ * It stores the result of fQS in yQSdot.
+ * (Allocation of memory for yQSdot is handled within CVODES)
+ *
+ * A CVQuadSensRhsFn should return 0 if successful, a negative
+ * value if an unrecoverable error occured, and a positive value
+ * if a recoverable error (e.g. invalid y or yS values) occured. 
+ * If an unrecoverable occured, the integration is halted. 
+ * If a recoverable error occured, then (in most cases) CVODES
+ * will try to correct and retry.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVQuadSensRhsFn)(int Ns, realtype t,
+                               N_Vector y, N_Vector *yS, 
+                               N_Vector yQdot, N_Vector *yQSdot,
+                               void *user_data,
+                               N_Vector tmp, N_Vector tmpQ);
+
+/*
+ * -----------------------------------------------------------------
+ * CVRhsFnB and CVRhsFnBS
+ *    The fB function which defines the right hand side of the
+ *    ODE systems to be integrated backwards must have type CVRhsFnB.
+ *    If the backward problem depends on forward sensitivities, its
+ *    RHS function must have type CVRhsFnBS.
+ * -----------------------------------------------------------------
+ * CVQuadRhsFnB and CVQuadRhsFnBS
+ *    The fQB function which defines the quadratures to be integrated
+ *    backwards must have type CVQuadRhsFnB.
+ *    If the backward problem depends on forward sensitivities, its
+ *    quadrature RHS function must have type CVQuadRhsFnBS.
+ * -----------------------------------------------------------------
+ */
+  
+typedef int (*CVRhsFnB)(realtype t, N_Vector y,
+			N_Vector yB, N_Vector yBdot,
+			void *user_dataB);
+
+typedef int (*CVRhsFnBS)(realtype t, N_Vector y, N_Vector *yS,
+                         N_Vector yB, N_Vector yBdot,
+                         void *user_dataB);
+
+  
+typedef int (*CVQuadRhsFnB)(realtype t, N_Vector y,
+			    N_Vector yB, N_Vector qBdot,
+			    void *user_dataB);
+
+typedef int (*CVQuadRhsFnBS)(realtype t, N_Vector y, N_Vector *yS,
+                             N_Vector yB, N_Vector qBdot,
+                             void *user_dataB);
+
+
+/*
+ * =================================================================
+ *
+ * INITIALIZATION AND DEALLOCATION FUNCTIONS FOR FORWARD PROBLEMS 
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeCreate
+ * -----------------------------------------------------------------
+ * CVodeCreate creates an internal memory block for a problem to
+ * be solved by CVODES.
+ *
+ * lmm  is the type of linear multistep method to be used.
+ *      The legal values are CV_ADAMS and CV_BDF (see previous
+ *      description).
+ *
+ * iter  is the type of iteration used to solve the nonlinear
+ *       system that arises during each internal time step.
+ *       The legal values are CV_FUNCTIONAL and CV_NEWTON.
+ *
+ * If successful, CVodeCreate returns a pointer to initialized
+ * problem memory. This pointer should be passed to CVodeInit.
+ * If an initialization error occurs, CVodeCreate prints an error
+ * message to standard err and returns NULL.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void *CVodeCreate(int lmm, int iter);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : CVodeInit and CVodeReInit
+ * -----------------------------------------------------------------
+ * CVodeInit allocates and initializes memory for a problem to
+ * to be solved by CVODE.
+ *
+ * CVodeReInit re-initializes CVode for the solution of a problem,
+ * where a prior call to CVodeInit has been made with the same
+ * problem size N. CVodeReInit performs the same input checking
+ * and initializations that CVodeInit does.
+ * But it does no memory allocation, assuming that the existing
+ * internal memory is sufficient for the new problem.
+ *
+ * The use of CVodeReInit requires that the maximum method order,
+ * maxord, is no larger for the new problem than for the problem
+ * specified in the last call to CVodeInit.  This condition is
+ * automatically fulfilled if the multistep method parameter lmm
+ * is unchanged (or changed from CV_ADAMS to CV_BDF) and the default
+ * value for maxord is specified.
+ *
+ * cvode_mem is pointer to CVODE memory returned by CVodeCreate.
+ *
+ * f       is the name of the C function defining the right-hand
+ *         side function in y' = f(t,y).
+ *
+ * t0      is the initial value of t.
+ *
+ * y0      is the initial condition vector y(t0).
+ *
+ * Return flag:
+ *  CV_SUCCESS   if successful
+ *  CV_MEM_NULL  if the cvode memory was NULL
+ *  CV_MEM_FAIL  if a memory allocation failed
+ *  CV_NO_MALLOC if cvode_mem has not been allocated
+ *               (i.e., CVodeInit has not been called).
+ *  CV_ILL_INPUT if an argument has an illegal value.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, N_Vector y0);
+SUNDIALS_EXPORT int CVodeReInit(void *cvode_mem, realtype t0, N_Vector y0);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : CVodeSStolerances
+ *             CVodeSVtolerances
+ *             CVodeWFtolerances
+ * -----------------------------------------------------------------
+ *
+ * These functions specify the integration tolerances. One of them
+ * MUST be called before the first call to CVode.
+ *
+ * CVodeSStolerances specifies scalar relative and absolute tolerances.
+ * CVodeSVtolerances specifies scalar relative tolerance and a vector
+ *   absolute tolerance (a potentially different absolute tolerance 
+ *   for each vector component).
+ * CVodeWFtolerances specifies a user-provides function (of type CVEwtFn)
+ *   which will be called to set the error weight vector.
+ *
+ * The tolerances reltol and abstol define a vector of error weights,
+ * ewt, with components
+ *   ewt[i] = 1/(reltol*abs(y[i]) + abstol)      (in the SS case), or
+ *   ewt[i] = 1/(reltol*abs(y[i]) + abstol[i])   (in the SV case).
+ * This vector is used in all error and convergence tests, which
+ * use a weighted RMS norm on all error-like vectors v:
+ *    WRMSnorm(v) = sqrt( (1/N) sum(i=1..N) (v[i]*ewt[i])^2 ),
+ * where N is the problem dimension.
+ *
+ * The return value of these functions is equal to CV_SUCCESS = 0 if
+ * there were no errors; otherwise it is a negative int equal to:
+ *   CV_MEM_NULL      indicating cvode_mem was NULL (i.e.,
+ *                    CVodeCreate has not been called).
+ *   CV_NO_MALLOC     indicating that cvode_mem has not been
+ *                    allocated (i.e., CVodeInit has not been
+ *                    called).
+ *   CV_ILL_INPUT     indicating an input argument was illegal
+ *                    (e.g. a negative tolerance)
+ * In case of an error return, an error message is also printed.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSStolerances(void *cvode_mem, realtype reltol, realtype abstol);
+SUNDIALS_EXPORT int CVodeSVtolerances(void *cvode_mem, realtype reltol, N_Vector abstol);
+SUNDIALS_EXPORT int CVodeWFtolerances(void *cvode_mem, CVEwtFn efun);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeQuadInit and CVodeQuadReInit
+ * -----------------------------------------------------------------
+ * CVodeQuadInit allocates and initializes memory related to
+ * quadrature integration.
+ *
+ * CVodeQuadReInit re-initializes CVODES's quadrature related
+ * memory for a problem, assuming it has already been allocated
+ * in prior calls to CVodeInit and CVodeQuadInit.
+ * The number of quadratures Nq is assumed to be unchanged
+ * since the previous call to CVodeQuadInit.
+ *
+ * cvode_mem is a pointer to CVODES memory returned by CVodeCreate
+ *
+ * fQ    is the user-provided integrand routine.
+ *
+ * yQ0   is an N_Vector with initial values for quadratures
+ *       (typically yQ0 has all zero components).
+ *
+ * Return values:
+ *  CV_SUCCESS if successful
+ *  CV_MEM_NULL if the cvode memory was NULL
+ *  CV_MEM_FAIL if a memory allocation failed
+ *  CV_NO_QUAD  if quadratures were not initialized
+ *              (i.e. CVodeQuadInit has not been called)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeQuadInit(void *cvode_mem, CVQuadRhsFn fQ, N_Vector yQ0);
+SUNDIALS_EXPORT int CVodeQuadReInit(void *cvode_mem, N_Vector yQ0);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : CVodeQuadSStolerances
+ *             CVodeQuadSVtolerances
+ * -----------------------------------------------------------------
+ *
+ * These functions specify the integration tolerances for quadrature
+ * variables. One of them MUST be called before the first call to
+ * CVode IF error control on the quadrature variables is enabled
+ * (see CVodeSetQuadErrCon).
+ *
+ * CVodeSStolerances specifies scalar relative and absolute tolerances.
+ * CVodeSVtolerances specifies scalar relative tolerance and a vector
+ *   absolute tolerance (a potentially different absolute tolerance 
+ *   for each vector component).
+ *
+ * Return values:
+ *  CV_SUCCESS    if successful
+ *  CV_MEM_NULL   if the cvode memory was NULL
+ *  CV_NO_QUAD    if quadratures were not initialized
+ *  CV_ILL_INPUT  if an input argument was illegal
+ *                (e.g. a negative tolerance)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeQuadSStolerances(void *cvode_mem, realtype reltolQ, realtype abstolQ);
+SUNDIALS_EXPORT int CVodeQuadSVtolerances(void *cvode_mem, realtype reltolQ, N_Vector abstolQ);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeSensInit, CVSensInit1, and CVodeSensReInit
+ * -----------------------------------------------------------------
+ * CVodeSensInit and CVSensInit1 allocate and initialize memory
+ * related to sensitivity computations. They only differ in the 
+ * type of the sensitivity RHS function: CVodeSensInit specifies
+ * fS of type CVSensRhsFn (i.e. a function that evaluates all
+ * sensitivity RHS simultaneously), while CVodeSensInit1 specifies
+ * fS of type CVSensRhs1Fn (i.e. a function that evaluates one
+ * sensitivity RHS at a time). Recall that ism=CV_STAGGERED1 is 
+ * compatible ONLY with a CVSensRhs1Fn. As such, this value for
+ * ism cannot be passed to CVodeSensInit.
+ *
+ * CVodeSensReInit re-initializes CVODES's sensitivity related
+ * memory for a problem, assuming it has already been allocated
+ * in prior calls to CVodeInit and CVodeSensInit.
+ * The number of sensitivities Ns is assumed to be unchanged
+ * since the previous call to CVodeSensInit.
+ * If any error occurs during initialization, it is reported to
+ * the file whose file pointer is errfp.
+ * CVodeSensReInit potentially does some minimal memory allocation
+ * (for the sensitivity absolute tolerance and for arrays of
+ * counters used by the CV_STAGGERED1 method).
+
+ * cvode_mem is pointer to CVODES memory returned by CVodeCreate
+ *
+ * Ns        is the number of sensitivities to be computed.
+ *
+ * ism       is the type of corrector used in sensitivity
+ *           analysis. The legal values are: CV_SIMULTANEOUS,
+ *           CV_STAGGERED, and CV_STAGGERED1.
+ *
+ * fS        is the sensitivity righ-hand side function
+ *           (pass NULL to use the internal DQ approximation)
+ *
+ * yS0       is the array of initial condition vectors for
+ *           sensitivity variables.
+ *
+ * Return values:
+ *   CV_SUCCESS
+ *   CV_MEM_NULL
+ *   CV_ILL_INPUT
+ *   CV_MEM_FAIL
+ *   CV_NO_SENS
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSensInit(void *cvode_mem, int Ns, int ism,
+                                  CVSensRhsFn fS, N_Vector *yS0);
+SUNDIALS_EXPORT int CVodeSensInit1(void *cvode_mem, int Ns, int ism,
+                                   CVSensRhs1Fn fS1, N_Vector *yS0);
+SUNDIALS_EXPORT int CVodeSensReInit(void *cvode_mem, int ism, N_Vector *yS0);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : CVodeSensSStolerances
+ *             CVodeSensSVtolerances
+ *             CVodeSensEEtolerances
+ * -----------------------------------------------------------------
+ *
+ * These functions specify the integration tolerances for sensitivity
+ * variables. One of them MUST be called before the first call to CVode.
+ *
+ * CVodeSensSStolerances specifies scalar relative and absolute tolerances.
+ * CVodeSensSVtolerances specifies scalar relative tolerance and a vector
+ *   absolute tolerance for each sensitivity vector (a potentially different
+ *   absolute tolerance for each vector component).
+ * CVodeSensEEtolerances specifies that tolerances for sensitivity variables
+ *   should be estimated from those provided for the state variables.
+ *
+ * The return value is equal to CV_SUCCESS = 0 if there were no
+ * errors; otherwise it is a negative int equal to:
+ *   CV_MEM_NULL  indicating cvode_mem was NULL, or
+ *   CV_NO_SENS   indicating there was not a prior call to
+ *                CVodeSensInit.
+ *   CV_ILL_INPUT indicating an input argument was illegal
+ *                (e.g. negative tolerances)
+ * In case of an error return, an error message is also printed.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSensSStolerances(void *cvode_mem, realtype reltolS, realtype *abstolS);
+SUNDIALS_EXPORT int CVodeSensSVtolerances(void *cvode_mem, realtype reltolS, N_Vector *abstolS);
+SUNDIALS_EXPORT int CVodeSensEEtolerances(void *cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeQuadSensInit and CVodeQuadSensReInit
+ * -----------------------------------------------------------------
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeQuadSensInit(void *cvode_mem, CVQuadSensRhsFn fQS, N_Vector *yQS0);
+SUNDIALS_EXPORT int CVodeQuadSensReInit(void *cvode_mem, N_Vector *yQS0);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : CVodeQuadSensSStolerances
+ *             CVodeQuadSensSVtolerances
+ *             CVodeQuadSensEEtolerances
+ * -----------------------------------------------------------------
+ *
+ * These functions specify the integration tolerances for quadrature
+ * sensitivity variables. One of them MUST be called before the first
+ * call to CVode IF these variables are included in the error test.
+ *
+ * CVodeQuadSensSStolerances specifies scalar relative and absolute tolerances.
+ * CVodeQuadSensSVtolerances specifies scalar relative tolerance and a vector
+ *   absolute tolerance for each quadrature sensitivity vector (a potentially
+ *   different absolute tolerance for each vector component).
+ * CVodeQuadSensEEtolerances specifies that tolerances for sensitivity variables
+ *   should be estimated from those provided for the quadrature variables.
+ *   In this case, tolerances for the quadrature variables must be
+ *   specified through a call to one of CVodeQuad**tolerances.
+ *
+ * The return value is equal to CV_SUCCESS = 0 if there were no
+ * errors; otherwise it is a negative int equal to:
+ *   CV_MEM_NULL     if cvode_mem was NULL, or
+ *   CV_NO_QuadSENS  if there was not a prior call to
+ *                   CVodeQuadSensInit.
+ *   CV_ILL_INPUT    if an input argument was illegal
+ *                   (e.g. negative tolerances)
+ * In case of an error return, an error message is also printed.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeQuadSensSStolerances(void *cvode_mem, realtype reltolQS, realtype *abstolQS);
+SUNDIALS_EXPORT int CVodeQuadSensSVtolerances(void *cvode_mem, realtype reltolQS, N_Vector *abstolQS);
+SUNDIALS_EXPORT int CVodeQuadSensEEtolerances(void *cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeRootInit
+ * -----------------------------------------------------------------
+ * CVodeRootInit initializes a rootfinding problem to be solved
+ * during the integration of the ODE system.  It must be called
+ * after CVodeCreate, and before CVode.  The arguments are:
+ *
+ * cvode_mem = pointer to CVODE memory returned by CVodeCreate.
+ *
+ * nrtfn     = number of functions g_i, an int >= 0.
+ *
+ * g         = name of user-supplied function, of type CVRootFn,
+ *             defining the functions g_i whose roots are sought.
+ *
+ * If a new problem is to be solved with a call to CVodeReInit,
+ * where the new problem has no root functions but the prior one
+ * did, then call CVodeRootInit with nrtfn = 0.
+ *
+ * The return value of CVodeRootInit is CV_SUCCESS = 0 if there were
+ * no errors; otherwise it is a negative int equal to:
+ *   CV_MEM_NULL    indicating cvode_mem was NULL, or
+ *   CV_MEM_FAIL    indicating a memory allocation failed.
+ *                  (including an attempt to increase maxord).
+ *   CV_ILL_INPUT   indicating nrtfn > 0 but g = NULL.
+ * In case of an error return, an error message is also printed.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeFree
+ * -----------------------------------------------------------------
+ * CVodeFree frees the problem memory cvode_mem allocated by
+ * CVodeInit.  Its only argument is the pointer cvode_mem
+ * returned by CVodeCreate.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void CVodeFree(void **cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeQuadFree
+ * -----------------------------------------------------------------
+ * CVodeQuadFree frees the problem memory in cvode_mem allocated
+ * for quadrature integration. Its only argument is the pointer
+ * cvode_mem returned by CVodeCreate.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void CVodeQuadFree(void *cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeSensFree
+ * -----------------------------------------------------------------
+ * CVodeSensFree frees the problem memory in cvode_mem allocated
+ * for sensitivity analysis. Its only argument is the pointer
+ * cvode_mem returned by CVodeCreate.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void CVodeSensFree(void *cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeQuadSensFree
+ * -----------------------------------------------------------------
+ * CVodeQuadSensFree frees the problem memory in cvode_mem allocated
+ * for quadrature sensitivity analysis. Its only argument is the
+ * pointer cvode_mem returned by CVodeCreate.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void CVodeQuadSensFree(void *cvode_mem);
+
+/*
+ * =================================================================
+ *
+ * OPTIONAL INPUT FUNCTIONS FOR FORWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Integrator optional input specification functions
+ * -----------------------------------------------------------------
+ * The following functions can be called to set optional inputs
+ * to values other than the defaults given below:
+ *
+ * Function                |  Optional input / [ default value ]
+ * -----------------------------------------------------------------
+ *                         |
+ * CVodeSetErrHandlerFn    | user-provided ErrHandler function.
+ *                         | [internal]
+ *                         |
+ * CVodeSetErrFile         | the file pointer for an error file
+ *                         | where all CVODE warning and error
+ *                         | messages will be written if the default
+ *                         | internal error handling function is used. 
+ *                         | This parameter can be stdout (standard 
+ *                         | output), stderr (standard error), or a 
+ *                         | file pointer (corresponding to a user 
+ *                         | error file opened for writing) returned 
+ *                         | by fopen.
+ *                         | If not called, then all messages will
+ *                         | be written to the standard error stream.
+ *                         | [stderr]
+ *                         |
+ * CVodeSetUserData        | a pointer to user data that will be
+ *                         | passed to the user's f function every
+ *                         | time f is called.
+ *                         | [NULL]
+ *                         |
+ * CVodeSetMaxOrd          | maximum lmm order to be used by the
+ *                         | solver.
+ *                         | [12 for Adams , 5 for BDF]
+ *                         |
+ * CVodeSetMaxNumSteps     | maximum number of internal steps to be
+ *                         | taken by the solver in its attempt to
+ *                         | reach tout.
+ *                         | [500]
+ *                         |
+ * CVodeSetMaxHnilWarns    | maximum number of warning messages
+ *                         | issued by the solver that t+h==t on the
+ *                         | next internal step. A value of -1 means
+ *                         | no such messages are issued.
+ *                         | [10]
+ *                         |
+ * CVodeSetStabLimDet      | flag to turn on/off stability limit
+ *                         | detection (SUNTRUE = on, SUNFALSE = off).
+ *                         | When BDF is used and order is 3 or
+ *                         | greater, CVsldet is called to detect
+ *                         | stability limit.  If limit is detected,
+ *                         | the order is reduced.
+ *                         | [SUNFALSE]
+ *                         |
+ * CVodeSetInitStep        | initial step size.
+ *                         | [estimated by CVODES]
+ *                         |
+ * CVodeSetMinStep         | minimum absolute value of step size
+ *                         | allowed.
+ *                         | [0.0]
+ *                         |
+ * CVodeSetMaxStep         | maximum absolute value of step size
+ *                         | allowed.
+ *                         | [infinity]
+ *                         |
+ * CVodeSetStopTime        | the independent variable value past
+ *                         | which the solution is not to proceed.
+ *                         | [infinity]
+ *                         |
+ * CVodeSetMaxErrTestFails | Maximum number of error test failures
+ *                         | in attempting one step.
+ *                         | [7]
+ *                         |
+ * CVodeSetMaxNonlinIters  | Maximum number of nonlinear solver
+ *                         | iterations at one solution.
+ *                         | [3]
+ *                         |
+ * CVodeSetMaxConvFails    | Maximum number of allowable conv.
+ *                         | failures in attempting one step.
+ *                         | [10]
+ *                         |
+ * CVodeSetNonlinConvCoef  | Coeficient in the nonlinear conv.
+ *                         | test.
+ *                         | [0.1]
+ *                         |
+ * CVodeSetConstraints     | an N_vector defining inequality
+ *                         | constraints for each component of the
+ *                         | solution vector y. If a given element
+ *                         | of this vector has values +2 or -2,
+ *                         | then the corresponding component of y
+ *                         | will be constrained to be > 0.0 or
+ *                         | < 0.0, respectively, while if it is +1
+ *                         | or -1, the y component is constrained
+ *                         | to be >= 0.0 or <= 0.0, respectively.
+ *                         | If a component of constraints is 0.0,
+ *                         | then no constraint is imposed on the
+ *                         | corresponding component of y.
+ *                         | The presence of a non-NULL constraints
+ *                         | vector that is not 0.0 (ZERO) in all
+ *                         | components will cause constraint
+ *                         | checking to be performed.
+ *                         |
+ * -----------------------------------------------------------------
+ *                         |
+ * CVodeSetIterType        | Changes the current nonlinear iteration
+ *                         | type.
+ *                         | [set by CVodecreate]
+ *                         |
+ * -----------------------------------------------------------------
+ *                            |
+ * CVodeSetRootDirection      | Specifies the direction of zero
+ *                            | crossings to be monitored
+ *                            | [both directions]
+ *                            |
+ * CVodeSetNoInactiveRootWarn | disable warning about possible
+ *                            | g==0 at beginning of integration
+ *                            | 
+ * -----------------------------------------------------------------
+ * Return flag:
+ *   CV_SUCCESS   if successful
+ *   CV_MEM_NULL  if the cvode memory is NULL
+ *   CV_ILL_INPUT if an argument has an illegal value
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun, void *eh_data);
+SUNDIALS_EXPORT int CVodeSetErrFile(void *cvode_mem, FILE *errfp);
+SUNDIALS_EXPORT int CVodeSetUserData(void *cvode_mem, void *user_data);
+SUNDIALS_EXPORT int CVodeSetMaxOrd(void *cvode_mem, int maxord);
+SUNDIALS_EXPORT int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps);
+SUNDIALS_EXPORT int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil);
+SUNDIALS_EXPORT int CVodeSetStabLimDet(void *cvode_mem, booleantype stldet);
+SUNDIALS_EXPORT int CVodeSetInitStep(void *cvode_mem, realtype hin);
+SUNDIALS_EXPORT int CVodeSetMinStep(void *cvode_mem, realtype hmin);
+SUNDIALS_EXPORT int CVodeSetMaxStep(void *cvode_mem, realtype hmax);
+SUNDIALS_EXPORT int CVodeSetStopTime(void *cvode_mem, realtype tstop);
+SUNDIALS_EXPORT int CVodeSetMaxErrTestFails(void *cvode_mem, int maxnef);
+SUNDIALS_EXPORT int CVodeSetMaxNonlinIters(void *cvode_mem, int maxcor);
+SUNDIALS_EXPORT int CVodeSetMaxConvFails(void *cvode_mem, int maxncf);
+SUNDIALS_EXPORT int CVodeSetNonlinConvCoef(void *cvode_mem, realtype nlscoef);
+SUNDIALS_EXPORT int CVodeSetConstraints(void *cvode_mem, N_Vector constraints);
+
+SUNDIALS_EXPORT int CVodeSetIterType(void *cvode_mem, int iter);
+
+SUNDIALS_EXPORT int CVodeSetRootDirection(void *cvode_mem, int *rootdir);
+SUNDIALS_EXPORT int CVodeSetNoInactiveRootWarn(void *cvode_mem);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Quadrature optional input specification functions
+ * -----------------------------------------------------------------
+ * The following functions can be called to set optional inputs
+ * to values other than the defaults given below:
+ *
+ * Function             |  Optional input / [ default value ]
+ * --------------------------------------------------------------
+ *                      |
+ * CVodeSetQuadErrCon   | are quadrature variables considered in
+ *                      | the error control?
+ *                      | If yes, tolerances for quadrature are
+ *                      | required (see CVodeQuad**tolerances) 
+ *                      | [errconQ = SUNFALSE]
+ *                      |
+ * -----------------------------------------------------------------
+ * If successful, these functions return CV_SUCCESS. If an argument
+ * has an illegal value, they return one of the error flags
+ * defined for the CVodeSet* routines.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSetQuadErrCon(void *cvode_mem, booleantype errconQ); 
+
+/*
+ * -----------------------------------------------------------------
+ * Forward sensitivity optional input specification functions
+ * -----------------------------------------------------------------
+ * The following functions can be called to set optional inputs
+ * to other values than the defaults given below:
+ *
+ * Function                   |  Optional input / [ default value ]
+ * -----------------------------------------------------------------
+ *                            |
+ * CVodeSetSensDQMethod       | controls the selection of finite
+ *                            | difference schemes used in evaluating
+ *                            | the sensitivity right hand sides:
+ *                            | (centered vs. forward and 
+ *                            | simultaneous vs. separate)
+ *                            | [DQtype=CV_CENTERED]
+ *                            | [DQrhomax=0.0]
+ *                            |
+ * CVodeSetSensParams         | parameter information:
+ *                            | p: pointer to problem parameters
+ *                            | plist: list of parameters with respect
+ *                            |        to which sensitivities are to be
+ *                            |        computed.
+ *                            | pbar: order of magnitude info. 
+ *                            |       Typically, if p[plist[i]] is nonzero, 
+ *                            |       pbar[i]=p[plist[i]].
+ *                            | [p=NULL]
+ *                            | [plist=NULL]
+ *                            | [pbar=NULL]
+ *                            |
+ * CVodeSetSensErrCon         | are sensitivity variables considered in
+ *                            | the error control?
+ *                            | [SUNFALSE]
+ *                            |
+ * CVodeSetSensMaxNonlinIters | Maximum number of nonlinear solver
+ *                            | iterations at one solution.
+ *                            | [3]
+ *                            |
+ * -----------------------------------------------------------------
+ * The return values are the same as for CVodeSet*
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSetSensDQMethod(void *cvode_mem, int DQtype, realtype DQrhomax);
+SUNDIALS_EXPORT int CVodeSetSensErrCon(void *cvode_mem, booleantype errconS);
+SUNDIALS_EXPORT int CVodeSetSensMaxNonlinIters(void *cvode_mem, int maxcorS);
+SUNDIALS_EXPORT int CVodeSetSensParams(void *cvode_mem, realtype *p, realtype *pbar, int *plist);
+
+/*
+ * -----------------------------------------------------------------
+ * Quadrature sensitivity optional input specification functions
+ * -----------------------------------------------------------------
+ * The following functions can be called to set optional inputs
+ * to values other than the defaults given below:
+ *
+ * Function               |  Optional input / [ default value ]
+ * --------------------------------------------------------------
+ *                        |
+ * CVodeSetQuadSensErrCon | are quadrature sensitivity variables
+ *                        | considered in the error control?
+ *                        | If yes, tolerances for quadrature
+ *                        | sensitivity variables are required.
+ *                        | [errconQS = SUNFALSE]
+ *                        |
+ * -----------------------------------------------------------------
+ * If successful, these functions return CV_SUCCESS. If an argument
+ * has an illegal value, they return one of the error flags
+ * defined for the CVodeSet* routines.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSetQuadSensErrCon(void *cvode_mem, booleantype errconQS); 
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeSensToggleOff
+ * -----------------------------------------------------------------
+ * CVodeSensToggleOff deactivates sensitivity calculations.
+ * It does NOT deallocate sensitivity-related memory so that 
+ * sensitivity computations can be later toggled ON (through
+ * CVodeSensReInit).
+ * 
+ * The return value is equal to CV_SUCCESS = 0 if there were no
+ * errors or CV_MEM_NULL if cvode_mem was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSensToggleOff(void *cvode_mem);
+
+
+/*
+ * =================================================================
+ *
+ * MAIN SOLVER FUNCTION FOR FORWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVode
+ * -----------------------------------------------------------------
+ * CVode integrates the ODE over an interval in t.
+ * If itask is CV_NORMAL, then the solver integrates from its
+ * current internal t value to a point at or beyond tout, then
+ * interpolates to t = tout and returns y(tout) in the user-
+ * allocated vector yout. If itask is CV_ONE_STEP, then the solver
+ * takes one internal time step and returns in yout the value of
+ * y at the new internal time. In this case, tout is used only
+ * during the first call to CVode to determine the direction of
+ * integration and the rough scale of the problem. If tstop is
+ * enabled (through a call to CVodeSetStopTime), then CVode returns
+ * the solution at tstop. Once the integrator returns at a tstop
+ * time, any future testing for tstop is disabled (and can be 
+ * reenabled only though a new call to CVodeSetStopTime).
+ * The time reached by the solver is placed in (*tret). The
+ * user is responsible for allocating the memory for this value.
+ *
+ * cvode_mem is the pointer to CVODES memory returned by
+ *           CVodeCreate.
+ *
+ * tout  is the next time at which a computed solution is desired.
+ *
+ * yout  is the computed solution vector. In CV_NORMAL mode with no
+ *       errors and no roots found, yout=y(tout).
+ *
+ * tret  is a pointer to a real location. CVode sets (*tret) to
+ *       the time reached by the solver and returns yout=y(*tret).
+ *
+ * itask is CV_NORMAL or CV_ONE_STEP. These two modes are described above.
+ *
+ * Here is a brief description of each return value:
+ *
+ * CV_SUCCESS:     CVode succeeded and no roots were found.
+ *
+ * CV_ROOT_RETURN: CVode succeeded, and found one or more roots.
+ *                 If nrtfn > 1, call CVodeGetRootInfo to see
+ *                 which g_i were found to have a root at (*tret).
+ *
+ * CV_TSTOP_RETURN: CVode succeded and returned at tstop.
+ *
+ * CV_MEM_NULL:    The cvode_mem argument was NULL.
+ *
+ * CV_NO_MALLOC:   cvode_mem was not allocated.
+ *
+ * CV_ILL_INPUT:   One of the inputs to CVode is illegal. This
+ *                 includes the situation when a component of the
+ *                 error weight vectors becomes < 0 during
+ *                 internal time-stepping. The ILL_INPUT flag
+ *                 will also be returned if the linear solver
+ *                 routine CV--- (called by the user after
+ *                 calling CVodeCreate) failed to set one of the
+ *                 linear solver-related fields in cvode_mem or
+ *                 if the linear solver's init routine failed. In
+ *                 any case, the user should see the printed
+ *                 error message for more details.
+ *
+ * CV_TOO_MUCH_WORK: The solver took mxstep internal steps but
+ *                 could not reach tout. The default value for
+ *                 mxstep is MXSTEP_DEFAULT = 500.
+ *
+ * CV_TOO_MUCH_ACC: The solver could not satisfy the accuracy
+ *                 demanded by the user for some internal step.
+ *
+ * CV_CONSTR_FAIL: The inequality constraints were violated,
+ *                 and the solver was unable to recover.
+ *
+ * CV_ERR_FAILURE: Error test failures occurred too many times
+ *                 (= MXNEF = 7) during one internal time step or
+ *                 occurred with |h| = hmin.
+ *
+ * CV_CONV_FAILURE: Convergence test failures occurred too many
+ *                 times (= MXNCF = 10) during one internal time
+ *                 step or occurred with |h| = hmin.
+ *
+ * CV_LINIT_FAIL:  The linear solver's initialization function 
+ *                 failed.
+ *
+ * CV_LSETUP_FAIL: The linear solver's setup routine failed in an
+ *                 unrecoverable manner.
+ *
+ * CV_LSOLVE_FAIL: The linear solver's solve routine failed in an
+ *                 unrecoverable manner.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVode(void *cvode_mem, realtype tout, N_Vector yout,
+			  realtype *tret, int itask);
+
+
+/*
+ * =================================================================
+ *
+ * EXTRACTION AND DENSE OUTPUT FUNCTIONS FOR FORWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVodeGetDky
+ * -----------------------------------------------------------------
+ * CVodeGetDky computes the kth derivative of the y function at
+ * time t, where tn-hu <= t <= tn, tn denotes the current
+ * internal time reached, and hu is the last internal step size
+ * successfully used by the solver. The user may request
+ * k=0, 1, ..., qu, where qu is the current order. The
+ * derivative vector is returned in dky. This vector must be
+ * allocated by the caller. It is only legal to call this
+ * function after a successful return from CVode.
+ *
+ * cvode_mem is the pointer to CVODES memory returned by
+ *           CVodeCreate.
+ *
+ * t   is the time at which the kth derivative of y is evaluated.
+ *     The legal range for t is [tn-hu,tn] as described above.
+ *
+ * k   is the order of the derivative of y to be computed. The
+ *     legal range for k is [0,qu] as described above.
+ *
+ * dky is the output derivative vector [(D_k)y](t).
+ *
+ * The return values for CVodeGetDky are defined below.
+ * Here is a brief description of each return value:
+ *
+ * CV_SUCCESS: CVodeGetDky succeeded.
+ *
+ * CV_BAD_K : k is not in the range 0, 1, ..., qu.
+ *
+ * CV_BAD_T : t is not in the interval [tn-hu,tn].
+ *
+ * CV_BAD_DKY : The dky argument was NULL.
+ *
+ * CV_MEM_NULL : The cvode_mem argument was NULL.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Quadrature integration solution extraction routines
+ * -----------------------------------------------------------------
+ * The following functions can be called to obtain the quadrature
+ * variables after a successful integration step.
+ * If quadratures were not computed, they return CV_NO_QUAD.
+ *
+ * CVodeGetQuad returns the quadrature variables at the same time
+ *   as that at which CVode returned the solution.
+ *
+ * CVodeGetQuadDky returns the quadrature variables (or their 
+ *   derivatives up to the current method order) at any time within
+ *   the last integration step (dense output). See CVodeGetQuad for
+ *   more information.
+ *
+ * The output vectors yQout and dky must be allocated by the user.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetQuad(void *cvode_mem, realtype *tret, N_Vector yQout);
+
+SUNDIALS_EXPORT int CVodeGetQuadDky(void *cvode_mem, realtype t, int k, N_Vector dky);
+
+/*
+ * -----------------------------------------------------------------
+ * Forward sensitivity solution extraction routines
+ * -----------------------------------------------------------------
+ * The following functions can be called to obtain the sensitivity
+ * variables after a successful integration step.
+ * 
+ * CVodeGetSens and CVodeGetSens1 return all the sensitivity vectors
+ *   or only one of them, respectively, at the same time as that at 
+ *   which CVode returned the solution.
+ *   The array of output vectors or output vector ySout must be
+ *   allocated by the user.
+ *
+ * CVodeGetSensDky1 computes the kth derivative of the is-th
+ *   sensitivity (is=1, 2, ..., Ns) of the y function at time t,
+ *   where tn-hu <= t <= tn, tn denotes the current internal time
+ *   reached, and hu is the last internal step size successfully
+ *   used by the solver. The user may request k=0, 1, ..., qu,
+ *   where qu is the current order.
+ *   The is-th sensitivity derivative vector is returned in dky.
+ *   This vector must be allocated by the caller. It is only legal
+ *   to call this function after a successful return from CVode
+ *   with sensitivty computations enabled.
+ *   Arguments have the same meaning as in CVodeDky.
+ *
+ * CVodeGetSensDky computes the k-th derivative of all
+ *   sensitivities of the y function at time t. It repeatedly calls
+ *   CVodeGetSensDky. The argument dkyA must be a pointer to
+ *   N_Vector and must be allocated by the user to hold at least Ns
+ *   vectors.
+ *
+ * Return values are similar to those of CVodeDky. Additionally,
+ * CVodeSensDky can return CV_NO_SENS if sensitivities were
+ * not computed and CV_BAD_IS if is < 0 or is >= Ns.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetSens(void *cvode_mem, realtype *tret, N_Vector *ySout);
+SUNDIALS_EXPORT int CVodeGetSens1(void *cvode_mem, realtype *tret, int is, N_Vector ySout);
+
+SUNDIALS_EXPORT int CVodeGetSensDky(void *cvode_mem, realtype t, int k, N_Vector *dkyA);
+SUNDIALS_EXPORT int CVodeGetSensDky1(void *cvode_mem, realtype t, int k, int is, N_Vector dky);
+
+/*
+ * -----------------------------------------------------------------
+ * Quadrature sensitivity solution extraction routines
+ * -----------------------------------------------------------------
+ * The following functions can be called to obtain the quadrature
+ * sensitivity variables after a successful integration step.
+ * 
+ * CVodeGetQuadSens and CVodeGetQuadSens1 return all the quadrature
+ *   sensitivity vectors or only one of them, respectively, at the
+ *   same time as that at which CVode returned the solution.
+ *   The array of output vectors or output vector yQSout must be
+ *   allocated by the user.
+ *
+ * CVodeGetQuadSensDky1 computes the kth derivative of the is-th
+ *   quadrature sensitivity (is=1, 2, ..., Ns) at time t, where
+ *   tn-hu <= t <= tn, tn denotes the current internal time 
+ *   reached, and hu is the last internal step size successfully
+ *   used by the solver. The user may request  k=0, 1, ..., qu,
+ *   where qu is the current order.
+ *   The is-th sensitivity derivative vector is returned in dkyQS.
+ *   This vector must be allocated by the caller. It is only legal
+ *   to call this function after a successful return from CVode
+ *   with quadrature sensitivty computations enabled.
+ *   Arguments have the same meaning as in CVodeDky.
+ *
+ * CVodeGetQuadSensDky computes the k-th derivative of all
+ *   quadrature sensitivities at time t. It repeatedly calls
+ *   CVodeGetSensDky. The argument dkyQS_all must be a pointer to
+ *   N_Vector and must be allocated by the user to hold at least Ns
+ *   vectors.
+ *
+ * Return values are similar to those of CVodeDky. Additionally,
+ * CVodeQuadSensDky can return CV_NO_QUADSENS if quadrature
+ * sensitivities were not computed and CV_BAD_IS if is < 0 or is >= Ns.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetQuadSens(void *cvode_mem, realtype *tret, N_Vector *yQSout);
+SUNDIALS_EXPORT int CVodeGetQuadSens1(void *cvode_mem, realtype *tret, int is, N_Vector yQSout);
+
+SUNDIALS_EXPORT int CVodeGetQuadSensDky(void *cvode_mem, realtype t, int k, N_Vector *dkyQS_all);
+SUNDIALS_EXPORT int CVodeGetQuadSensDky1(void *cvode_mem, realtype t, int k, int is, N_Vector dkyQS);
+
+/*
+ * =================================================================
+ *
+ * OPTIONAL OUTPUT FUNCTIONS FOR FORWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Integrator optional output extraction functions
+ * -----------------------------------------------------------------
+ * The following functions can be called to get optional outputs
+ * and statistics related to the main integrator.
+ * -----------------------------------------------------------------
+ * CVodeGetWorkSpace returns the CVODES real and integer workspaces
+ * CVodeGetNumSteps returns the cumulative number of internal
+ *                  steps taken by the solver
+ * CVodeGetNumRhsEvals returns the number of calls to the user's
+ *                  f function
+ * CVodeGetNumLinSolvSetups returns the number of calls made to
+ *                  the linear solver's setup routine
+ * CVodeGetNumErrTestFails returns the number of local error test
+ *                  failures that have occured
+ * CVodeGetLastOrder returns the order used during the last
+ *                  internal step
+ * CVodeGetCurrentOrder returns the order to be used on the next
+ *                  internal step
+ * CVodeGetNumStabLimOrderReds returns the number of order
+ *                  reductions due to stability limit detection
+ * CVodeGetActualInitStep returns the actual initial step size
+ *                  used by CVODES
+ * CVodeGetLastStep returns the step size for the last internal
+ *                  step
+ * CVodeGetCurrentStep returns the step size to be attempted on
+ *                  the next internal step
+ * CVodeGetCurrentTime returns the current internal time reached
+ *                  by the solver
+ * CVodeGetTolScaleFactor returns a suggested factor by which the
+ *                  user's tolerances should be scaled when too
+ *                  much accuracy has been requested for some
+ *                  internal step
+ * CVodeGetErrWeights returns the current error weight vector.
+ *                    The user must allocate space for eweight.
+ * CVodeGetEstLocalErrors returns the vector of estimated local
+ *                  errors. The user must allocate space for ele.
+ * CVodeGetNumGEvals returns the number of calls to the user's
+ *                  g function (for rootfinding)
+ * CVodeGetRootInfo returns the indices for which g_i was found to 
+ *                  have a root. The user must allocate space for 
+ *                  rootsfound. For i = 0 ... nrtfn-1, 
+ *                  rootsfound[i] = 1 if g_i has a root, and = 0 if not.
+ *
+ * CVodeGet* return values:
+ *   CV_SUCCESS   if succesful
+ *   CV_MEM_NULL  if the cvode memory was NULL
+ *   CV_NO_SLDET  if stability limit was not turned on
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetWorkSpace(void *cvode_mem, long int *lenrw, long int *leniw);
+SUNDIALS_EXPORT int CVodeGetNumSteps(void *cvode_mem, long int *nsteps);
+SUNDIALS_EXPORT int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevals);
+SUNDIALS_EXPORT int CVodeGetNumLinSolvSetups(void *cvode_mem, long int *nlinsetups);
+SUNDIALS_EXPORT int CVodeGetNumErrTestFails(void *cvode_mem, long int *netfails);
+SUNDIALS_EXPORT int CVodeGetLastOrder(void *cvode_mem, int *qlast);
+SUNDIALS_EXPORT int CVodeGetCurrentOrder(void *cvode_mem, int *qcur);
+SUNDIALS_EXPORT int CVodeGetNumStabLimOrderReds(void *cvode_mem, long int *nslred);
+SUNDIALS_EXPORT int CVodeGetActualInitStep(void *cvode_mem, realtype *hinused);
+SUNDIALS_EXPORT int CVodeGetLastStep(void *cvode_mem, realtype *hlast);
+SUNDIALS_EXPORT int CVodeGetCurrentStep(void *cvode_mem, realtype *hcur);
+SUNDIALS_EXPORT int CVodeGetCurrentTime(void *cvode_mem, realtype *tcur);
+SUNDIALS_EXPORT int CVodeGetTolScaleFactor(void *cvode_mem, realtype *tolsfac);
+SUNDIALS_EXPORT int CVodeGetErrWeights(void *cvode_mem, N_Vector eweight);
+SUNDIALS_EXPORT int CVodeGetEstLocalErrors(void *cvode_mem, N_Vector ele);
+SUNDIALS_EXPORT int CVodeGetNumGEvals(void *cvode_mem, long int *ngevals);
+SUNDIALS_EXPORT int CVodeGetRootInfo(void *cvode_mem, int *rootsfound);
+
+/*
+ * -----------------------------------------------------------------
+ * As a convenience, the following functions provides the
+ * optional outputs in one group.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetIntegratorStats(void *cvode_mem, long int *nsteps,
+					    long int *nfevals, long int *nlinsetups,
+					    long int *netfails, int *qlast,
+					    int *qcur, realtype *hinused, realtype *hlast,
+					    realtype *hcur, realtype *tcur);
+
+/*
+ * -----------------------------------------------------------------
+ * Nonlinear solver optional output extraction functions
+ * -----------------------------------------------------------------
+ * The following functions can be called to get optional outputs
+ * and statistics related to the nonlinear solver.
+ * -----------------------------------------------------------------
+ * CVodeGetNumNonlinSolvIters returns the number of nonlinear
+ *                            solver iterations performed.
+ * CVodeGetNumNonlinSolvConvFails returns the number of nonlinear
+ *                                convergence failures.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetNumNonlinSolvIters(void *cvode_mem, long int *nniters);
+SUNDIALS_EXPORT int CVodeGetNumNonlinSolvConvFails(void *cvode_mem, long int *nncfails);
+
+/*
+ * -----------------------------------------------------------------
+ * As a convenience, the following function provides the
+ * nonlinear solver optional outputs in a group.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetNonlinSolvStats(void *cvode_mem, long int *nniters,
+					    long int *nncfails);
+
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a CVODES return flag
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT char *CVodeGetReturnFlagName(long int flag);
+
+/*
+ * -----------------------------------------------------------------
+ * Quadrature integration optional output extraction routines
+ * -----------------------------------------------------------------
+ * The following functions can be called to get optional outputs
+ * and statistics related to the integration of quadratures.
+ * -----------------------------------------------------------------
+ * CVodeGetQuadNumRhsEvals returns the number of calls to the
+ *                         user function fQ defining the right hand
+ *                         side of the quadrature variables.
+ * CVodeGetQuadNumErrTestFails returns the number of local error
+ *                             test failures for quadrature variables.
+ * CVodeGetQuadErrWeights returns the vector of error weights for
+ *                        the quadrature variables. The user must
+ *                        allocate space for ewtQ.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetQuadNumRhsEvals(void *cvode_mem, long int *nfQevals);
+SUNDIALS_EXPORT int CVodeGetQuadNumErrTestFails(void *cvode_mem, long int *nQetfails);
+SUNDIALS_EXPORT int CVodeGetQuadErrWeights(void *cvode_mem, N_Vector eQweight);
+
+/*
+ * -----------------------------------------------------------------
+ * As a convenience, the following function provides the above
+ * optional outputs in a group.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetQuadStats(void *cvode_mem, long int *nfQevals,
+				      long int *nQetfails);
+
+/*
+ * -----------------------------------------------------------------
+ * Forward sensitivity optional output extraction routines
+ * -----------------------------------------------------------------
+ * The following functions can be called to get optional outputs
+ * and statistics related to the integration of sensitivities.
+ * -----------------------------------------------------------------
+ * CVodeGetSensNumRhsEvals returns the number of calls to the
+ *   sensitivity right hand side routine.
+ * CVodeGetNumRhsEvalsSens returns the number of calls to the
+ *   user f routine due to finite difference evaluations of the 
+ *   sensitivity equations.
+ * CVodeGetSensNumErrTestFails returns the number of local error
+ *   test failures for sensitivity variables.
+ * CVodeGetSensNumLinSolvSetups returns the number of calls made
+ *   to the linear solver's setup routine due to sensitivity computations.
+ * CVodeGetSensErrWeights returns the sensitivity error weight
+ *   vectors. The user need not allocate space for ewtS.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetSensNumRhsEvals(void *cvode_mem, long int *nfSevals);
+SUNDIALS_EXPORT int CVodeGetNumRhsEvalsSens(void *cvode_mem, long int *nfevalsS);
+SUNDIALS_EXPORT int CVodeGetSensNumErrTestFails(void *cvode_mem, long int *nSetfails);
+SUNDIALS_EXPORT int CVodeGetSensNumLinSolvSetups(void *cvode_mem, long int *nlinsetupsS);
+SUNDIALS_EXPORT int CVodeGetSensErrWeights(void *cvode_mem, N_Vector *eSweight);
+
+/*
+ * -----------------------------------------------------------------
+ * As a convenience, the following function provides the
+ * optional outputs in a group.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetSensStats(void *cvode_mem, long int *nfSevals, long int *nfevalsS,
+				      long int *nSetfails, long int *nlinsetupsS);
+
+/*
+ * -----------------------------------------------------------------
+ * Sensitivity nonlinear solver optional output extraction
+ * -----------------------------------------------------------------
+ * The following functions can be called to get optional outputs
+ * and statistics related to the sensitivity nonlinear solver.
+ * -----------------------------------------------------------------
+ * CVodeGetSensNumNonlinSolvIters returns the total number of
+ *   nonlinear iterations for sensitivity variables.
+ * CVodeGetSensNumNonlinSolvConvFails returns the total number
+ *   of nonlinear convergence failures for sensitivity variables
+ * CVodeGetStgrSensNumNonlinSolvIters returns a vector of Ns
+ *   nonlinear iteration counters for sensitivity variables in 
+ *   the CV_STAGGERED1 method.
+ * CVodeGetStgrSensNumNonlinSolvConvFails returns a vector of Ns
+ *   nonlinear solver convergence failure counters for sensitivity 
+ *   variables in the CV_STAGGERED1 method.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetSensNumNonlinSolvIters(void *cvode_mem, long int *nSniters);
+SUNDIALS_EXPORT int CVodeGetSensNumNonlinSolvConvFails(void *cvode_mem, long int *nSncfails);
+SUNDIALS_EXPORT int CVodeGetStgrSensNumNonlinSolvIters(void *cvode_mem, long int *nSTGR1niters);
+SUNDIALS_EXPORT int CVodeGetStgrSensNumNonlinSolvConvFails(void *cvode_mem, 
+							   long int *nSTGR1ncfails);
+
+/*
+ * -----------------------------------------------------------------
+ * As a convenience, the following function provides the      
+ * optional outputs in groups.                                    
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetSensNonlinSolvStats(void *cvode_mem, long int *nSniters,
+						long int *nSncfails);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Quadrature sensitivity optional output extraction routines
+ * -----------------------------------------------------------------
+ * The following functions can be called to get optional outputs and
+ * statistics related to the integration of quadrature sensitivitiess.
+ * -----------------------------------------------------------------
+ * CVodeGetQuadSensNumRhsEvals returns the number of calls to the
+ *       user function fQS defining the right hand side of the 
+ *       quadrature sensitivity equations.
+ * CVodeGetQuadSensNumErrTestFails returns the number of local error
+ *       test failures for quadrature sensitivity variables.
+ * CVodeGetQuadSensErrWeights returns the vector of error weights
+ *       for the quadrature sensitivity variables. The user must
+ *       allocate space for ewtQS.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetQuadSensNumRhsEvals(void *cvode_mem, long int *nfQSevals);
+SUNDIALS_EXPORT int CVodeGetQuadSensNumErrTestFails(void *cvode_mem, long int *nQSetfails);
+SUNDIALS_EXPORT int CVodeGetQuadSensErrWeights(void *cvode_mem, N_Vector *eQSweight);
+
+/*
+ * -----------------------------------------------------------------
+ * As a convenience, the following function provides the above
+ * optional outputs in a group.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetQuadSensStats(void *cvode_mem,
+                                          long int *nfQSevals,
+                                          long int *nQSetfails);
+
+
+/*
+ * =================================================================
+ *
+ * INITIALIZATION AND DEALLOCATION FUNCTIONS FOR BACKWARD PROBLEMS 
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeAdjInit
+ * -----------------------------------------------------------------
+ * CVodeAdjInit specifies some parameters for ASA, initializes ASA
+ * and allocates space for the adjoint memory structure.
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT int CVodeAdjInit(void *cvode_mem, long int steps, int interp);
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeAdjReInit
+ * -----------------------------------------------------------------
+ * CVodeAdjReInit reinitializes the CVODES memory structure for ASA,
+ * assuming that the number of steps between check points and the
+ * type of interpolation remained unchanged. The list of check points
+ * (and associated memory) is deleted. The list of backward problems
+ * is kept (however, new backward problems can be added to this list
+ * by calling CVodeCreateB). The CVODES memory for the forward and 
+ * backward problems can be reinitialized separately by calling 
+ * CVodeReInit and CVodeReInitB, respectively.
+ * NOTE: if a entirely new list of backward problems is desired,
+ *   then simply free the adjoint memory (by calling CVodeAdjFree)
+ *   and reinitialize ASA with CVodeAdjInit.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeAdjReInit(void *cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeAdjFree
+ * -----------------------------------------------------------------
+ * CVodeAdjFree frees the memory allocated by CVodeAdjInit.
+ * It is typically called by CVodeFree.
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT void CVodeAdjFree(void *cvode_mem);
+  
+
+/*
+ * -----------------------------------------------------------------
+ * Interfaces to CVODES functions for setting-up backward problems.
+ * -----------------------------------------------------------------
+ * CVodeCreateB, 
+ *
+ * CVodeInitB, CVodeInitBS, CVodeReInitB
+ * 
+ * CVodeQuadInitB, CVodeQuadInitBS, CVodeQuadReInitB
+ * 
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeCreateB(void *cvode_mem, int lmmB, int iterB, int *which);
+
+SUNDIALS_EXPORT int CVodeInitB(void *cvode_mem, int which,
+                               CVRhsFnB fB,
+                               realtype tB0, N_Vector yB0);
+SUNDIALS_EXPORT int CVodeInitBS(void *cvode_mem, int which,
+                                CVRhsFnBS fBs,
+                                realtype tB0, N_Vector yB0);
+SUNDIALS_EXPORT int CVodeReInitB(void *cvode_mem, int which,
+				 realtype tB0, N_Vector yB0);
+
+SUNDIALS_EXPORT int CVodeSStolerancesB(void *cvode_mem, int which,
+                                       realtype reltolB, realtype abstolB);
+SUNDIALS_EXPORT int CVodeSVtolerancesB(void *cvode_mem, int which,
+                                       realtype reltolB, N_Vector abstolB);
+
+SUNDIALS_EXPORT int CVodeQuadInitB(void *cvode_mem, int which,
+                                     CVQuadRhsFnB fQB, N_Vector yQB0);
+SUNDIALS_EXPORT int CVodeQuadInitBS(void *cvode_mem, int which,
+                                      CVQuadRhsFnBS fQBs, N_Vector yQB0);
+SUNDIALS_EXPORT int CVodeQuadReInitB(void *cvode_mem, int which, N_Vector yQB0);
+
+SUNDIALS_EXPORT int CVodeQuadSStolerancesB(void *cvode_mem, int which,
+                                           realtype reltolQB, realtype abstolQB);
+SUNDIALS_EXPORT int CVodeQuadSVtolerancesB(void *cvode_mem, int which,
+                                           realtype reltolQB, N_Vector abstolQB);
+
+/*
+ * =================================================================
+ *
+ * MAIN SOLVER FUNCTIONS FOR FORWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeF
+ * -----------------------------------------------------------------
+ * CVodeF integrates towards tout and returns solution into yout.
+ * In the same time, it stores check point data every 'steps'.
+ *
+ * CVodeF can be called repeatedly by the user.
+ *
+ * ncheckPtr points to the number of check points stored so far.
+ *
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeF(void *cvode_mem, realtype tout, N_Vector yout,
+			   realtype *tret, int itask, int *ncheckPtr);
+
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeB
+ * -----------------------------------------------------------------
+ * CVodeB performs the integration of all backward problems specified
+ * through calls to CVodeCreateB through a sequence of forward-backward
+ * runs in between consecutive check points. CVodeB can be called 
+ * either in CV_NORMAL or CV_ONE_STEP mode. After a successful return
+ * from CVodeB, the solution and quadrature variables at the current
+ * return time for any given backward problem can be obtained by
+ * calling CVodeGetB and CVodeGetQuadB, respectively.
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT int CVodeB(void *cvode_mem, realtype tBout, int itaskB);
+
+/*
+ * =================================================================
+ *
+ * OPTIONAL INPUT FUNCTIONS FOR BACKWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeSetAdjNoSensi
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSetAdjNoSensi(void *cvode_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Optional input functions for backward problems
+ * -----------------------------------------------------------------
+ * These functions are just wrappers around the corresponding
+ * functions in cvodes.h, with some particularizations for the
+ * backward integration.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeSetIterTypeB(void *cvode_mem, int which, int iterB);
+SUNDIALS_EXPORT int CVodeSetUserDataB(void *cvode_mem, int which, void *user_dataB);
+SUNDIALS_EXPORT int CVodeSetMaxOrdB(void *cvode_mem, int which, int maxordB);
+SUNDIALS_EXPORT int CVodeSetMaxNumStepsB(void *cvode_mem, int which, long int mxstepsB);
+SUNDIALS_EXPORT int CVodeSetStabLimDetB(void *cvode_mem, int which, booleantype stldetB);
+SUNDIALS_EXPORT int CVodeSetInitStepB(void *cvode_mem, int which, realtype hinB);
+SUNDIALS_EXPORT int CVodeSetMinStepB(void *cvode_mem, int which, realtype hminB);
+SUNDIALS_EXPORT int CVodeSetMaxStepB(void *cvode_mem, int which, realtype hmaxB);
+SUNDIALS_EXPORT int CVodeSetConstraintsB(void *cvode_mem, int which, N_Vector constraintsB);      
+SUNDIALS_EXPORT int CVodeSetQuadErrConB(void *cvode_mem, int which, booleantype errconQB);
+
+/*
+ * =================================================================
+ *
+ * EXTRACTION AND DENSE OUTPUT FUNCTIONS FOR BACKWARD PROBLEMS
+ *
+ * =================================================================
+ */
+  
+/*
+ * -----------------------------------------------------------------
+ * CVodeGetB and CVodeGetQuadB
+ * -----------------------------------------------------------------
+ * Extraction functions for the solution and quadratures for a given 
+ * backward problem. They return their corresponding output vector
+ * at the current time reached by the integration of the backward
+ * problem. To obtain the solution or quadratures associated with
+ * a given backward problem at some other time within the last 
+ * integration step (dense output), first obtain a pointer to the
+ * proper CVODES memory by calling CVodeGetAdjCVodeBmem and then use it
+ * to call CVodeGetDky and CVodeGetQuadDky.  
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT int CVodeGetB(void *cvode_mem, int which,
+                              realtype *tBret, N_Vector yB);
+SUNDIALS_EXPORT int CVodeGetQuadB(void *cvode_mem, int which,
+                                  realtype *tBret, N_Vector qB);
+
+
+/*
+ * =================================================================
+ *
+ * OPTIONAL OUTPUT FUNCTIONS FOR BACKWARD PROBLEMS
+ *
+ * =================================================================
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeGetAdjCVodeBmem
+ * -----------------------------------------------------------------
+ * CVodeGetAdjCVodeBmem returns a (void *) pointer to the CVODES
+ * memory allocated for the backward problem. This pointer can
+ * then be used to call any of the CVodeGet* CVODES routines to
+ * extract optional output for the backward integration phase.
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT void *CVodeGetAdjCVodeBmem(void *cvode_mem, int which);
+
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeGetAdjY
+ *    Returns the interpolated forward solution at time t. This
+ *    function is a wrapper around the interpType-dependent internal
+ *    function.
+ *    The calling function must allocate space for y.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetAdjY(void *cvode_mem, realtype t, N_Vector y);
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeGetAdjCheckPointsInfo
+ *    Loads an array of nckpnts structures of type CVadjCheckPointRec.
+ *    The user must allocate space for ckpnt (ncheck+1).
+ * -----------------------------------------------------------------
+ */
+
+typedef struct {
+  void *my_addr;
+  void *next_addr;
+  realtype t0;
+  realtype t1;
+  long int nstep;
+  int order;
+  realtype step;
+} CVadjCheckPointRec;
+
+SUNDIALS_EXPORT int CVodeGetAdjCheckPointsInfo(void *cvode_mem, CVadjCheckPointRec *ckpnt);
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeGetAdjDataPointHermite
+ *    Returns the 2 vectors stored for cubic Hermite interpolation 
+ *    at the data point 'which'. The user must allocate space for
+ *    y and yd. Returns CV_MEM_NULL if cvode_mem is NULL.
+ *    Returns CV_ILL_INPUT if interpType != CV_HERMITE.
+ * CVodeGetAdjDataPointPolynomial
+ *    Returns the vector stored for polynomial interpolation 
+ *    at the data point 'which'. The user must allocate space for
+ *    y. Returns CV_MEM_NULL if cvode_mem is NULL.
+ *    Returns CV_ILL_INPUT if interpType != CV_POLYNOMIAL.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetAdjDataPointHermite(void *cvode_mem, int which,
+                                                realtype *t, N_Vector y, N_Vector yd);
+  
+SUNDIALS_EXPORT int CVodeGetAdjDataPointPolynomial(void *cvode_mem, int which,
+                                                   realtype *t, int *order, N_Vector y);
+
+/*
+ * -----------------------------------------------------------------
+ * CVodeGetAdjCurrentCheckPoint
+ *    Returns the address of the 'active' check point.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVodeGetAdjCurrentCheckPoint(void *cvode_mem, void **addr);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_bandpre.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_bandpre.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_bandpre.h	(revision 16222)
@@ -0,0 +1,188 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *                Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the CVSBANDPRE module, which
+ * provides a banded difference quotient Jacobian-based
+ * preconditioner and solver routines for use with the CVSSPILS
+ * iterative linear solver interface.
+ *
+ * Part I contains type definitions and function prototypes for using
+ * CVSBANDPRE on forward problems (IVP integration and/or FSA)
+ *
+ * Part II contains type definitions and function prototypes for using
+ * CVSBANDPRE on adjopint (backward) problems
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSBANDPRE_H
+#define _CVSBANDPRE_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*=================================================================
+  PART I - forward problems
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  SUMMARY
+  
+  These routines provide a band matrix preconditioner based on
+  difference quotients of the ODE right-hand side function f.
+  The user supplies parameters
+    mu = upper half-bandwidth (number of super-diagonals)
+    ml = lower half-bandwidth (number of sub-diagonals)
+  The routines generate a band matrix of bandwidth ml + mu + 1
+  and use this to form a preconditioner for use with the Krylov
+  linear solver through the CVSPILS interface. Although this 
+  matrix is intended to approximate the Jacobian df/dy, it may 
+  be a very crude approximation. The true Jacobian need not be 
+  banded, or its true bandwith may be larger than ml + mu + 1, 
+  as long as the banded approximation generated here is 
+  sufficiently accurate to speed convergence as a preconditioner.
+ 
+  Usage:
+    The following is a summary of the usage of this module.
+    Details of the calls to CVodeCreate, CVodeInit, CVSp*,
+    and CVode are available in the User Guide.
+    To use these routines, the sequence of calls in the user
+    main program should be as follows:
+ 
+    #include <cvodes/cvodes_bandpre.h>
+    #include <nvector_serial.h>   (or openmp or pthreads)
+    ...
+    void *cvode_mem;
+    ...
+    Set y0
+    ...
+    SUNLinearSolver LS = SUNSPBCGS(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNSPFGMR(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNSPGMR(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNSPTFQMR(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNPCG(y0, pretype, maxl);
+    ...
+    cvode_mem = CVodeCreate(...);
+    flag = CVodeInit(...);
+    ...
+    flag = CVSpilsSetLinearSolver(cvode_mem, LS);
+    ...
+    flag = CVBandPrecInit(cvode_mem, N, mu, ml);
+    ...
+    flag = CVode(...);
+    ...
+    Free y0
+    ...
+    CVodeFree(&cvode_mem);
+    ...
+    SUNLinSolFree(LS);
+    ...
+ 
+  Notes:
+  (1) Include this file for the CVBandPrecData type definition.
+  (2) In the CVBandPrecInit call, the arguments N is the
+      problem dimension.
+  (3) In the linear solver creation call, the user is free to
+      specify the input pretype and the optional input maxl.
+  -----------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------
+  Function : CVBandPrecInit
+  -----------------------------------------------------------------
+  CVBandPrecInit allocates and initializes the BANDPRE preconditioner
+  module. This function must be called AFTER the CVSPILS linear
+  solver interface has been created.
+ 
+  The parameters of CVBandPrecInit are as follows:
+ 
+  cvode_mem is the pointer to CVODE memory returned by CVodeCreate.
+ 
+  N is the problem size.
+ 
+  mu is the upper half bandwidth.
+ 
+  ml is the lower half bandwidth.
+ 
+  The return value of CVBandPrecInit is one of:
+    CVSPILS_SUCCESS if no errors occurred
+    CVSPILS_MEM_NULL if the integrator memory is NULL
+    CVSPILS_LMEM_NULL if the linear solver memory is NULL
+    CVSPILS_ILL_INPUT if an input has an illegal value
+    CVSPILS_MEM_FAIL if a memory allocation request failed
+ 
+  NOTE: The band preconditioner assumes a serial/OpenMP/Pthreads
+        implementation of the NVECTOR package. Therefore, 
+        CVBandPrecInit will first test for a compatible N_Vector 
+        internal representation by checking for required functions.
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVBandPrecInit(void *cvode_mem, sunindextype N,
+                                   sunindextype mu, sunindextype ml);
+
+/*-----------------------------------------------------------------
+  Optional output functions : CVBandPrecGet*
+  -----------------------------------------------------------------
+  CVBandPrecGetWorkSpace returns the real and integer work space used
+                         by CVBANDPRE.
+  CVBandPrecGetNumRhsEvals returns the number of calls made from
+                           CVBANDPRE to the user's right-hand side
+                           routine f.
+ 
+  The return value of CVBandPrecGet* is one of:
+    CVSPILS_SUCCESS if no errors occurred
+    CVSPILS_MEM_NULL if the integrator memory is NULL
+    CVSPILS_LMEM_NULL if the linear solver memory is NULL
+    CVSPILS_PMEM_NULL if the preconditioner memory is NULL
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVBandPrecGetWorkSpace(void *cvode_mem,
+                                           long int *lenrwLS,
+                                           long int *leniwLS);
+SUNDIALS_EXPORT int CVBandPrecGetNumRhsEvals(void *cvode_mem,
+                                             long int *nfevalsBP);
+
+
+/*=================================================================
+  PART II - backward problems
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  Functions: CVBandPrecInitB
+  -----------------------------------------------------------------
+  Interface functions for the CVBANDPRE preconditioner to be used
+  on the backward phase.
+ 
+  CVBandPrecInitB interfaces to the CVBANDPRE preconditioner
+  for the backward integration.
+  The 'which' argument is the int returned by CVodeCreateB.
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVBandPrecInitB(void *cvode_mem, int which,
+                                    sunindextype nB, sunindextype muB,
+                                    sunindextype mlB);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_bbdpre.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_bbdpre.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_bbdpre.h	(revision 16222)
@@ -0,0 +1,337 @@
+/*
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *                Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the CVBBDPRE module, for a
+ * band-block-diagonal preconditioner, i.e. a block-diagonal
+ * matrix with banded blocks, for use with the CVSPILS interface,
+ * and the MPI-parallel implementation of the NVECTOR module.
+ *
+ * Part I contains type definitions and function prototypes for using
+ * CVBBDPRE on forward problems (IVP integration and/or FSA)
+ *
+ * Part II contains type definitions and function prototypes for using
+ * CVBBDPRE on adjopint (backward) problems
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSBBDPRE_H
+#define _CVSBBDPRE_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*=================================================================
+  PART I - forward problems
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  SUMMARY
+ 
+  These routines provide a preconditioner matrix that is
+  block-diagonal with banded blocks. The blocking corresponds
+  to the distribution of the dependent variable vector y among
+  the processors. Each preconditioner block is generated from
+  the Jacobian of the local part (on the current processor) of a
+  given function g(t,y) approximating f(t,y). The blocks are
+  generated by a difference quotient scheme on each processor
+  independently. This scheme utilizes an assumed banded
+  structure with given half-bandwidths, mudq and mldq.
+  However, the banded Jacobian block kept by the scheme has
+  half-bandwiths mukeep and mlkeep, which may be smaller.
+ 
+  The user's calling program should have the following form:
+ 
+    #include <cvodes/cvodes_spils.h>
+    #include <cvodes/cvodes_bbdpre.h>
+    #include <nvector_parallel.h>
+    ...
+    void *cvode_mem;
+    ...
+    Set y0
+    ...
+    SUNLinearSolver LS = SUNSPBCGS(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNSPFGMR(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNSPGMR(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNSPTFQMR(y0, pretype, maxl);
+      -or-
+    SUNLinearSolver LS = SUNPCG(y0, pretype, maxl);
+    ...
+    cvode_mem = CVodeCreate(...);
+    flag = CVodeInit(...);
+    ...
+    flag = CVSpilsSetLinearSolver(cvode_mem, LS);
+    ...
+    flag = CVBBDPrecInit(cvode_mem, Nlocal, mudq ,mldq,
+                         mukeep, mlkeep, dqrely, gloc, cfn);
+    ...
+    flag = CVode(...);
+    ...
+    CVodeFree(&cvode_mem);
+    ...
+    Free y0
+    ...
+    CVodeFree(&cvode_mem);
+    ...
+    SUNLinSolFree(LS);
+    ...
+ 
+  The user-supplied routines required are:
+ 
+    f    = function defining the ODE right-hand side f(t,y).
+ 
+    gloc = function defining the approximation g(t,y).
+ 
+    cfn  = function to perform communication need for gloc.
+ 
+  Notes:
+ 
+  1) This header file is included by the user for the definition
+     of the CVBBDData type and for needed function prototypes.
+ 
+  2) The CVBBDPrecInit call includes half-bandwiths mudq and mldq
+     to be used in the difference quotient calculation of the
+     approximate Jacobian. They need not be the true
+     half-bandwidths of the Jacobian of the local block of g,
+     when smaller values may provide a greater efficiency.
+     Also, the half-bandwidths mukeep and mlkeep of the retained
+     banded approximate Jacobian block may be even smaller,
+     to reduce storage and computation costs further.
+     For all four half-bandwidths, the values need not be the
+     same on every processor.
+ 
+  3) The actual name of the user's f function is passed to
+     CVodeInit, and the names of the user's gloc and cfn
+     functions are passed to CVBBDPrecInit.
+ 
+  4) The pointer to the user-defined data block user_data, which is
+     set through CVodeSetUserData is also available to the user in
+     gloc and cfn.
+ 
+  5) Optional outputs specific to this module are available by
+     way of routines listed below. These include work space sizes
+     and the cumulative number of gloc calls. The costs
+     associated with this module also include nsetups banded LU
+     factorizations, nlinsetups cfn calls, and npsolves banded
+     backsolve calls, where nlinsetups and npsolves are
+     integrator/CVSPILS optional outputs.
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Type : CVLocalFn
+  -----------------------------------------------------------------
+  The user must supply a function g(t,y) which approximates the
+  right-hand side function f for the system y'=f(t,y), and which
+  is computed locally (without interprocess communication).
+  (The case where g is mathematically identical to f is allowed.)
+  The implementation of this function must have type CVLocalFn.
+ 
+  This function takes as input the local vector size Nlocal, the
+  independent variable value t, the local real dependent
+  variable vector y, and a pointer to the user-defined data
+  block user_data. It is to compute the local part of g(t,y) and
+  store this in the vector g.
+  (Allocation of memory for y and g is handled within the
+  preconditioner module.)
+  The user_data parameter is the same as that specified by the user
+  through the CVodeSetUserdata routine.
+ 
+  A CVLocalFn should return 0 if successful, a positive value if 
+  a recoverable error occurred, and a negative value if an 
+  unrecoverable error occurred.
+  -----------------------------------------------------------------*/
+typedef int (*CVLocalFn)(sunindextype Nlocal, realtype t, 
+			 N_Vector y, N_Vector g, void *user_data);
+
+  
+/*-----------------------------------------------------------------
+  Type : CVCommFn
+  -----------------------------------------------------------------
+  The user may supply a function of type CVCommFn which performs
+  all interprocess communication necessary to evaluate the
+  approximate right-hand side function described above.
+ 
+  This function takes as input the local vector size Nlocal,
+  the independent variable value t, the dependent variable
+  vector y, and a pointer to the user-defined data block 
+  user_data. The user_data parameter is the same as that 
+  specified by the user through the CVodeSetUserData routine. 
+  The CVCommFn cfn is expected to save communicated data in 
+  space defined within the structure user_data. 
+  Note: A CVCommFn cfn does not have a return value.
+ 
+  Each call to the CVCommFn cfn is preceded by a call to the
+  CVRhsFn f with the same (t,y) arguments. Thus cfn can omit any
+  communications done by f if relevant to the evaluation of g.
+  If all necessary communication was done by f, the user can
+  pass NULL for cfn in CVBBDPrecInit (see below).
+ 
+  A CVCommFn should return 0 if successful, a positive value if 
+  a recoverable error occurred, and a negative value if an 
+  unrecoverable error occurred.
+  -----------------------------------------------------------------*/
+typedef int (*CVCommFn)(sunindextype Nlocal, realtype t, 
+			N_Vector y, void *user_data);
+
+  
+/*-----------------------------------------------------------------
+  Function : CVBBDPrecInit
+  -----------------------------------------------------------------
+  CVBBDPrecInit allocates and initializes the BBD preconditioner.
+ 
+  The parameters of CVBBDPrecInit are as follows:
+ 
+  cvode_mem is the pointer to the integrator memory.
+ 
+  Nlocal is the length of the local block of the vectors y etc.
+         on the current processor.
+ 
+  mudq, mldq are the upper and lower half-bandwidths to be used
+             in the difference quotient computation of the local
+             Jacobian block.
+ 
+  mukeep, mlkeep are the upper and lower half-bandwidths of the
+                 retained banded approximation to the local Jacobian
+                 block.
+ 
+  dqrely is an optional input. It is the relative increment
+         in components of y used in the difference quotient
+         approximations. To specify the default, pass 0.
+         The default is dqrely = sqrt(unit roundoff).
+ 
+  gloc is the name of the user-supplied function g(t,y) that
+       approximates f and whose local Jacobian blocks are
+       to form the preconditioner.
+ 
+  cfn is the name of the user-defined function that performs
+      necessary interprocess communication for the
+      execution of gloc.
+ 
+  The return value of CVBBDPrecInit is one of:
+    CVSPILS_SUCCESS if no errors occurred
+    CVSPILS_MEM_NULL if the integrator memory is NULL
+    CVSPILS_LMEM_NULL if the linear solver memory is NULL
+    CVSPILS_ILL_INPUT if an input has an illegal value
+    CVSPILS_MEM_FAIL if a memory allocation request failed
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVBBDPrecInit(void *cvode_mem,
+                                  sunindextype Nlocal, 
+                                  sunindextype mudq,
+                                  sunindextype mldq, 
+                                  sunindextype mukeep,
+                                  sunindextype mlkeep, 
+                                  realtype dqrely,
+                                  CVLocalFn gloc,
+                                  CVCommFn cfn);
+
+  
+/*-----------------------------------------------------------------
+  Function : CVBBDPrecReInit
+  -----------------------------------------------------------------
+  CVBBDPrecReInit re-initializes the BBDPRE module when solving a
+  sequence of problems of the same size with CVSPILS/CVBBDPRE 
+  provided there is no change in Nlocal, mukeep, or mlkeep. After 
+  solving one problem, and after calling CVodeReInit to 
+  re-initialize the integrator for a subsequent problem, call 
+  CVBBDPrecReInit.
+ 
+  All arguments have the same names and meanings as those
+  of CVBBDPrecInit.
+ 
+  The return value of CVBBDPrecReInit is one of:
+    CVSPILS_SUCCESS if no errors occurred
+    CVSPILS_MEM_NULL if the integrator memory is NULL
+    CVSPILS_LMEM_NULL if the linear solver memory is NULL
+    CVSPILS_PMEM_NULL if the preconditioner memory is NULL
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVBBDPrecReInit(void *cvode_mem,
+                                    sunindextype mudq,
+                                    sunindextype mldq,
+                                    realtype dqrely);
+
+  
+/*-----------------------------------------------------------------
+  BBDPRE optional output extraction routines
+  -----------------------------------------------------------------
+  CVBBDPrecGetWorkSpace returns the BBDPRE real and integer work 
+                        space sizes.
+  CVBBDPrecGetNumGfnEvals returns the number of calls to gfn.
+ 
+  The return value of CVBBDPrecGet* is one of:
+    CVSPILS_SUCCESS if no errors occurred
+    CVSPILS_MEM_NULL if the integrator memory is NULL
+    CVSPILS_LMEM_NULL if the linear solver memory is NULL
+    CVSPILS_PMEM_NULL if the preconditioner memory is NULL
+  -----------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int CVBBDPrecGetWorkSpace(void *cvode_mem,
+                                          long int *lenrwBBDP,
+                                          long int *leniwBBDP);
+SUNDIALS_EXPORT int CVBBDPrecGetNumGfnEvals(void *cvode_mem,
+                                            long int *ngevalsBBDP);
+
+  
+/*=================================================================
+  PART II - backward problems
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  Types: CVLocalFnB and CVCommFnB
+  -----------------------------------------------------------------
+  Local approximation function and inter-process communication
+  function for the BBD preconditioner on the backward phase.
+  -----------------------------------------------------------------*/
+typedef int (*CVLocalFnB)(sunindextype NlocalB, realtype t, 
+			  N_Vector y, N_Vector yB, N_Vector gB,
+			  void *user_dataB);
+typedef int (*CVCommFnB)(sunindextype NlocalB, realtype t,
+			 N_Vector y, N_Vector yB, void *user_dataB);
+
+
+/*-----------------------------------------------------------------
+  Functions: CVBBDPrecInitB, CVBBDPrecReInit
+  -----------------------------------------------------------------
+  Interface functions for the CVBBDPRE preconditioner to be used on
+  the backward phase.
+  The 'which' argument is the int returned by CVodeCreateB.
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVBBDPrecInitB(void *cvode_mem, int which,
+                                   sunindextype NlocalB,
+                                   sunindextype mudqB,
+                                   sunindextype mldqB,
+                                   sunindextype mukeepB,
+                                   sunindextype mlkeepB,
+                                   realtype dqrelyB,
+                                   CVLocalFnB glocB,
+                                   CVCommFnB cfnB);
+SUNDIALS_EXPORT int CVBBDPrecReInitB(void *cvode_mem, int which, 
+                                     sunindextype mudqB,
+                                     sunindextype mldqB,
+                                     realtype dqrelyB);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_diag.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_diag.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_diag.h	(revision 16222)
@@ -0,0 +1,143 @@
+/*
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the diagonal linear solver CVSDIAG.
+ *
+ *
+ * Part I contains type definitions and function prototypes for using
+ * CVDIAG on forward problems (IVP integration and/or FSA)
+ *
+ * Part II contains type definitions and function prototypes for using
+ * CVDIAG on adjoint (backward) problems
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSDIAG_H
+#define _CVSDIAG_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * CVDIAG return values
+ * -----------------------------------------------------------------
+ */
+
+#define CVDIAG_SUCCESS          0
+#define CVDIAG_MEM_NULL        -1
+#define CVDIAG_LMEM_NULL       -2
+#define CVDIAG_ILL_INPUT       -3
+#define CVDIAG_MEM_FAIL        -4
+
+/* Additional last_flag values */
+
+#define CVDIAG_INV_FAIL        -5
+#define CVDIAG_RHSFUNC_UNRECVR -6
+#define CVDIAG_RHSFUNC_RECVR   -7
+
+/* Return values for adjoint module */
+
+#define CVDIAG_NO_ADJ          -101
+
+/* 
+ * -----------------------------------------------------------------
+ * PART I - forward problems
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVDiag
+ * -----------------------------------------------------------------
+ * A call to the CVDiag function links the main integrator with
+ * the CVDIAG linear solver.
+ *
+ * cvode_mem is the pointer to the integrator memory returned by
+ *           CVodeCreate.
+ *
+ * The return value of CVDiag is one of:
+ *    CVDIAG_SUCCESS   if successful
+ *    CVDIAG_MEM_NULL  if the cvode memory was NULL
+ *    CVDIAG_MEM_FAIL  if there was a memory allocation failure
+ *    CVDIAG_ILL_INPUT if a required vector operation is missing
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVDiag(void *cvode_mem);
+  
+/*
+ * -----------------------------------------------------------------
+ * Optional outputs from the CVDIAG linear solver
+ * -----------------------------------------------------------------
+ *
+ * CVDiagGetWorkSpace returns the real and integer workspace used
+ *                    by CVDIAG.
+ * CVDiagGetNumRhsEvals returns the number of calls to the user
+ *                      f routine due to finite difference Jacobian
+ *                      evaluation.
+ *                      Note: The number of diagonal approximate
+ *                      Jacobians formed is equal to the number of
+ *                      CVDiagSetup calls. This number is available
+ *                      through CVodeGetNumLinSolvSetups.
+ * CVDiagGetLastFlag returns the last error flag set by any of
+ *                   the CVDIAG interface functions.
+ *
+ * The return value of CVDiagGet* is one of:
+ *    CVDIAG_SUCCESS   if successful
+ *    CVDIAG_MEM_NULL  if the cvode memory was NULL
+ *    CVDIAG_LMEM_NULL if the cvdiag memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVDiagGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS);
+SUNDIALS_EXPORT int CVDiagGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS);
+SUNDIALS_EXPORT int CVDiagGetLastFlag(void *cvode_mem, long int *flag);
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a CVDIAG return flag
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT char *CVDiagGetReturnFlagName(long int flag);
+
+/* 
+ * -----------------------------------------------------------------
+ * PART II - backward problems
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: CVDiagB
+ * -----------------------------------------------------------------
+ * CVDiagB links the main CVODE integrator with the CVDIAG
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT int CVDiagB(void *cvode_mem, int which);
+  
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_direct.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_direct.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_direct.h	(revision 16222)
@@ -0,0 +1,280 @@
+/* ----------------------------------------------------------------- 
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *                Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * Common header file for the direct linear solver interface in 
+ * CVODES.
+ *
+ * Part I contains type definitions and function prototypes for 
+ * using a CVDLS linear solver on forward problems (IVP 
+ * integration and/or FSA)
+ *
+ * Part II contains type definitions and function prototypes for 
+ * using a CVDLS linear solver on adjoint (backward) problems
+ * -----------------------------------------------------------------*/
+
+#ifndef _CVSDLS_H
+#define _CVSDLS_H
+
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*=================================================================
+  CVSDLS Constants
+  =================================================================*/
+
+  
+/*-----------------------------------------------------------------
+  return values 
+  -----------------------------------------------------------------*/
+
+#define CVDLS_SUCCESS           0
+#define CVDLS_MEM_NULL         -1
+#define CVDLS_LMEM_NULL        -2
+#define CVDLS_ILL_INPUT        -3
+#define CVDLS_MEM_FAIL         -4
+
+/* Additional last_flag values */
+
+#define CVDLS_JACFUNC_UNRECVR  -5
+#define CVDLS_JACFUNC_RECVR    -6
+#define CVDLS_SUNMAT_FAIL      -7
+
+/* Return values for the adjoint module */
+
+#define CVDLS_NO_ADJ           -101
+#define CVDLS_LMEMB_NULL       -102
+
+
+/*=================================================================
+  PART I:  Forward Problems
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  FUNCTION TYPES
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Type: CVDlsJacFn
+  -----------------------------------------------------------------
+ 
+  A Jacobian approximation function Jac must be of type CVDlsJacFn. 
+  Its parameters are:
+ 
+  Jac is the SUNMatrix that will be loaded by a CVDlsJacFn with an 
+      approximation to the Jacobian matrix J = (df_i/dy_j) at 
+      the point (t,y). 
+ 
+  t   is the current value of the independent variable.
+ 
+  y   is the current value of the dependent variable vector,
+      namely the predicted value of y(t).
+ 
+  fy  is the vector f(t,y).
+ 
+  user_data is a pointer to user data - the same as the user_data
+      parameter passed to CVodeSetUserdata.
+ 
+  tmp1, tmp2, and tmp3 are pointers to memory allocated for
+  vectors of length N which can be used by a CVDlsJacFn
+  as temporary storage or work space.
+ 
+  A CVDlsJacFn should return 0 if successful, a positive 
+  value if a recoverable error occurred, and a negative value if 
+  an unrecoverable error occurred.
+ 
+  -----------------------------------------------------------------
+
+  NOTE: See the relevant SUNMatrix implementation header files and
+      documentation for mechanisms to inquire about matrix 
+      dimensions, and for efficient ways to set matrix entries.
+                                                                 
+  NOTE: If the user's Jacobian routine needs other quantities,   
+      they are accessible as follows: hcur (the current stepsize)
+      and ewt (the error weight vector) are accessible through   
+      CVodeGetCurrentStep and CVodeGetErrWeights, respectively 
+      (see cvode.h). The unit roundoff is available as 
+      UNIT_ROUNDOFF defined in sundials_types.h.
+ 
+  -----------------------------------------------------------------*/
+typedef int (*CVDlsJacFn)(realtype t, N_Vector y, N_Vector fy, 
+                          SUNMatrix Jac, void *user_data,
+                          N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+  
+
+/*-----------------------------------------------------------------
+  EXPORTED FUNCTIONS 
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Required inputs to the CVSDLS linear solver interface
+  -----------------------------------------------------------------
+ 
+  CVDlsSetLinearSolver specifies the direct SUNLinearSolver object
+  that should be used.  This is required if CVodes is solving a 
+  problem using the Newton nonlinear solver (not the function 
+  iteration).
+ 
+  The return value is one of:
+     CVDLS_SUCCESS   if successful
+     CVDLS_MEM_NULL  if the CVODE memory was NULL
+     CVDLS_ILL_INPUT if the arguments are incompatible
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVDlsSetLinearSolver(void *cvode_mem, 
+                                         SUNLinearSolver LS,
+                                         SUNMatrix A);
+
+  
+/*-----------------------------------------------------------------
+  Optional inputs to the CVSDLS linear solver
+  -----------------------------------------------------------------
+ 
+  CVDlsSetJacFn specifies the dense/band/sparse Jacobian
+  approximation routine to be used for a direct linear solver.
+  By default, a difference quotient approximation is used for 
+  dense/band; no default exists for sparse (so this must be 
+  user-supplied).
+ 
+  The return value is one of:
+     CVDLS_SUCCESS   if successful
+     CVDLS_MEM_NULL  if the CVODE memory was NULL
+     CVDLS_LMEM_NULL if the linear solver memory was NULL
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVDlsSetJacFn(void *cvode_mem, CVDlsJacFn jac);
+
+
+/*-----------------------------------------------------------------
+  Optional outputs from the CVSSDLS linear solver interface
+  -----------------------------------------------------------------
+ 
+  CVDlsGetWorkSpace   returns the real and integer workspace used
+                      by the direct linear solver.
+  CVDlsGetNumJacEvals returns the number of calls made to the
+                      Jacobian evaluation routine jac.
+  CVDlsGetNumRhsEvals returns the number of calls to the user
+                      f routine due to finite difference Jacobian
+                      evaluation.
+  CVDlsGetLastFlag    returns the last error flag set by any of
+                      the CVSDIRECT interface functions.
+ 
+  The return value of CVDlsGet* is one of:
+     CVDLS_SUCCESS   if successful
+     CVDLS_MEM_NULL  if the CVODES memory was NULL
+     CVDLS_LMEM_NULL if the linear solver memory was NULL
+  -----------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int CVDlsGetWorkSpace(void *cvode_mem,
+                                      long int *lenrwLS,
+                                      long int *leniwLS);
+SUNDIALS_EXPORT int CVDlsGetNumJacEvals(void *cvode_mem,
+                                        long int *njevals);
+SUNDIALS_EXPORT int CVDlsGetNumRhsEvals(void *cvode_mem,
+                                        long int *nfevalsLS);
+SUNDIALS_EXPORT int CVDlsGetLastFlag(void *cvode_mem,
+                                     long int *flag);
+
+/*-----------------------------------------------------------------
+  The following function returns the name of the constant 
+  associated with a CVSDLS return flag
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT char *CVDlsGetReturnFlagName(long int flag);
+
+/*=================================================================
+  PART II:  Backward Problems
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  FUNCTION TYPES
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Type: CVDlsJacFnB
+  -----------------------------------------------------------------
+  A Jacobian approximation function jacB for the adjoint
+  (backward) problem must have the prototype given below. 
+  -----------------------------------------------------------------*/
+typedef int (*CVDlsJacFnB)(realtype t, N_Vector y, N_Vector yB,
+                           N_Vector fyB, SUNMatrix JB,
+                           void *user_dataB, N_Vector tmp1B,
+                           N_Vector tmp2B, N_Vector tmp3B);
+
+/*-----------------------------------------------------------------
+  Type: CVDlsJacFnBS
+  -----------------------------------------------------------------
+  A Jacobian approximation function jacBS for the adjoint
+  (backward) problem, sensitivity-dependent case,  must have the
+  prototype given below. 
+  -----------------------------------------------------------------*/
+typedef int (*CVDlsJacFnBS)(realtype t, N_Vector y, N_Vector *yS,
+                            N_Vector yB, N_Vector fyB, SUNMatrix JB,
+                            void *user_dataB, N_Vector tmp1B,
+                            N_Vector tmp2B, N_Vector tmp3B);
+
+
+/*-----------------------------------------------------------------
+  EXPORTED FUNCTIONS 
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Required inputs for the CVSDLS linear solver interface:
+
+  CVDlsSetLinearSolverB specifies the direct SUNLinearSolver 
+  object that should be used for backward integration. The 
+  'which' argument is the int returned by CVodeCreateB.
+
+  The return value is one of:
+    CVDLS_SUCCESS   if successful
+    CVDLS_MEM_NULL  if the cvode memory was NULL
+    CVDLS_ILL_INPUT if the arguments are incompatible
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVDlsSetLinearSolverB(void *cvode_mem,
+                                          int which,
+                                          SUNLinearSolver LS,
+                                          SUNMatrix A);
+  
+/*-----------------------------------------------------------------
+  Functions: CVDlsSetJacFnB and CVDlsSetJacFnBS
+  -----------------------------------------------------------------
+  CVDlsSetJacFnB specifies the Jacobian function to be used by a
+  CVSDLS linear solver for the backward integration phase, when
+  the backward problem does not depend on forward sensitivities.
+  CVDlsSetJacFnBS specifies the Jacobian function when the backward
+  problem does depend on sensitivities.
+
+  The 'which' argument is the int returned by CVodeCreateB.
+ 
+  The return value is one of:
+     CVDLS_SUCCESS   if successful
+     CVDLS_MEM_NULL  if the CVODE memory was NULL
+     CVDLS_LMEM_NULL if the linear solver memory was NULL
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVDlsSetJacFnB(void *cvode_mem, int which,
+                                   CVDlsJacFnB jacB);
+SUNDIALS_EXPORT int CVDlsSetJacFnBS(void *cvode_mem, int which,
+                                    CVDlsJacFnBS jacBS);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_impl.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_impl.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_impl.h	(revision 16222)
@@ -0,0 +1,1107 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the main CVODES integrator.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVODES_IMPL_H
+#define _CVODES_IMPL_H
+
+#include <stdarg.h>
+
+#include <cvodes/cvodes.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* 
+ * =================================================================
+ *   I N T E R N A L   C V O D E S   C O N S T A N T S
+ * =================================================================
+ */
+
+/* Basic CVODES constants */
+
+#define ADAMS_Q_MAX 12      /* max value of q for lmm == ADAMS    */
+#define BDF_Q_MAX    5      /* max value of q for lmm == BDF      */
+#define Q_MAX  ADAMS_Q_MAX  /* max value of q for either lmm      */
+#define L_MAX  (Q_MAX+1)    /* max value of L for either lmm      */
+#define NUM_TESTS    5      /* number of error test quantities    */
+
+#define HMIN_DEFAULT     RCONST(0.0)    /* hmin default value     */
+#define HMAX_INV_DEFAULT RCONST(0.0)    /* hmax_inv default value */
+#define MXHNIL_DEFAULT   10             /* mxhnil default value   */
+#define MXSTEP_DEFAULT   500            /* mxstep default value   */
+
+/* 
+ * =================================================================
+ *   F O R W A R D   P O I N T E R   R E F E R E N C E S
+ * =================================================================
+ */
+
+typedef struct CVadjMemRec  *CVadjMem;
+typedef struct CkpntMemRec  *CkpntMem;
+typedef struct DtpntMemRec  *DtpntMem;
+typedef struct CVodeBMemRec *CVodeBMem;
+
+/* 
+ * =================================================================
+ *   M A I N    I N T E G R A T O R    M E M O R Y    B L O C K
+ * =================================================================
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * Types: struct CVodeMemRec, CVodeMem
+ * -----------------------------------------------------------------
+ * The type CVodeMem is type pointer to struct CVodeMemRec.
+ * This structure contains fields to keep track of problem state.
+ * -----------------------------------------------------------------
+ */
+  
+typedef struct CVodeMemRec {
+    
+  realtype cv_uround;         /* machine unit roundoff                         */   
+
+  /*-------------------------- 
+    Problem Specification Data 
+    --------------------------*/
+
+  CVRhsFn cv_f;                   /* y' = f(t,y(t))                                */
+  void *cv_user_data;             /* user pointer passed to f                      */
+
+  int cv_lmm;                     /* lmm = ADAMS or BDF                            */
+  int cv_iter;                    /* iter = FUNCTIONAL or NEWTON                   */
+
+  int cv_itol;                    /* itol = CV_SS, CV_SV, or CV_WF, or CV_NN       */
+  realtype cv_reltol;             /* relative tolerance                            */
+  realtype cv_Sabstol;            /* scalar absolute tolerance                     */
+  N_Vector cv_Vabstol;            /* vector absolute tolerance                     */
+  booleantype cv_user_efun;       /* SUNTRUE if user sets efun                     */
+  CVEwtFn cv_efun;                /* function to set ewt                           */
+  void *cv_e_data;                /* user pointer passed to efun                   */
+
+  booleantype cv_constraintsSet;  /* constraints vector present:
+                                     do constraints calc                           */
+  /*-----------------------
+    Quadrature Related Data 
+    -----------------------*/
+
+  booleantype cv_quadr;       /* SUNTRUE if integrating quadratures            */
+
+  CVQuadRhsFn cv_fQ;          /* q' = fQ(t, y(t))                              */
+
+  booleantype cv_errconQ;     /* SUNTRUE if quadrs. are included in error test */
+
+  int cv_itolQ;               /* itolQ = CV_SS or CV_SV                        */
+  realtype cv_reltolQ;        /* relative tolerance for quadratures            */
+  realtype cv_SabstolQ;       /* scalar absolute tolerance for quadratures     */
+  N_Vector cv_VabstolQ;       /* vector absolute tolerance for quadratures     */
+
+  /*------------------------
+    Sensitivity Related Data 
+    ------------------------*/
+
+  booleantype cv_sensi;       /* SUNTRUE if computing sensitivities           */
+
+  int cv_Ns;                  /* Number of sensitivities                      */
+
+  int cv_ism;                 /* ism = SIMULTANEOUS or STAGGERED              */
+
+  CVSensRhsFn cv_fS;          /* fS = (df/dy)*yS + (df/dp)                    */
+  CVSensRhs1Fn cv_fS1;        /* fS1 = (df/dy)*yS_i + (df/dp)                 */
+  void *cv_fS_data;           /* data pointer passed to fS                    */
+  booleantype cv_fSDQ;        /* SUNTRUE if using internal DQ functions       */
+  int cv_ifS;                 /* ifS = ALLSENS or ONESENS                     */
+
+  realtype *cv_p;             /* parameters in f(t,y,p)                       */
+  realtype *cv_pbar;          /* scale factors for parameters                 */
+  int *cv_plist;              /* list of sensitivities                        */
+  int cv_DQtype;              /* central/forward finite differences           */
+  realtype cv_DQrhomax;       /* cut-off value for separate/simultaneous FD   */
+
+  booleantype cv_errconS;     /* SUNTRUE if yS are considered in err. control */
+
+  int cv_itolS;
+  realtype cv_reltolS;        /* relative tolerance for sensitivities         */
+  realtype *cv_SabstolS;      /* scalar absolute tolerances for sensi.        */
+  N_Vector *cv_VabstolS;      /* vector absolute tolerances for sensi.        */
+
+  /*-----------------------------------
+    Quadrature Sensitivity Related Data 
+    -----------------------------------*/
+
+  booleantype cv_quadr_sensi; /* SUNTRUE if computing sensitivties of quadrs. */
+
+  CVQuadSensRhsFn cv_fQS;     /* fQS = (dfQ/dy)*yS + (dfQ/dp)                 */
+  void *cv_fQS_data;          /* data pointer passed to fQS                   */
+  booleantype cv_fQSDQ;       /* SUNTRUE if using internal DQ functions       */
+
+  booleantype cv_errconQS;    /* SUNTRUE if yQS are considered in err. con.   */
+
+  int cv_itolQS;
+  realtype cv_reltolQS;       /* relative tolerance for yQS                   */
+  realtype *cv_SabstolQS;     /* scalar absolute tolerances for yQS           */
+  N_Vector *cv_VabstolQS;     /* vector absolute tolerances for yQS           */
+
+  /*-----------------------
+    Nordsieck History Array 
+    -----------------------*/
+
+  N_Vector cv_zn[L_MAX];      /* Nordsieck array, of size N x (q+1).
+                                 zn[j] is a vector of length N (j=0,...,q)
+                                 zn[j] = [1/factorial(j)] * h^j * 
+                                 (jth derivative of the interpolating poly.)  */
+
+  /*-------------------
+    Vectors of length N 
+    -------------------*/
+
+  N_Vector cv_ewt;            /* error weight vector                          */
+  N_Vector cv_y;              /* y is used as temporary storage by the solver.
+                                 The memory is provided by the user to CVode 
+                                 where the vector is named yout.              */
+  N_Vector cv_acor;           /* In the context of the solution of the
+                                 nonlinear equation, acor = y_n(m) - y_n(0).
+                                 On return, this vector is scaled to give
+                                 the estimated local error in y.              */
+  N_Vector cv_tempv;          /* temporary storage vector                     */
+  N_Vector cv_ftemp;          /* temporary storage vector                     */
+
+  N_Vector cv_mm;             /* mask vector in constraints tests             */
+  N_Vector cv_constraints;    /* vector of inequality constraint options      */
+
+  /*--------------------------
+    Quadrature Related Vectors 
+    --------------------------*/
+
+  N_Vector cv_znQ[L_MAX];     /* Nordsieck arrays for quadratures             */
+  N_Vector cv_ewtQ;           /* error weight vector for quadratures          */
+  N_Vector cv_yQ;             /* Unlike y, yQ is not allocated by the user    */
+  N_Vector cv_acorQ;          /* acorQ = yQ_n(m) - yQ_n(0)                    */
+  N_Vector cv_tempvQ;         /* temporary storage vector (~ tempv)           */
+
+  /*---------------------------
+    Sensitivity Related Vectors 
+    ---------------------------*/
+
+  N_Vector *cv_znS[L_MAX];    /* Nordsieck arrays for sensitivities           */
+  N_Vector *cv_ewtS;          /* error weight vectors for sensitivities       */
+  N_Vector *cv_yS;            /* yS=yS0 (allocated by the user)               */
+  N_Vector *cv_acorS;         /* acorS = yS_n(m) - yS_n(0)                    */
+  N_Vector *cv_tempvS;        /* temporary storage vector (~ tempv)           */
+  N_Vector *cv_ftempS;        /* temporary storage vector (~ ftemp)           */
+
+  booleantype cv_stgr1alloc;  /* Did we allocate ncfS1, ncfnS1, and nniS1?    */
+
+  /*--------------------------------------
+    Quadrature Sensitivity Related Vectors 
+    --------------------------------------*/
+
+  N_Vector *cv_znQS[L_MAX];   /* Nordsieck arrays for quadr. sensitivities    */
+  N_Vector *cv_ewtQS;         /* error weight vectors for sensitivities       */
+  N_Vector *cv_yQS;           /* Unlike yS, yQS is not allocated by the user  */
+  N_Vector *cv_acorQS;        /* acorQS = yQS_n(m) - yQS_n(0)                 */
+  N_Vector *cv_tempvQS;       /* temporary storage vector (~ tempv)           */
+  N_Vector cv_ftempQ;         /* temporary storage vector (~ ftemp)           */
+  
+  /*-----------------
+    Tstop information
+    -----------------*/
+
+  booleantype cv_tstopset;
+  realtype cv_tstop;
+
+  /*---------
+    Step Data 
+    ---------*/
+
+  int cv_q;                    /* current order                               */
+  int cv_qprime;               /* order to be used on the next step
+                                * qprime = q-1, q, or q+1                     */
+  int cv_next_q;               /* order to be used on the next step           */
+  int cv_qwait;                /* number of internal steps to wait before
+                                * considering a change in q                   */
+  int cv_L;                    /* L = q + 1                                   */
+
+  realtype cv_hin;
+  realtype cv_h;               /* current step size                           */
+  realtype cv_hprime;          /* step size to be used on the next step       */ 
+  realtype cv_next_h;          /* step size to be used on the next step       */ 
+  realtype cv_eta;             /* eta = hprime / h                            */
+  realtype cv_hscale;          /* value of h used in zn                       */
+  realtype cv_tn;              /* current internal value of t                 */
+  realtype cv_tretlast;        /* last value of t returned                    */
+
+  realtype cv_tau[L_MAX+1];    /* array of previous q+1 successful step
+                                * sizes indexed from 1 to q+1                 */
+  realtype cv_tq[NUM_TESTS+1]; /* array of test quantities indexed from
+                                * 1 to NUM_TESTS(=5)                          */
+  realtype cv_l[L_MAX];        /* coefficients of l(x) (degree q poly)        */
+
+  realtype cv_rl1;             /* the scalar 1/l[1]                           */
+  realtype cv_gamma;           /* gamma = h * rl1                             */
+  realtype cv_gammap;          /* gamma at the last setup call                */
+  realtype cv_gamrat;          /* gamma / gammap                              */
+
+  realtype cv_crate;           /* est. corrector conv. rate in Nls            */
+  realtype cv_crateS;          /* est. corrector conv. rate in NlsStgr        */
+  realtype cv_acnrm;           /* | acor |                                    */
+  realtype cv_acnrmQ;          /* | acorQ |                                   */
+  realtype cv_acnrmS;          /* | acorS |                                   */
+  realtype cv_acnrmQS;         /* | acorQS |                                  */
+  realtype cv_nlscoef;         /* coeficient in nonlinear convergence test    */
+  int  cv_mnewt;               /* Newton iteration counter                    */
+  int  *cv_ncfS1;              /* Array of Ns local counters for conv.  
+                                * failures (used in CVStep for STAGGERED1)    */
+
+  /*------
+    Limits 
+    ------*/
+
+  int cv_qmax;             /* q <= qmax                                       */
+  long int cv_mxstep;      /* maximum number of internal steps for one 
+			      user call                                       */
+  int cv_maxcor;           /* maximum number of corrector iterations for 
+			      the solution of the nonlinear equation          */
+  int cv_maxcorS;
+  int cv_mxhnil;           /* max. number of warning messages issued to the
+			      user that t + h == t for the next internal step */
+  int cv_maxnef;           /* maximum number of error test failures           */
+  int cv_maxncf;           /* maximum number of nonlinear conv. failures      */
+  
+  realtype cv_hmin;        /* |h| >= hmin                                     */
+  realtype cv_hmax_inv;    /* |h| <= 1/hmax_inv                               */
+  realtype cv_etamax;      /* eta <= etamax                                   */
+
+  /*----------
+    Counters 
+    ----------*/
+
+  long int cv_nst;         /* number of internal steps taken                  */
+
+  long int cv_nfe;         /* number of f calls                               */
+  long int cv_nfQe;        /* number of fQ calls                              */
+  long int cv_nfSe;        /* number of fS calls                              */
+  long int cv_nfeS;        /* number of f calls from sensi DQ                 */
+  long int cv_nfQSe;       /* number of fQS calls                             */
+  long int cv_nfQeS;       /* number of fQ calls from sensi DQ                */
+
+
+  long int cv_ncfn;        /* number of corrector convergence failures        */
+  long int cv_ncfnS;       /* number of total sensi. corr. conv. failures     */
+  long int *cv_ncfnS1;     /* number of sensi. corrector conv. failures       */
+
+  long int cv_nni;         /* number of nonlinear iterations performed        */
+  long int cv_nniS;        /* number of total sensi. nonlinear iterations     */
+  long int *cv_nniS1;      /* number of sensi. nonlinear iterations           */
+
+  long int cv_netf;        /* number of error test failures                   */
+  long int cv_netfQ;       /* number of quadr. error test failures            */
+  long int cv_netfS;       /* number of sensi. error test failures            */
+  long int cv_netfQS;      /* number of quadr. sensi. error test failures     */
+
+  long int cv_nsetups;     /* number of setup calls                           */
+  long int cv_nsetupsS;    /* number of setup calls due to sensitivities      */
+
+  int cv_nhnil;            /* number of messages issued to the user that
+			      t + h == t for the next iternal step            */
+
+  /*-----------------------------
+    Space requirements for CVODES 
+    -----------------------------*/
+
+  sunindextype cv_lrw1;        /* no. of realtype words in 1 N_Vector y           */ 
+  sunindextype cv_liw1;        /* no. of integer words in 1 N_Vector y            */ 
+  sunindextype cv_lrw1Q;       /* no. of realtype words in 1 N_Vector yQ          */ 
+  sunindextype cv_liw1Q;       /* no. of integer words in 1 N_Vector yQ           */ 
+  long int cv_lrw;             /* no. of realtype words in CVODES work vectors    */
+  long int cv_liw;             /* no. of integer words in CVODES work vectors     */
+
+  /*----------------
+    Step size ratios
+    ----------------*/
+
+  realtype cv_etaqm1;      /* ratio of new to old h for order q-1             */
+  realtype cv_etaq;        /* ratio of new to old h for order q               */
+  realtype cv_etaqp1;      /* ratio of new to old h for order q+1             */
+
+  /*------------------
+    Linear Solver Data 
+    ------------------*/
+
+  /* Linear Solver functions to be called */
+
+  int (*cv_linit)(struct CVodeMemRec *cv_mem);
+
+  int (*cv_lsetup)(struct CVodeMemRec *cv_mem, int convfail, 
+		   N_Vector ypred, N_Vector fpred, booleantype *jcurPtr, 
+		   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); 
+
+  int (*cv_lsolve)(struct CVodeMemRec *cv_mem, N_Vector b, N_Vector weight,
+		   N_Vector ycur, N_Vector fcur);
+
+  int (*cv_lfree)(struct CVodeMemRec *cv_mem);
+
+  /* Linear Solver specific memory */
+
+  void *cv_lmem;           
+
+  /* Flag to request a call to the setup routine */
+
+  booleantype cv_forceSetup;
+
+  /*------------
+    Saved Values
+    ------------*/
+
+  int cv_qu;                   /* last successful q value used                */
+  long int cv_nstlp;           /* step number of last setup call              */
+  realtype cv_h0u;             /* actual initial stepsize                     */
+  realtype cv_hu;              /* last successful h value used                */
+  realtype cv_saved_tq5;       /* saved value of tq[5]                        */
+  booleantype cv_jcur;         /* is Jacobian info for linear solver current? */
+  int cv_convfail;             /* flag storing previous solver failure mode   */
+  realtype cv_tolsf;           /* tolerance scale factor                      */
+  int cv_qmax_alloc;           /* qmax used when allocating mem               */
+  int cv_qmax_allocQ;          /* qmax used when allocating quad. mem         */
+  int cv_qmax_allocS;          /* qmax used when allocating sensi. mem        */
+  int cv_qmax_allocQS;         /* qmax used when allocating quad. sensi. mem  */
+  int cv_indx_acor;            /* index of zn vector in which acor is saved   */
+
+  /*--------------------------------------------------------------------
+    Flags turned ON by CVodeInit, CVodeSensMalloc, and CVodeQuadMalloc 
+    and read by CVodeReInit, CVodeSensReInit, and CVodeQuadReInit
+    --------------------------------------------------------------------*/
+
+  booleantype cv_VabstolMallocDone;
+  booleantype cv_MallocDone;
+  booleantype cv_constraintsMallocDone;
+
+  booleantype cv_VabstolQMallocDone;
+  booleantype cv_QuadMallocDone;
+
+  booleantype cv_VabstolSMallocDone;
+  booleantype cv_SabstolSMallocDone;
+  booleantype cv_SensMallocDone;
+
+  booleantype cv_VabstolQSMallocDone;
+  booleantype cv_SabstolQSMallocDone;
+  booleantype cv_QuadSensMallocDone;
+
+  /*-------------------------------------------
+    Error handler function and error ouput file 
+    -------------------------------------------*/
+
+  CVErrHandlerFn cv_ehfun;    /* Error messages are handled by ehfun          */
+  void *cv_eh_data;           /* dats pointer passed to ehfun                 */
+  FILE *cv_errfp;             /* CVODES error messages are sent to errfp      */    
+
+  /*-------------------------
+    Stability Limit Detection
+    -------------------------*/
+
+  booleantype cv_sldeton;     /* Is Stability Limit Detection on?             */
+  realtype cv_ssdat[6][4];    /* scaled data array for STALD                  */
+  int cv_nscon;               /* counter for STALD method                     */
+  long int cv_nor;            /* counter for number of order reductions       */
+
+  /*----------------
+    Rootfinding Data
+    ----------------*/
+
+  CVRootFn cv_gfun;        /* Function g for roots sought                     */
+  int cv_nrtfn;            /* number of components of g                       */
+  int *cv_iroots;          /* array for root information                      */
+  int *cv_rootdir;         /* array specifying direction of zero-crossing     */
+  realtype cv_tlo;         /* nearest endpoint of interval in root search     */
+  realtype cv_thi;         /* farthest endpoint of interval in root search    */
+  realtype cv_trout;       /* t value returned by rootfinding routine         */
+  realtype *cv_glo;        /* saved array of g values at t = tlo              */
+  realtype *cv_ghi;        /* saved array of g values at t = thi              */
+  realtype *cv_grout;      /* array of g values at t = trout                  */
+  realtype cv_toutc;       /* copy of tout (if NORMAL mode)                   */
+  realtype cv_ttol;        /* tolerance on root location trout                */
+  int cv_taskc;            /* copy of parameter itask                         */
+  int cv_irfnd;            /* flag showing whether last step had a root       */
+  long int cv_nge;         /* counter for g evaluations                       */
+  booleantype *cv_gactive; /* array with active/inactive event functions      */
+  int cv_mxgnull;          /* number of warning messages about possible g==0  */
+
+  /*------------------------
+    Adjoint sensitivity data
+    ------------------------*/
+
+  booleantype cv_adj;             /* SUNTRUE if performing ASA                */
+
+  struct CVadjMemRec *cv_adj_mem; /* Pointer to adjoint memory structure      */
+
+  booleantype cv_adjMallocDone;
+
+} *CVodeMem;
+
+
+/* 
+ * =================================================================
+ *   A D J O I N T   M O D U L E    M E M O R Y    B L O C K
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : struct CkpntMemRec, CkpntMem
+ * -----------------------------------------------------------------
+ * The type CkpntMem is type pointer to struct CkpntMemRec.
+ * This structure contains fields to store all information at a
+ * check point that is needed to 'hot' start cvodes.
+ * -----------------------------------------------------------------
+ */
+
+struct CkpntMemRec {
+
+  /* Integration limits */
+  realtype ck_t0;
+  realtype ck_t1;
+    
+  /* Nordsieck History Array */
+  N_Vector ck_zn[L_MAX];
+    
+  /* Do we need to carry quadratures? */
+  booleantype ck_quadr;
+    
+  /* Nordsieck History Array for quadratures */
+  N_Vector ck_znQ[L_MAX];
+    
+  /* Do we need to carry sensitivities? */
+  booleantype ck_sensi;
+
+  /* number of sensitivities */
+  int ck_Ns;
+
+  /* Nordsieck History Array for sensitivities */
+  N_Vector *ck_znS[L_MAX];
+
+  /* Do we need to carry quadrature sensitivities? */
+  booleantype ck_quadr_sensi;
+
+  /* Nordsieck History Array for quadrature sensitivities */
+  N_Vector *ck_znQS[L_MAX];
+    
+  /* Was ck_zn[qmax] allocated?
+     ck_zqm = 0    - no
+     ck_zqm = qmax - yes      */
+  int ck_zqm;
+    
+  /* Step data */
+  long int ck_nst;
+  realtype ck_tretlast;
+  int      ck_q;
+  int      ck_qprime;
+  int      ck_qwait;
+  int      ck_L;
+  realtype ck_gammap;
+  realtype ck_h;
+  realtype ck_hprime;
+  realtype ck_hscale;
+  realtype ck_eta;
+  realtype ck_etamax;
+  realtype ck_tau[L_MAX+1];
+  realtype ck_tq[NUM_TESTS+1];
+  realtype ck_l[L_MAX];
+    
+  /* Saved values */
+  realtype ck_saved_tq5;
+    
+  /* Pointer to next structure in list */
+  struct CkpntMemRec *ck_next;
+    
+};
+  
+/*
+ * -----------------------------------------------------------------
+ * Types for functions provided by an interpolation module
+ * -----------------------------------------------------------------
+ * cvaIMMallocFn: Type for a function that initializes the content
+ *                field of the structures in the dt array
+ * cvaIMFreeFn:   Type for a function that deallocates the content
+ *                field of the structures in the dt array
+ * cvaIMGetYFn:   Type for a function that returns the 
+ *                interpolated forward solution.
+ * cvaIMStorePnt: Type for a function that stores a new
+ *                point in the structure d
+ * -----------------------------------------------------------------
+ */
+
+typedef booleantype (*cvaIMMallocFn)(CVodeMem cv_mem);
+typedef void (*cvaIMFreeFn)(CVodeMem cv_mem);
+typedef int (*cvaIMGetYFn)(CVodeMem cv_mem, realtype t, N_Vector y, N_Vector *yS);
+typedef int (*cvaIMStorePntFn)(CVodeMem cv_mem, DtpntMem d);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : struct DtpntMemRec
+ * -----------------------------------------------------------------
+ * This structure contains fields to store all information at a
+ * data point that is needed to interpolate solution of forward
+ * simulations. Its content field depends on IMtype.
+ * -----------------------------------------------------------------
+ */
+  
+struct DtpntMemRec {
+  realtype t;    /* time */
+  void *content; /* IMtype-dependent content */
+};
+
+/* Data for cubic Hermite interpolation */
+typedef struct HermiteDataMemRec {
+  N_Vector y;
+  N_Vector yd;
+  N_Vector *yS;
+  N_Vector *ySd;
+} *HermiteDataMem;
+
+/* Data for polynomial interpolation */
+typedef struct PolynomialDataMemRec {
+  N_Vector y;
+  N_Vector *yS;
+  int order;
+} *PolynomialDataMem;
+
+
+/*
+ * -----------------------------------------------------------------
+ * Type : struct CVodeBMemRec
+ * -----------------------------------------------------------------
+ * The type CVodeBMem is a pointer to a structure which stores all
+ * information for ONE backward problem.
+ * The CVadjMem structure contains a linked list of CVodeBMem pointers
+ * -----------------------------------------------------------------
+ */
+
+struct CVodeBMemRec {
+
+  /* Index of this backward problem */
+  int cv_index;
+
+  /* Time at which the backward problem is initialized */
+  realtype cv_t0;
+  
+  /* CVODES memory for this backward problem */
+  CVodeMem cv_mem;
+
+  /* Flags to indicate that this backward problem's RHS or quad RHS
+   * require forward sensitivities */
+  booleantype cv_f_withSensi;
+  booleantype cv_fQ_withSensi;
+
+  /* Right hand side function for backward run */
+  CVRhsFnB cv_f;
+  CVRhsFnBS cv_fs;
+
+  /* Right hand side quadrature function for backward run */
+  CVQuadRhsFnB cv_fQ;
+  CVQuadRhsFnBS cv_fQs;
+
+  /* User user_data */
+  void *cv_user_data;
+    
+  /* Memory block for a linear solver's interface to CVODEA */
+  void *cv_lmem;
+
+  /* Function to free any memory allocated by the linear solver */
+  int (*cv_lfree)(CVodeBMem cvB_mem);
+
+  /* Memory block for a preconditioner's module interface to CVODEA */ 
+  void *cv_pmem;
+
+  /* Function to free any memory allocated by the preconditioner module */
+  int (*cv_pfree)(CVodeBMem cvB_mem);
+
+  /* Time at which to extract solution / quadratures */
+  realtype cv_tout;
+  
+  /* Workspace Nvector */
+  N_Vector cv_y;
+
+  /* Pointer to next structure in list */
+  struct CVodeBMemRec *cv_next;
+
+};
+
+/*
+ * -----------------------------------------------------------------
+ * Type : struct CVadjMemRec
+ * -----------------------------------------------------------------
+ * The type CVadjMem is type pointer to struct CVadjMemRec.
+ * This structure contins fields to store all information
+ * necessary for adjoint sensitivity analysis.
+ * -----------------------------------------------------------------
+ */
+
+struct CVadjMemRec {
+    
+  /* --------------------
+   * Forward problem data
+   * -------------------- */
+
+  /* Integration interval */
+  realtype ca_tinitial, ca_tfinal;
+
+  /* Flag for first call to CVodeF */
+  booleantype ca_firstCVodeFcall;
+
+  /* Flag if CVodeF was called with TSTOP */
+  booleantype ca_tstopCVodeFcall;
+  realtype ca_tstopCVodeF;
+    
+  /* ----------------------
+   * Backward problems data
+   * ---------------------- */
+
+  /* Storage for backward problems */
+  struct CVodeBMemRec *cvB_mem;
+
+  /* Number of backward problems */
+  int ca_nbckpbs;
+
+  /* Address of current backward problem */
+  struct CVodeBMemRec *ca_bckpbCrt;
+
+  /* Flag for first call to CVodeB */
+  booleantype ca_firstCVodeBcall;
+    
+  /* ----------------
+   * Check point data
+   * ---------------- */
+
+  /* Storage for check point information */
+  struct CkpntMemRec *ck_mem;
+
+  /* Number of check points */
+  int ca_nckpnts;
+
+  /* address of the check point structure for which data is available */
+  struct CkpntMemRec *ca_ckpntData;
+    
+  /* ------------------
+   * Interpolation data
+   * ------------------ */
+
+  /* Number of steps between 2 check points */
+  long int ca_nsteps;
+
+  /* Last index used in CVAfindIndex */
+  long int ca_ilast;
+  
+  /* Storage for data from forward runs */
+  struct DtpntMemRec **dt_mem;
+
+  /* Actual number of data points in dt_mem (typically np=nsteps+1) */
+  long int ca_np;
+    
+  /* Interpolation type */
+  int ca_IMtype;
+
+  /* Functions set by the interpolation module */
+  cvaIMMallocFn   ca_IMmalloc; 
+  cvaIMFreeFn     ca_IMfree;
+  cvaIMStorePntFn ca_IMstore; /* store a new interpolation point */
+  cvaIMGetYFn     ca_IMget;   /* interpolate forward solution    */
+
+  /* Flags controlling the interpolation module */
+  booleantype ca_IMmallocDone;   /* IM initialized? */
+  booleantype ca_IMnewData;      /* new data available in dt_mem?*/
+  booleantype ca_IMstoreSensi;   /* store sensitivities? */
+  booleantype ca_IMinterpSensi;  /* interpolate sensitivities? */
+
+  /* Workspace for the interpolation module */
+  N_Vector ca_Y[L_MAX];     /* pointers to zn[i] */
+  N_Vector *ca_YS[L_MAX];   /* pointers to znS[i] */
+  realtype ca_T[L_MAX];
+
+  /* -------------------------------
+   * Workspace for wrapper functions
+   * ------------------------------- */
+
+  N_Vector ca_ytmp;
+
+  N_Vector *ca_yStmp;
+    
+};
+  
+
+/*
+ * =================================================================
+ *     I N T E R F A C E   T O    L I N E A R   S O L V E R S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Communication between CVODE and a CVODE Linear Solver
+ * -----------------------------------------------------------------
+ * convfail (input to cv_lsetup)
+ *
+ * CV_NO_FAILURES : Either this is the first cv_setup call for this
+ *                  step, or the local error test failed on the
+ *                  previous attempt at this step (but the Newton
+ *                  iteration converged).
+ *
+ * CV_FAIL_BAD_J  : This value is passed to cv_lsetup if
+ *
+ *                  (a) The previous Newton corrector iteration
+ *                      did not converge and the linear solver's
+ *                      setup routine indicated that its Jacobian-
+ *                      related data is not current
+ *                                   or
+ *                  (b) During the previous Newton corrector
+ *                      iteration, the linear solver's solve routine
+ *                      failed in a recoverable manner and the
+ *                      linear solver's setup routine indicated that
+ *                      its Jacobian-related data is not current.
+ *
+ * CV_FAIL_OTHER  : During the current internal step try, the
+ *                  previous Newton iteration failed to converge
+ *                  even though the linear solver was using current
+ *                  Jacobian-related data.
+ * -----------------------------------------------------------------
+ */
+
+/* Constants for convfail (input to cv_lsetup) */
+
+#define CV_NO_FAILURES 0
+#define CV_FAIL_BAD_J  1
+#define CV_FAIL_OTHER  2
+
+/*
+ * -----------------------------------------------------------------
+ * int (*cv_linit)(CVodeMem cv_mem);
+ * -----------------------------------------------------------------
+ * The purpose of cv_linit is to complete initializations for a
+ * specific linear solver, such as counters and statistics.
+ * An LInitFn should return 0 if it has successfully initialized the
+ * CVODE linear solver and a negative value otherwise.
+ * If an error does occur, an appropriate message should be sent to
+ * the error handler function.
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * int (*cv_lsetup)(CVodeMem cv_mem, int convfail, N_Vector ypred,
+ *                 N_Vector fpred, booleantype *jcurPtr,
+ *                 N_Vector vtemp1, N_Vector vtemp2,
+ *                 N_Vector vtemp3);
+ * -----------------------------------------------------------------
+ * The job of cv_lsetup is to prepare the linear solver for
+ * subsequent calls to cv_lsolve. It may recompute Jacobian-
+ * related data is it deems necessary. Its parameters are as
+ * follows:
+ *
+ * cv_mem - problem memory pointer of type CVodeMem. See the
+ *          typedef earlier in this file.
+ *
+ * convfail - a flag to indicate any problem that occurred during
+ *            the solution of the nonlinear equation on the
+ *            current time step for which the linear solver is
+ *            being used. This flag can be used to help decide
+ *            whether the Jacobian data kept by a CVODE linear
+ *            solver needs to be updated or not.
+ *            Its possible values have been documented above.
+ *
+ * ypred - the predicted y vector for the current CVODE internal
+ *         step.
+ *
+ * fpred - f(tn, ypred).
+ *
+ * jcurPtr - a pointer to a boolean to be filled in by cv_lsetup.
+ *           The function should set *jcurPtr=SUNTRUE if its Jacobian
+ *           data is current after the call and should set
+ *           *jcurPtr=SUNFALSE if its Jacobian data is not current.
+ *           Note: If cv_lsetup calls for re-evaluation of
+ *           Jacobian data (based on convfail and CVODE state
+ *           data), it should return *jcurPtr=SUNTRUE always;
+ *           otherwise an infinite loop can result.
+ *
+ * vtemp1 - temporary N_Vector provided for use by cv_lsetup.
+ *
+ * vtemp3 - temporary N_Vector provided for use by cv_lsetup.
+ *
+ * vtemp3 - temporary N_Vector provided for use by cv_lsetup.
+ *
+ * The cv_lsetup routine should return 0 if successful, a positive
+ * value for a recoverable error, and a negative value for an
+ * unrecoverable error.
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * int (*cv_lsolve)(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+ *                  N_Vector ycur, N_Vector fcur);
+ * -----------------------------------------------------------------
+ * cv_lsolve must solve the linear equation P x = b, where
+ * P is some approximation to (I - gamma J), J = (df/dy)(tn,ycur)
+ * and the RHS vector b is input. The N-vector ycur contains
+ * the solver's current approximation to y(tn) and the vector
+ * fcur contains the N_Vector f(tn,ycur). The solution is to be
+ * returned in the vector b. cv_lsolve returns a positive value
+ * for a recoverable error and a negative value for an
+ * unrecoverable error. Success is indicated by a 0 return value.
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * int (*cv_lfree)(CVodeMem cv_mem);
+ * -----------------------------------------------------------------
+ * cv_lfree should free up any memory allocated by the linear
+ * solver. This routine is called once a problem has been
+ * completed and the linear solver is no longer needed.  It should 
+ * return 0 upon success, nonzero on failure.
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * =================================================================
+ *   C V O D E S    I N T E R N A L   F U N C T I O N S
+ * =================================================================
+ */
+  
+/* Prototype of internal ewtSet function */
+
+int cvEwtSet(N_Vector ycur, N_Vector weight, void *data);
+
+/* High level error handler */
+
+void cvProcessError(CVodeMem cv_mem, 
+		    int error_code, const char *module, const char *fname, 
+		    const char *msgfmt, ...);
+
+/* Prototype of internal errHandler function */
+
+void cvErrHandler(int error_code, const char *module, const char *function, 
+		  char *msg, void *data);
+
+/* Prototypes for internal sensitivity rhs wrappers */
+
+int cvSensRhsWrapper(CVodeMem cv_mem, realtype time, 
+                     N_Vector ycur, N_Vector fcur, 
+                     N_Vector *yScur, N_Vector *fScur,
+                     N_Vector temp1, N_Vector temp2);
+
+int cvSensRhs1Wrapper(CVodeMem cv_mem, realtype time, 
+                      N_Vector ycur, N_Vector fcur, 
+                      int is, N_Vector yScur, N_Vector fScur,
+                      N_Vector temp1, N_Vector temp2);
+
+/* Prototypes for internal sensitivity rhs DQ functions */
+
+int cvSensRhsInternalDQ(int Ns, realtype t, 
+                        N_Vector y, N_Vector ydot, 
+                        N_Vector *yS, N_Vector *ySdot, 
+                        void *fS_data,  
+                        N_Vector tempv, N_Vector ftemp);
+
+int cvSensRhs1InternalDQ(int Ns, realtype t, 
+                         N_Vector y, N_Vector ydot, 
+                         int is, N_Vector yS, N_Vector ySdot, 
+                         void *fS_data,
+                         N_Vector tempv, N_Vector ftemp);
+
+/* 
+ * =================================================================
+ *   C V O D E S    E R R O R    M E S S A G E S
+ * =================================================================
+ */
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+
+#define MSG_TIME        "t = %Lg"
+#define MSG_TIME_H      "t = %Lg and h = %Lg"
+#define MSG_TIME_INT    "t = %Lg is not between tcur - hu = %Lg and tcur = %Lg."
+#define MSG_TIME_TOUT   "tout = %Lg"
+#define MSG_TIME_TSTOP  "tstop = %Lg"
+
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+
+#define MSG_TIME        "t = %lg"
+#define MSG_TIME_H      "t = %lg and h = %lg"
+#define MSG_TIME_INT    "t = %lg is not between tcur - hu = %lg and tcur = %lg."
+#define MSG_TIME_TOUT   "tout = %lg"
+#define MSG_TIME_TSTOP  "tstop = %lg"
+
+#else
+
+#define MSG_TIME        "t = %g"
+#define MSG_TIME_H      "t = %g and h = %g"
+#define MSG_TIME_INT    "t = %g is not between tcur - hu = %g and tcur = %g."
+#define MSG_TIME_TOUT   "tout = %g"
+#define MSG_TIME_TSTOP  "tstop = %g"
+
+#endif
+
+
+/* Initialization and I/O error messages */
+
+#define MSGCV_NO_MEM "cvode_mem = NULL illegal."
+#define MSGCV_CVMEM_FAIL "Allocation of cvode_mem failed."
+#define MSGCV_MEM_FAIL "A memory request failed."
+#define MSGCV_BAD_LMM  "Illegal value for lmm. The legal values are CV_ADAMS and CV_BDF."
+#define MSGCV_BAD_ITER  "Illegal value for iter. The legal values are CV_FUNCTIONAL and CV_NEWTON."
+#define MSGCV_NO_MALLOC "Attempt to call before CVodeInit."
+#define MSGCV_NEG_MAXORD "maxord <= 0 illegal."
+#define MSGCV_BAD_MAXORD  "Illegal attempt to increase maximum method order."
+#define MSGCV_SET_SLDET  "Attempt to use stability limit detection with the CV_ADAMS method illegal."
+#define MSGCV_NEG_HMIN "hmin < 0 illegal."
+#define MSGCV_NEG_HMAX "hmax < 0 illegal."
+#define MSGCV_BAD_HMIN_HMAX "Inconsistent step size limits: hmin > hmax."
+#define MSGCV_BAD_RELTOL "reltol < 0 illegal."
+#define MSGCV_BAD_ABSTOL "abstol has negative component(s) (illegal)."
+#define MSGCV_NULL_ABSTOL "abstol = NULL illegal."
+#define MSGCV_NULL_Y0 "y0 = NULL illegal."
+#define MSGCV_Y0_FAIL_CONSTR "y0 fails to satisfy constraints."
+#define MSGCV_BAD_ISM_CONSTR "Constraints can not be enforced while forward sensitivity is used with simultaneous method"
+#define MSGCV_NULL_F "f = NULL illegal."
+#define MSGCV_NULL_G "g = NULL illegal."
+#define MSGCV_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGCV_BAD_CONSTR "Illegal values in constraints vector."
+#define MSGCV_BAD_K "Illegal value for k."
+#define MSGCV_NULL_DKY "dky = NULL illegal."
+#define MSGCV_BAD_T "Illegal value for t." MSG_TIME_INT
+#define MSGCV_NO_ROOT "Rootfinding was not initialized."
+
+#define MSGCV_NO_QUAD  "Quadrature integration not activated."
+#define MSGCV_BAD_ITOLQ "Illegal value for itolQ. The legal values are CV_SS and CV_SV."
+#define MSGCV_NULL_ABSTOLQ "abstolQ = NULL illegal."
+#define MSGCV_BAD_RELTOLQ "reltolQ < 0 illegal."
+#define MSGCV_BAD_ABSTOLQ "abstolQ has negative component(s) (illegal)."  
+
+#define MSGCV_SENSINIT_2 "Sensitivity analysis already initialized."
+#define MSGCV_NO_SENSI  "Forward sensitivity analysis not activated."
+#define MSGCV_BAD_ITOLS "Illegal value for itolS. The legal values are CV_SS, CV_SV, and CV_EE."
+#define MSGCV_NULL_ABSTOLS "abstolS = NULL illegal."
+#define MSGCV_BAD_RELTOLS "reltolS < 0 illegal."
+#define MSGCV_BAD_ABSTOLS "abstolS has negative component(s) (illegal)."  
+#define MSGCV_BAD_PBAR "pbar has zero component(s) (illegal)."
+#define MSGCV_BAD_PLIST "plist has negative component(s) (illegal)."
+#define MSGCV_BAD_NS "NS <= 0 illegal."
+#define MSGCV_NULL_YS0 "yS0 = NULL illegal."
+#define MSGCV_BAD_ISM "Illegal value for ism. Legal values are: CV_SIMULTANEOUS, CV_STAGGERED and CV_STAGGERED1."
+#define MSGCV_BAD_IFS "Illegal value for ifS. Legal values are: CV_ALLSENS and CV_ONESENS."
+#define MSGCV_BAD_ISM_IFS "Illegal ism = CV_STAGGERED1 for CVodeSensInit."
+#define MSGCV_BAD_IS "Illegal value for is."
+#define MSGCV_NULL_DKYA "dkyA = NULL illegal."
+#define MSGCV_BAD_DQTYPE "Illegal value for DQtype. Legal values are: CV_CENTERED and CV_FORWARD."
+#define MSGCV_BAD_DQRHO "DQrhomax < 0 illegal."
+
+#define MSGCV_BAD_ITOLQS "Illegal value for itolQS. The legal values are CV_SS, CV_SV, and CV_EE."
+#define MSGCV_NULL_ABSTOLQS "abstolQS = NULL illegal."
+#define MSGCV_BAD_RELTOLQS "reltolQS < 0 illegal."
+#define MSGCV_BAD_ABSTOLQS "abstolQS has negative component(s) (illegal)."  
+#define MSGCV_NO_QUADSENSI  "Forward sensitivity analysis for quadrature variables not activated."
+#define MSGCV_NULL_YQS0 "yQS0 = NULL illegal."
+
+/* CVode Error Messages */
+
+#define MSGCV_NO_TOL "No integration tolerances have been specified."
+#define MSGCV_LSOLVE_NULL "The linear solver's solve routine is NULL."
+#define MSGCV_YOUT_NULL "yout = NULL illegal."
+#define MSGCV_TRET_NULL "tret = NULL illegal."
+#define MSGCV_BAD_EWT "Initial ewt has component(s) equal to zero (illegal)."
+#define MSGCV_EWT_NOW_BAD "At " MSG_TIME ", a component of ewt has become <= 0."
+#define MSGCV_BAD_ITASK "Illegal value for itask."
+#define MSGCV_BAD_H0 "h0 and tout - t0 inconsistent."
+#define MSGCV_BAD_TOUT "Trouble interpolating at " MSG_TIME_TOUT ". tout too far back in direction of integration"
+#define MSGCV_EWT_FAIL "The user-provide EwtSet function failed."
+#define MSGCV_EWT_NOW_FAIL "At " MSG_TIME ", the user-provide EwtSet function failed."
+#define MSGCV_LINIT_FAIL "The linear solver's init routine failed."
+#define MSGCV_HNIL_DONE "The above warning has been issued mxhnil times and will not be issued again for this problem."
+#define MSGCV_TOO_CLOSE "tout too close to t0 to start integration."
+#define MSGCV_MAX_STEPS "At " MSG_TIME ", mxstep steps taken before reaching tout."
+#define MSGCV_TOO_MUCH_ACC "At " MSG_TIME ", too much accuracy requested."
+#define MSGCV_HNIL "Internal " MSG_TIME_H " are such that t + h = t on the next step. The solver will continue anyway."
+#define MSGCV_ERR_FAILS "At " MSG_TIME_H ", the error test failed repeatedly or with |h| = hmin."
+#define MSGCV_CONV_FAILS "At " MSG_TIME_H ", the corrector convergence test failed repeatedly or with |h| = hmin."
+#define MSGCV_SETUP_FAILED "At " MSG_TIME ", the setup routine failed in an unrecoverable manner."
+#define MSGCV_SOLVE_FAILED "At " MSG_TIME ", the solve routine failed in an unrecoverable manner."
+#define MSGCV_FAILED_CONSTR "At " MSG_TIME ", unable to satisfy inequality constraints."
+#define MSGCV_RHSFUNC_FAILED "At " MSG_TIME ", the right-hand side routine failed in an unrecoverable manner."
+#define MSGCV_RHSFUNC_UNREC "At " MSG_TIME ", the right-hand side failed in a recoverable manner, but no recovery is possible."
+#define MSGCV_RHSFUNC_REPTD "At " MSG_TIME " repeated recoverable right-hand side function errors."
+#define MSGCV_RHSFUNC_FIRST "The right-hand side routine failed at the first call."
+#define MSGCV_RTFUNC_FAILED "At " MSG_TIME ", the rootfinding routine failed in an unrecoverable manner."
+#define MSGCV_CLOSE_ROOTS "Root found at and very near " MSG_TIME "."
+#define MSGCV_BAD_TSTOP "The value " MSG_TIME_TSTOP " is behind current " MSG_TIME " in the direction of integration."
+#define MSGCV_INACTIVE_ROOTS "At the end of the first step, there are still some root functions identically 0. This warning will not be issued again."
+
+#define MSGCV_NO_TOLQ "No integration tolerances for quadrature variables have been specified."
+#define MSGCV_BAD_EWTQ "Initial ewtQ has component(s) equal to zero (illegal)."
+#define MSGCV_EWTQ_NOW_BAD "At " MSG_TIME ", a component of ewtQ has become <= 0."
+#define MSGCV_QRHSFUNC_FAILED "At " MSG_TIME ", the quadrature right-hand side routine failed in an unrecoverable manner."
+#define MSGCV_QRHSFUNC_UNREC "At " MSG_TIME ", the quadrature right-hand side failed in a recoverable manner, but no recovery is possible."
+#define MSGCV_QRHSFUNC_REPTD "At " MSG_TIME " repeated recoverable quadrature right-hand side function errors."
+#define MSGCV_QRHSFUNC_FIRST "The quadrature right-hand side routine failed at the first call."
+
+#define MSGCV_NO_TOLS "No integration tolerances for sensitivity variables have been specified."
+#define MSGCV_NULL_P "p = NULL when using internal DQ for sensitivity RHS illegal."
+#define MSGCV_BAD_EWTS "Initial ewtS has component(s) equal to zero (illegal)."
+#define MSGCV_EWTS_NOW_BAD "At " MSG_TIME ", a component of ewtS has become <= 0."
+#define MSGCV_SRHSFUNC_FAILED "At " MSG_TIME ", the sensitivity right-hand side routine failed in an unrecoverable manner."
+#define MSGCV_SRHSFUNC_UNREC "At " MSG_TIME ", the sensitivity right-hand side failed in a recoverable manner, but no recovery is possible."
+#define MSGCV_SRHSFUNC_REPTD "At " MSG_TIME " repeated recoverable sensitivity right-hand side function errors."
+#define MSGCV_SRHSFUNC_FIRST "The sensitivity right-hand side routine failed at the first call."
+
+#define MSGCV_NULL_FQ "CVODES is expected to use DQ to evaluate the RHS of quad. sensi., but quadratures were not initialized."
+#define MSGCV_NO_TOLQS "No integration tolerances for quadrature sensitivity variables have been specified."
+#define MSGCV_BAD_EWTQS "Initial ewtQS has component(s) equal to zero (illegal)."
+#define MSGCV_EWTQS_NOW_BAD "At " MSG_TIME ", a component of ewtQS has become <= 0."
+#define MSGCV_QSRHSFUNC_FAILED "At " MSG_TIME ", the quadrature sensitivity right-hand side routine failed in an unrecoverable manner."
+#define MSGCV_QSRHSFUNC_UNREC "At " MSG_TIME ", the quadrature sensitivity right-hand side failed in a recoverable manner, but no recovery is possible."
+#define MSGCV_QSRHSFUNC_REPTD "At " MSG_TIME " repeated recoverable quadrature sensitivity right-hand side function errors."
+#define MSGCV_QSRHSFUNC_FIRST "The quadrature sensitivity right-hand side routine failed at the first call."
+
+/* 
+ * =================================================================
+ *   C V O D E A    E R R O R    M E S S A G E S
+ * =================================================================
+ */
+
+#define MSGCV_NO_ADJ      "Illegal attempt to call before calling CVodeAdjMalloc."
+#define MSGCV_BAD_STEPS   "Steps nonpositive illegal."
+#define MSGCV_BAD_INTERP  "Illegal value for interp."
+#define MSGCV_BAD_WHICH   "Illegal value for which."
+#define MSGCV_NO_BCK      "No backward problems have been defined yet."
+#define MSGCV_NO_FWD      "Illegal attempt to call before calling CVodeF."
+#define MSGCV_BAD_TB0     "The initial time tB0 for problem %d is outside the interval over which the forward problem was solved."
+#define MSGCV_BAD_SENSI   "At least one backward problem requires sensitivities, but they were not stored for interpolation."
+#define MSGCV_BAD_ITASKB  "Illegal value for itaskB. Legal values are CV_NORMAL and CV_ONE_STEP."
+#define MSGCV_BAD_TBOUT   "The final time tBout is outside the interval over which the forward problem was solved."
+#define MSGCV_BACK_ERROR  "Error occured while integrating backward problem # %d" 
+#define MSGCV_BAD_TINTERP "Bad t = %g for interpolation."
+#define MSGCV_WRONG_INTERP "This function cannot be called for the specified interp type."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_spils.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_spils.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/cvodes/cvodes_spils.h	(revision 16222)
@@ -0,0 +1,544 @@
+/*----------------------------------------------------------------- 
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *                Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the Scaled, Preconditioned Iterative 
+ * Linear Solver interface in CVODES.
+ *
+ * Part I contains type definitions and functions for using the 
+ * iterative linear solvers on forward problems 
+ * (IVP integration and/or FSA)
+ *
+ * Part II contains type definitions and functions for using the 
+ * iterative linear solvers on adjoint (backward) problems
+ * -----------------------------------------------------------------*/
+
+#ifndef _CVSSPILS_H
+#define _CVSSPILS_H
+
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_linearsolver.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*-----------------------------------------------------------------
+  CVSSPILS return values 
+  -----------------------------------------------------------------*/
+
+#define CVSPILS_SUCCESS          0
+#define CVSPILS_MEM_NULL        -1
+#define CVSPILS_LMEM_NULL       -2
+#define CVSPILS_ILL_INPUT       -3
+#define CVSPILS_MEM_FAIL        -4
+#define CVSPILS_PMEM_NULL       -5
+#define CVSPILS_SUNLS_FAIL      -6
+
+/* Return values for the adjoint module */
+
+#define CVSPILS_NO_ADJ          -101
+#define CVSPILS_LMEMB_NULL      -102
+
+/*-----------------------------------------------------------------
+  CVSSPILS solver constants
+  -----------------------------------------------------------------
+  CVSPILS_MSBPRE : maximum number of steps between
+                   preconditioner evaluations
+ 
+  CVSPILS_DGMAX  : maximum change in gamma between
+                   preconditioner evaluations
+ 
+  CVSPILS_EPLIN  : default value for factor by which the
+                   tolerance on the nonlinear iteration is
+                   multiplied to get a tolerance on the linear
+                   iteration
+  -----------------------------------------------------------------*/
+
+#define CVSPILS_MSBPRE 50
+#define CVSPILS_DGMAX  RCONST(0.2)
+#define CVSPILS_EPLIN  RCONST(0.05)
+
+/*-----------------------------------------------------------------
+  PART I - forward problems
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsPrecSetupFn
+  -----------------------------------------------------------------
+  The user-supplied preconditioner setup function PrecSetup and
+  the user-supplied preconditioner solve function PrecSolve
+  together must define left and right preconditoner matrices
+  P1 and P2 (either of which may be trivial), such that the
+  product P1*P2 is an approximation to the Newton matrix
+  M = I - gamma*J.  Here J is the system Jacobian J = df/dy,
+  and gamma is a scalar proportional to the integration step
+  size h.  The solution of systems P z = r, with P = P1 or P2,
+  is to be carried out by the PrecSolve function, and PrecSetup
+  is to do any necessary setup operations.
+ 
+  The user-supplied preconditioner setup function PrecSetup
+  is to evaluate and preprocess any Jacobian-related data
+  needed by the preconditioner solve function PrecSolve.
+  This might include forming a crude approximate Jacobian,
+  and performing an LU factorization on the resulting
+  approximation to M.  This function will not be called in
+  advance of every call to PrecSolve, but instead will be called
+  only as often as necessary to achieve convergence within the
+  Inexact Newton iteration.  If the PrecSolve function needs no
+  preparation, the PrecSetup function can be NULL.
+ 
+  For greater efficiency, the PrecSetup function may save
+  Jacobian-related data and reuse it, rather than generating it
+  from scratch.  In this case, it should use the input flag jok
+  to decide whether to recompute the data, and set the output
+  flag *jcurPtr accordingly.
+ 
+  Each call to the PrecSetup function is preceded by a call to
+  the RhsFn f with the same (t,y) arguments.  Thus the PrecSetup
+  function can use any auxiliary data that is computed and
+  saved by the f function and made accessible to PrecSetup.
+ 
+  A function PrecSetup must have the prototype given below.
+  Its parameters are as follows:
+ 
+  t       is the current value of the independent variable.
+ 
+  y       is the current value of the dependent variable vector,
+           namely the predicted value of y(t).
+ 
+  fy      is the vector f(t,y).
+ 
+  jok     is an input flag indicating whether Jacobian-related
+          data needs to be recomputed, as follows:
+            jok == SUNFALSE means recompute Jacobian-related data
+                   from scratch.
+            jok == SUNTRUE  means that Jacobian data, if saved from
+                   the previous PrecSetup call, can be reused
+                   (with the current value of gamma).
+          A Precset call with jok == SUNTRUE can only occur after
+          a call with jok == SUNFALSE.
+ 
+  jcurPtr is a pointer to an output integer flag which is
+          to be set by PrecSetup as follows:
+          Set *jcurPtr = SUNTRUE if Jacobian data was recomputed.
+          Set *jcurPtr = SUNFALSE if Jacobian data was not recomputed,
+                         but saved data was reused.
+ 
+  gamma   is the scalar appearing in the Newton matrix.
+ 
+  user_data  is a pointer to user data - the same as the user_data
+          parameter passed to the CVodeSetUserData function.
+ 
+  NOTE: If the user's preconditioner needs other quantities,
+        they are accessible as follows: hcur (the current stepsize)
+        and ewt (the error weight vector) are accessible through
+        CVodeGetCurrentStep and CVodeGetErrWeights, respectively).
+        The unit roundoff is available as UNIT_ROUNDOFF defined in
+        sundials_types.h.
+ 
+  Returned value:
+  The value to be returned by the PrecSetup function is a flag
+  indicating whether it was successful.  This value should be
+    0   if successful,
+    > 0 for a recoverable error (step will be retried),
+    < 0 for an unrecoverable error (integration is halted).
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsPrecSetupFn)(realtype t, N_Vector y, N_Vector fy,
+				  booleantype jok, booleantype *jcurPtr,
+				  realtype gamma, void *user_data);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsPrecSolveFn
+  -----------------------------------------------------------------
+  The user-supplied preconditioner solve function PrecSolve
+  is to solve a linear system P z = r in which the matrix P is
+  one of the preconditioner matrices P1 or P2, depending on the
+  type of preconditioning chosen.
+ 
+  A function PrecSolve must have the prototype given below.
+  Its parameters are as follows:
+ 
+  t      is the current value of the independent variable.
+ 
+  y      is the current value of the dependent variable vector.
+ 
+  fy     is the vector f(t,y).
+ 
+  r      is the right-hand side vector of the linear system.
+ 
+  z      is the output vector computed by PrecSolve.
+ 
+  gamma  is the scalar appearing in the Newton matrix.
+ 
+  delta  is an input tolerance for use by PSolve if it uses
+         an iterative method in its solution.  In that case,
+         the residual vector Res = r - P z of the system
+         should be made less than delta in weighted L2 norm,
+         i.e., sqrt [ Sum (Res[i]*ewt[i])^2 ] < delta.
+         Note: the error weight vector ewt can be obtained
+         through a call to the routine CVodeGetErrWeights.
+ 
+  lr     is an input flag indicating whether PrecSolve is to use
+         the left preconditioner P1 or right preconditioner
+         P2: lr = 1 means use P1, and lr = 2 means use P2.
+ 
+  user_data is a pointer to user data - the same as the user_data
+         parameter passed to the CVodeSetUserData function.
+ 
+  Returned value:
+  The value to be returned by the PrecSolve function is a flag
+  indicating whether it was successful.  This value should be
+    0 if successful,
+    positive for a recoverable error (step will be retried),
+    negative for an unrecoverable error (integration is halted).
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsPrecSolveFn)(realtype t, N_Vector y, N_Vector fy,
+				  N_Vector r, N_Vector z, realtype gamma, 
+				  realtype delta, int lr, void *user_data);
+
+/*---------------------------------------------------------------
+  Type: CVSpilsJacTimesSetupFn
+ 
+  The user-supplied Jacobian-times-vector product setup function 
+  JacTimesSetup and the user-supplied Jacobian-times-vector 
+  product function JTimes together must generate the product
+  J*v for v, where J is the Jacobian df/dy, or an approximation 
+  to it, and v is a given vector. It should return 0 if 
+  successful a positive value for a recoverable error or a
+  negative value for an unrecoverable failure.
+ 
+  Each call to the JacTimesSetup function is preceded by a call 
+  to the RhsFn fi with the same (t,y) arguments.  Thus the 
+  JacTimesSetup function can use any auxiliary data that is 
+  computed and saved by the f function and made accessible to 
+  JacTimesSetup.
+ 
+  A function JacTimesSetup must have the prototype given below.
+  Its parameters are as follows:
+ 
+  t       is the current value of the independent variable.
+ 
+  y       is the current value of the dependent variable vector,
+           namely the predicted value of y(t).
+ 
+  fy      is the vector f(t,y).
+ 
+  user_data  is a pointer to user data - the same as the user_data
+          parameter passed to the CVodeSetUserData function.
+ 
+  Returned value:
+  The value to be returned by the JacTimesSetup function is a flag
+  indicating whether it was successful.  This value should be
+    0   if successful,
+    > 0 for a recoverable error (step will be retried),
+    < 0 for an unrecoverable error (integration is halted).
+  ---------------------------------------------------------------*/
+typedef int (*CVSpilsJacTimesSetupFn)(realtype t, N_Vector y, 
+                                      N_Vector fy, void *user_data);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsJacTimesVecFn
+  -----------------------------------------------------------------
+  The user-supplied function jtimes is to generate the product
+  J*v for given v, where J is the Jacobian df/dy, or an
+  approximation to it, and v is a given vector. It should return
+  0 if successful a positive value for a recoverable error or 
+  a negative value for an unrecoverable failure.
+ 
+  A function jtimes must have the prototype given below. Its
+  parameters are as follows:
+ 
+    v        is the N_Vector to be multiplied by J.
+ 
+    Jv       is the output N_Vector containing J*v.
+ 
+    t        is the current value of the independent variable.
+ 
+    y        is the current value of the dependent variable
+             vector.
+ 
+    fy       is the vector f(t,y).
+ 
+    user_data   is a pointer to user data, the same as the user_data
+             parameter passed to the CVodeSetUserData function. 
+ 
+    tmp      is a pointer to memory allocated for an N_Vector
+             which can be used by Jtimes for work space.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsJacTimesVecFn)(N_Vector v, N_Vector Jv, realtype t,
+				    N_Vector y, N_Vector fy,
+				    void *user_data, N_Vector tmp);
+
+/*=================================================================
+  CVSSPILS Exported functions
+  =================================================================*/
+
+/*-----------------------------------------------------------------
+  Required inputs to the CVSSPILS linear solver interface
+  -----------------------------------------------------------------
+ 
+  CVSpilsSetLinearSolver specifies the iterative SUNLinearSolver 
+  object that CVode should use.  This is required if CVode is 
+  solving a problem with the Newton nonlinear solver (i.e. not the 
+  functional iteration).
+ 
+  The return value is one of:
+     CVSPILS_SUCCESS   if successful
+     CVSPILS_MEM_NULL  if the CVODE memory was NULL
+     CVSPILS_ILL_INPUT if the linear solver memory was NULL
+ ---------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVSpilsSetLinearSolver(void *cvode_mem, 
+                                           SUNLinearSolver LS);
+
+
+/*-----------------------------------------------------------------
+  Optional inputs to the CVSSPILS linear solver
+  -----------------------------------------------------------------
+ 
+  CVSpilsSetEpsLin specifies the factor by which the tolerance on
+                 the nonlinear iteration is multiplied to get a
+                 tolerance on the linear iteration.
+                 Default value is 0.05.
+ 
+  CVSpilsSetPreconditioner specifies the PrecSetup and PrecSolve 
+                 functions.  Default is NULL for both arguments 
+                 (no preconditioning)
+ 
+  CVSpilsSetJacTimes specifies the jtsetup and jtimes functions. 
+                 Default is to use an internal finite difference 
+                 approximation routine with no extra jtsetup.
+ 
+  The return value of CVSpilsSet* is one of:
+     CVSPILS_SUCCESS   if successful
+     CVSPILS_MEM_NULL  if the cvode memory was NULL
+     CVSPILS_LMEM_NULL if the linear solver memory was NULL
+     CVSPILS_ILL_INPUT if an input has an illegal value
+  -----------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int CVSpilsSetEpsLin(void *cvode_mem, realtype eplifac);
+SUNDIALS_EXPORT int CVSpilsSetPreconditioner(void *cvode_mem,
+                                             CVSpilsPrecSetupFn pset, 
+					     CVSpilsPrecSolveFn psolve);
+SUNDIALS_EXPORT int CVSpilsSetJacTimes(void *cvode_mem,
+                                       CVSpilsJacTimesSetupFn jtsetup,
+                                       CVSpilsJacTimesVecFn jtimes);
+
+/*-----------------------------------------------------------------
+  Optional outputs from the CVSSPILS linear solver
+  -----------------------------------------------------------------
+  CVSpilsGetWorkSpace returns the real and integer workspace used
+                 by the SPILS module.
+ 
+  CVSpilsGetNumPrecEvals returns the number of preconditioner
+                  evaluations, i.e. the number of calls made
+                  to PrecSetup with jok==SUNFALSE.
+ 
+  CVSpilsGetNumPrecSolves returns the number of calls made to
+                  PrecSolve.
+ 
+  CVSpilsGetNumLinIters returns the number of linear iterations.
+ 
+  CVSpilsGetNumConvFails returns the number of linear
+                  convergence failures.
+ 
+  CVSpilsGetNumJTSetupEvals returns the number of calls to jtsetup.
+ 
+  CVSpilsGetNumJtimesEvals returns the number of calls to jtimes.
+ 
+  CVSpilsGetNumRhsEvals returns the number of calls to the user
+                  f routine due to finite difference Jacobian
+                  times vector evaluation.
+ 
+  CVSpilsGetLastFlag returns the last error flag set by any of
+                  the CVSPILS interface functions.
+ 
+  The return value of CVSpilsGet* is one of:
+     CVSPILS_SUCCESS   if successful
+     CVSPILS_MEM_NULL  if the cvode memory was NULL
+     CVSPILS_LMEM_NULL if the linear solver memory was NULL
+  -----------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int CVSpilsGetWorkSpace(void *cvode_mem,
+                                        long int *lenrwLS,
+                                        long int *leniwLS);
+SUNDIALS_EXPORT int CVSpilsGetNumPrecEvals(void *cvode_mem,
+                                           long int *npevals);
+SUNDIALS_EXPORT int CVSpilsGetNumPrecSolves(void *cvode_mem,
+                                            long int *npsolves);
+SUNDIALS_EXPORT int CVSpilsGetNumLinIters(void *cvode_mem,
+                                          long int *nliters);
+SUNDIALS_EXPORT int CVSpilsGetNumConvFails(void *cvode_mem,
+                                           long int *nlcfails);
+SUNDIALS_EXPORT int CVSpilsGetNumJTSetupEvals(void *cvode_mem,
+                                              long int *njtsetups);
+SUNDIALS_EXPORT int CVSpilsGetNumJtimesEvals(void *cvode_mem,
+                                             long int *njvevals);
+SUNDIALS_EXPORT int CVSpilsGetNumRhsEvals(void *cvode_mem,
+                                          long int *nfevalsLS); 
+SUNDIALS_EXPORT int CVSpilsGetLastFlag(void *cvode_mem,
+                                       long int *flag);
+
+/*-----------------------------------------------------------------
+  The following function returns the name of the constant 
+  associated with a CVSSPILS return flag
+  -----------------------------------------------------------------*/
+SUNDIALS_EXPORT char *CVSpilsGetReturnFlagName(long int flag);
+
+
+/*-----------------------------------------------------------------
+  PART II - backward problems
+  -----------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsPrecSetupFnB
+  -----------------------------------------------------------------
+  A function PrecSetupB for the adjoint (backward) problem must 
+  have the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsPrecSetupFnB)(realtype t, N_Vector y, N_Vector yB,
+                                   N_Vector fyB, booleantype jokB,
+                                   booleantype *jcurPtrB,
+                                   realtype gammaB, void *user_dataB);
+
+
+/*----------------------------------------------------------------
+  Type : CVSpilsPrecSetupFnBS
+  -----------------------------------------------------------------
+  A function PrecSetupBS for the adjoint (backward) problem must 
+  have the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsPrecSetupFnBS)(realtype t, N_Vector y,
+                                    N_Vector *yS, N_Vector yB,
+                                    N_Vector fyB, booleantype jokB,
+                                    booleantype *jcurPtrB,
+                                    realtype gammaB, void *user_dataB);
+
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsPrecSolveFnB
+  -----------------------------------------------------------------
+  A function PrecSolveB for the adjoint (backward) problem  must 
+  have the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsPrecSolveFnB)(realtype t, N_Vector y, N_Vector yB, 
+                                   N_Vector fyB, N_Vector rB, 
+                                   N_Vector zB, realtype gammaB,
+                                   realtype deltaB, int lrB,
+                                   void *user_dataB);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsPrecSolveFnBS
+  -----------------------------------------------------------------
+  A function PrecSolveBS for the adjoint (backward) problem  must 
+  have the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsPrecSolveFnBS)(realtype t, N_Vector y, N_Vector *yS,
+                                    N_Vector yB, N_Vector fyB,
+                                    N_Vector rB, N_Vector zB,
+                                    realtype gammaB, realtype deltaB,
+                                    int lrB, void *user_dataB);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsJacTimesSetupFnB
+  -----------------------------------------------------------------
+  A function jtsetupB for the adjoint (backward) problem must have 
+  the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsJacTimesSetupFnB)(realtype t, N_Vector y, N_Vector yB,
+                                       N_Vector fyB, void *jac_dataB);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsJacTimesSetupFnBS
+  -----------------------------------------------------------------
+  A function jtsetupBS for the adjoint (backward) problem must have 
+  the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsJacTimesSetupFnBS)(realtype t, N_Vector y,
+                                        N_Vector *yS, N_Vector yB,
+                                        N_Vector fyB, void *jac_dataB);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsJacTimesVecFnB
+  -----------------------------------------------------------------
+  A function jtimesB for the adjoint (backward) problem must have 
+  the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsJacTimesVecFnB)(N_Vector vB, N_Vector JvB, realtype t,
+                                     N_Vector y, N_Vector yB, N_Vector fyB,
+                                     void *jac_dataB, N_Vector tmpB);
+
+/*-----------------------------------------------------------------
+  Type : CVSpilsJacTimesVecFnBS
+  -----------------------------------------------------------------
+  A function jtimesBS for the adjoint (backward) problem must have 
+  the prototype given below.
+  -----------------------------------------------------------------*/
+typedef int (*CVSpilsJacTimesVecFnBS)(N_Vector vB, N_Vector JvB,
+                                      realtype t, N_Vector y, N_Vector *yS,
+                                      N_Vector yB, N_Vector fyB,
+                                      void *jac_dataB, N_Vector tmpB);
+
+/*-----------------------------------------------------------------
+  Functions
+  -----------------------------------------------------------------*/
+
+/*---------------------------------------------------------------
+  Required input for the CVSSPILS linear solver interface:
+
+  CVSpilsSetLinearSolverB specifies the iterative SUNLinearSolver 
+  object that should be used for the backwards integration.  The 
+  'which' argument is the int returned by CVodeCreateB.
+
+  The return value is one of:
+     CVSPILS_SUCCESS   if successful
+     CVSPILS_MEM_NULL  if the cvode memory was NULL
+     CVSPILS_ILL_INPUT if the linear solver memory was NULL
+  ---------------------------------------------------------------*/
+SUNDIALS_EXPORT int CVSpilsSetLinearSolverB(void *cvode_mem,
+                                            int which,
+                                            SUNLinearSolver LS);
+
+/*-----------------------------------------------------------------
+  Each CVSpilsSet***B or CVSpilsSet***BS function below links the
+  main CVODES integrator with the corresponding CVSpilsSet***
+  optional input function for the backward integration.
+  The 'which' argument is the int returned by CVodeCreateB.
+  -----------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int CVSpilsSetEpsLinB(void *cvode_mem, int which, realtype eplifacB);
+
+SUNDIALS_EXPORT int CVSpilsSetPreconditionerB(void *cvode_mem, int which, 
+                                              CVSpilsPrecSetupFnB psetB,
+					      CVSpilsPrecSolveFnB psolveB);
+SUNDIALS_EXPORT int CVSpilsSetPreconditionerBS(void *cvode_mem, int which, 
+                                               CVSpilsPrecSetupFnBS psetBS,
+					       CVSpilsPrecSolveFnBS psolveBS);
+
+SUNDIALS_EXPORT int CVSpilsSetJacTimesB(void *cvode_mem, int which, 
+                                        CVSpilsJacTimesSetupFnB jtsetupB,
+                                        CVSpilsJacTimesVecFnB jtimesB);
+SUNDIALS_EXPORT int CVSpilsSetJacTimesBS(void *cvode_mem, int which, 
+                                         CVSpilsJacTimesSetupFnBS jtsetupBS,
+                                         CVSpilsJacTimesVecFnBS jtimesBS);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/nvector/nvector_serial.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/nvector/nvector_serial.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/nvector/nvector_serial.h	(revision 16222)
@@ -0,0 +1,289 @@
+/* -----------------------------------------------------------------
+ * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
+ *                and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the serial implementation of the
+ * NVECTOR module.
+ *
+ * Part I contains declarations specific to the serial
+ * implementation of the supplied NVECTOR module.
+ *
+ * Part II defines accessor macros that allow the user to
+ * efficiently use the type N_Vector without making explicit
+ * references to the underlying data structure.
+ *
+ * Part III contains the prototype for the constructor N_VNew_Serial
+ * as well as implementation-specific prototypes for various useful
+ * vector operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic N_Vector structure can be found
+ *     in the header file sundials_nvector.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype'.
+ *
+ *   - N_Vector arguments to arithmetic vector operations need not
+ *     be distinct. For example, the following call:
+ *
+ *       N_VLinearSum_Serial(a,x,b,y,y);
+ *
+ *     (which stores the result of the operation a*x+b*y in y)
+ *     is legal.
+ * -----------------------------------------------------------------*/
+
+#ifndef _NVECTOR_SERIAL_H
+#define _NVECTOR_SERIAL_H
+
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: SERIAL implementation of N_Vector
+ * -----------------------------------------------------------------
+ */
+
+/* serial implementation of the N_Vector 'content' structure
+   contains the length of the vector, a pointer to an array
+   of 'realtype' components, and a flag indicating ownership of
+   the data */
+
+struct _N_VectorContent_Serial {
+  sunindextype length;
+  booleantype own_data;
+  realtype *data;
+};
+
+typedef struct _N_VectorContent_Serial *N_VectorContent_Serial;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
+ *          NV_LENGTH_S, and NV_Ith_S
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * N_Vector v;
+ * sunindextype i;
+ *
+ * (1) NV_CONTENT_S
+ *
+ *     This routines gives access to the contents of the serial
+ *     vector N_Vector.
+ *
+ *     The assignment v_cont = NV_CONTENT_S(v) sets v_cont to be
+ *     a pointer to the serial N_Vector content structure.
+ *
+ * (2) NV_DATA_S NV_OWN_DATA_S and NV_LENGTH_S
+ *
+ *     These routines give access to the individual parts of
+ *     the content structure of a serial N_Vector.
+ *
+ *     The assignment v_data = NV_DATA_S(v) sets v_data to be
+ *     a pointer to the first component of v. The assignment
+ *     NV_DATA_S(v) = data_V sets the component array of v to
+ *     be data_v by storing the pointer data_v.
+ *
+ *     The assignment v_len = NV_LENGTH_S(v) sets v_len to be
+ *     the length of v. The call NV_LENGTH_S(v) = len_v sets
+ *     the length of v to be len_v.
+ *
+ * (3) NV_Ith_S
+ *
+ *     In the following description, the components of an
+ *     N_Vector are numbered 0..n-1, where n is the length of v.
+ *
+ *     The assignment r = NV_Ith_S(v,i) sets r to be the value of
+ *     the ith component of v. The assignment NV_Ith_S(v,i) = r
+ *     sets the value of the ith component of v to be r.
+ *
+ * Note: When looping over the components of an N_Vector v, it is
+ * more efficient to first obtain the component array via
+ * v_data = NV_DATA_S(v) and then access v_data[i] within the
+ * loop than it is to use NV_Ith_S(v,i) within the loop.
+ * -----------------------------------------------------------------
+ */
+
+#define NV_CONTENT_S(v)  ( (N_VectorContent_Serial)(v->content) )
+
+#define NV_LENGTH_S(v)   ( NV_CONTENT_S(v)->length )
+
+#define NV_OWN_DATA_S(v) ( NV_CONTENT_S(v)->own_data )
+
+#define NV_DATA_S(v)     ( NV_CONTENT_S(v)->data )
+
+#define NV_Ith_S(v,i)    ( NV_DATA_S(v)[i] )
+
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by nvector_serial
+ * 
+ * CONSTRUCTORS:
+ *    N_VNew_Serial
+ *    N_VNewEmpty_Serial
+ *    N_VMake_Serial
+ *    N_VCloneVectorArray_Serial
+ *    N_VCloneVectorArrayEmpty_Serial
+ * DESTRUCTORS:
+ *    N_VDestroy_Serial
+ *    N_VDestroyVectorArray_Serial
+ * OTHER:
+ *    N_VGetLength_Serial
+ *    N_VPrint_Serial
+ *    N_VPrintFile_Serial
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNew_Serial
+ * -----------------------------------------------------------------
+ * This function creates and allocates memory for a serial vector.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNewEmpty_Serial
+ * -----------------------------------------------------------------
+ * This function creates a new serial N_Vector with an empty (NULL)
+ * data array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNewEmpty_Serial(sunindextype vec_length);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VMake_Serial
+ * -----------------------------------------------------------------
+ * This function creates and allocates memory for a serial vector
+ * with a user-supplied data array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VMake_Serial(sunindextype vec_length, realtype *v_data);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArray_Serial
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' SERIAL vectors by
+ * cloning a given vector w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_Serial(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArrayEmpty_Serial
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' SERIAL vectors each
+ * with an empty (NULL) data array by cloning w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_Serial(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VDestroyVectorArray_Serial
+ * -----------------------------------------------------------------
+ * This function frees an array of SERIAL vectors created with 
+ * N_VCloneVectorArray_Serial or N_VCloneVectorArrayEmpty_Serial.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VDestroyVectorArray_Serial(N_Vector *vs, int count);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetLength_Serial
+ * -----------------------------------------------------------------
+ * This function returns number of vector elements.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype N_VGetLength_Serial(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VPrint_Serial
+ * -----------------------------------------------------------------
+ * This function prints the content of a serial vector to stdout.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VPrint_Serial(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VPrintFile_Serial
+ * -----------------------------------------------------------------
+ * This function prints the content of a serial vector to outfile.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VPrintFile_Serial(N_Vector v, FILE *outfile);
+
+/*
+ * -----------------------------------------------------------------
+ * serial implementations of various useful vector operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Serial(N_Vector v);
+SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Serial(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VClone_Serial(N_Vector w);
+SUNDIALS_EXPORT void N_VDestroy_Serial(N_Vector v);
+SUNDIALS_EXPORT void N_VSpace_Serial(N_Vector v, sunindextype *lrw, sunindextype *liw);
+SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Serial(N_Vector v);
+SUNDIALS_EXPORT void N_VSetArrayPointer_Serial(realtype *v_data, N_Vector v);
+SUNDIALS_EXPORT void N_VLinearSum_Serial(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VConst_Serial(realtype c, N_Vector z);
+SUNDIALS_EXPORT void N_VProd_Serial(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VDiv_Serial(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VScale_Serial(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAbs_Serial(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VInv_Serial(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAddConst_Serial(N_Vector x, realtype b, N_Vector z);
+SUNDIALS_EXPORT realtype N_VDotProd_Serial(N_Vector x, N_Vector y);
+SUNDIALS_EXPORT realtype N_VMaxNorm_Serial(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id);
+SUNDIALS_EXPORT realtype N_VMin_Serial(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWL2Norm_Serial(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VL1Norm_Serial(N_Vector x);
+SUNDIALS_EXPORT void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VInvTest_Serial(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m);
+SUNDIALS_EXPORT realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/LICENSE
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/LICENSE	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/LICENSE	(revision 16222)
@@ -0,0 +1,67 @@
+Copyright (c) 2002-2016, Lawrence Livermore National Security. 
+Produced at the Lawrence Livermore National Laboratory.
+Written by A.C. Hindmarsh, D.R. Reynolds, R. Serban, C.S. Woodward,
+S.D. Cohen, A.G. Taylor, S. Peles, L.E. Banks, and D. Shumaker.
+LLNL-CODE-667205    (ARKODE)
+UCRL-CODE-155951    (CVODE)
+UCRL-CODE-155950    (CVODES)
+UCRL-CODE-155952    (IDA)
+UCRL-CODE-237203    (IDAS)
+LLNL-CODE-665877    (KINSOL)
+All rights reserved. 
+
+This file is part of SUNDIALS.  For details, 
+see http://computation.llnl.gov/projects/sundials
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the disclaimer below.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the disclaimer (as noted below)
+in the documentation and/or other materials provided with the
+distribution.
+
+3. Neither the name of the LLNS/LLNL nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
+LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF 
+ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Additional BSD Notice
+---------------------
+1. This notice is required to be provided under our contract with
+the U.S. Department of Energy (DOE). This work was produced at
+Lawrence Livermore National Laboratory under Contract 
+No. DE-AC52-07NA27344 with the DOE.
+
+2. Neither the United States Government nor Lawrence Livermore 
+National Security, LLC nor any of their employees, makes any warranty, 
+express or implied, or assumes any liability or responsibility for the
+accuracy, completeness, or usefulness of any information, apparatus,
+product, or process disclosed, or represents that its use would not
+infringe privately-owned rights.
+
+3. Also, reference herein to any specific commercial products, process, 
+or services by trade name, trademark, manufacturer or otherwise does 
+not necessarily constitute or imply its endorsement, recommendation, 
+or favoring by the United States Government or Lawrence Livermore 
+National Security, LLC. The views and opinions of authors expressed 
+herein do not necessarily state or reflect those of the United States 
+Government or Lawrence Livermore National Security, LLC, and shall 
+not be used for advertising or product endorsement purposes.
+
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_band.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_band.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_band.h	(revision 16222)
@@ -0,0 +1,180 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for a generic BAND linear solver
+ * package, based on the DlsMat type defined in sundials_direct.h.
+ *
+ * There are two sets of band solver routines listed in
+ * this file: one set uses type DlsMat defined below and the
+ * other set uses the type realtype ** for band matrix arguments.
+ * Routines that work with the type DlsMat begin with "Band".
+ * Routines that work with realtype ** begin with "band"
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNDIALS_BAND_H
+#define _SUNDIALS_BAND_H
+
+#include <sundials/sundials_direct.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : BandGBTRF
+ * -----------------------------------------------------------------
+ * Usage : ier = BandGBTRF(A, p);
+ *         if (ier != 0) ... A is singular
+ * -----------------------------------------------------------------
+ * BandGBTRF performs the LU factorization of the N by N band
+ * matrix A. This is done using standard Gaussian elimination
+ * with partial pivoting.
+ *
+ * A successful LU factorization leaves the "matrix" A and the
+ * pivot array p with the following information:
+ *
+ * (1) p[k] contains the row number of the pivot element chosen
+ *     at the beginning of elimination step k, k=0, 1, ..., N-1.
+ *
+ * (2) If the unique LU factorization of A is given by PA = LU,
+ *     where P is a permutation matrix, L is a lower triangular
+ *     matrix with all 1's on the diagonal, and U is an upper
+ *     triangular matrix, then the upper triangular part of A
+ *     (including its diagonal) contains U and the strictly lower
+ *     triangular part of A contains the multipliers, I-L.
+ *
+ * BandGBTRF returns 0 if successful. Otherwise it encountered
+ * a zero diagonal element during the factorization. In this case
+ * it returns the column index (numbered from one) at which
+ * it encountered the zero.
+ *
+ * Important Note: A must be allocated to accommodate the increase
+ * in upper bandwidth that occurs during factorization. If
+ * mathematically, A is a band matrix with upper bandwidth mu and
+ * lower bandwidth ml, then the upper triangular factor U can
+ * have upper bandwidth as big as smu = MIN(n-1,mu+ml). The lower
+ * triangular factor L has lower bandwidth ml. Allocate A with
+ * call A = BandAllocMat(N,mu,ml,smu), where mu, ml, and smu are
+ * as defined above. The user does not have to zero the "extra"
+ * storage allocated for the purpose of factorization. This will
+ * handled by the BandGBTRF routine.
+ *
+ * BandGBTRF is only a wrapper around bandGBTRF. All work is done
+ * in bandGBTRF, which works directly on the data in the DlsMat A
+ * (i.e. in the field A->cols).
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype BandGBTRF(DlsMat A, sunindextype *p);
+SUNDIALS_EXPORT sunindextype bandGBTRF(realtype **a, sunindextype n, sunindextype mu, sunindextype ml,
+                                   sunindextype smu, sunindextype *p);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : BandGBTRS
+ * -----------------------------------------------------------------
+ * Usage : BandGBTRS(A, p, b);
+ * -----------------------------------------------------------------
+ * BandGBTRS solves the N-dimensional system A x = b using
+ * the LU factorization in A and the pivot information in p
+ * computed in BandGBTRF. The solution x is returned in b. This
+ * routine cannot fail if the corresponding call to BandGBTRF
+ * did not fail.
+ *
+ * BandGBTRS is only a wrapper around bandGBTRS which does all the
+ * work directly on the data in the DlsMat A (i.e. in A->cols).
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void BandGBTRS(DlsMat A, sunindextype *p, realtype *b);
+SUNDIALS_EXPORT void bandGBTRS(realtype **a, sunindextype n, sunindextype smu,
+                               sunindextype ml, sunindextype *p, realtype *b);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : BandCopy
+ * -----------------------------------------------------------------
+ * Usage : BandCopy(A, B, copymu, copyml);
+ * -----------------------------------------------------------------
+ * BandCopy copies the submatrix with upper and lower bandwidths
+ * copymu, copyml of the N by N band matrix A into the N by N
+ * band matrix B.
+ * 
+ * BandCopy is a wrapper around bandCopy which accesses the data
+ * in the DlsMat A and DlsMat B (i.e. the fields cols)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void BandCopy(DlsMat A, DlsMat B, sunindextype copymu, sunindextype copyml);
+SUNDIALS_EXPORT void bandCopy(realtype **a, realtype **b, sunindextype n,
+                              sunindextype a_smu, sunindextype b_smu,
+			      sunindextype copymu, sunindextype copyml);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: BandScale
+ * -----------------------------------------------------------------
+ * Usage : BandScale(c, A);
+ * -----------------------------------------------------------------
+ * A(i,j) <- c*A(i,j),   j-(A->mu) <= i <= j+(A->ml).
+ *
+ * BandScale is a wrapper around bandScale which performs the actual
+ * scaling by accessing the data in the DlsMat A (i.e. the field
+ * A->cols).
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void BandScale(realtype c, DlsMat A);
+SUNDIALS_EXPORT void bandScale(realtype c, realtype **a, sunindextype n, sunindextype mu, sunindextype ml, sunindextype smu);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: bandAddIdentity
+ * -----------------------------------------------------------------
+ * bandAddIdentity adds the identity matrix to the n-by-n matrix
+ * stored in the realtype** arrays.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void bandAddIdentity(realtype **a, sunindextype n, sunindextype smu);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: BandMatvec
+ * -----------------------------------------------------------------
+ * BandMatvec computes the matrix-vector product y = A*x, where A 
+ * is an M-by-N band matrix, x is a vector of length N, and y is a 
+ * vector of length M.  No error checking is performed on the length 
+ * of the arrays x and y.  Only y is modified in this routine.
+ *
+ * BandMatvec is a wrapper around bandMatvec which performs the 
+ * actual product by accessing the data in the DlsMat A.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void BandMatvec(DlsMat A, realtype *x, realtype *y);
+SUNDIALS_EXPORT void bandMatvec(realtype **a, realtype *x, realtype *y, sunindextype n, 
+		sunindextype mu, sunindextype ml, sunindextype smu);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_config.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_config.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_config.h	(revision 16222)
@@ -0,0 +1,113 @@
+/* ----------------------------------------------------------------- 
+ * Programmer(s): Aaron Collier and Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * Copyright (c) 2005, The Regents of the University of California.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * -----------------------------------------------------------------
+ * SUNDIALS configuration header file
+ * -----------------------------------------------------------------*/
+
+/* Define SUNDIALS version numbers */
+#define SUNDIALS_VERSION "3.2.0"
+#define SUNDIALS_VERSION_MAJOR 3
+#define SUNDIALS_VERSION_MINOR 2
+#define SUNDIALS_VERSION_PATCH 0
+#define SUNDIALS_VERSION_LABEL ""
+
+/* FCMIX: Define Fortran name-mangling macro for C identifiers.
+ * Depending on the inferred scheme, one of the following six
+ * macros will be defined:
+ *     #define SUNDIALS_F77_FUNC(name,NAME) name
+ *     #define SUNDIALS_F77_FUNC(name,NAME) name ## _
+ *     #define SUNDIALS_F77_FUNC(name,NAME) name ## __
+ *     #define SUNDIALS_F77_FUNC(name,NAME) NAME
+ *     #define SUNDIALS_F77_FUNC(name,NAME) NAME ## _
+ *     #define SUNDIALS_F77_FUNC(name,NAME) NAME ## __
+ */
+
+
+/* FCMIX: Define Fortran name-mangling macro for C identifiers
+ *        which contain underscores.
+ */
+
+
+/* Define precision of SUNDIALS data type 'realtype' 
+ * Depending on the precision level, one of the following 
+ * three macros will be defined:
+ *     #define SUNDIALS_SINGLE_PRECISION 1
+ *     #define SUNDIALS_DOUBLE_PRECISION 1
+ *     #define SUNDIALS_EXTENDED_PRECISION 1
+ */
+#define SUNDIALS_DOUBLE_PRECISION 1
+
+/* Define type of vector indices in SUNDIALS 'sunindextype'. 
+ * Depending on user choice of index type, one of the following 
+ * two macros will be defined:
+ *     #define SUNDIALS_INT64_T 1
+ *     #define SUNDIALS_INT32_T 1
+ */
+#define SUNDIALS_INT64_T 1
+
+/* Define the type of vector indices in SUNDIALS 'sunindextype'.
+ * The macro will be defined with a type of the appropriate size.
+ */
+#define SUNDIALS_INDEX_TYPE int64_t
+
+/* Use generic math functions 
+ * If it was decided that generic math functions can be used, then
+ *     #define SUNDIALS_USE_GENERIC_MATH
+ */
+/* #undef SUNDIALS_USE_GENERIC_MATH */
+
+/* Use POSIX timers if available.
+ *     #define SUNDIALS_HAVE_POSIX_TIMERS
+ */
+/* #undef SUNDIALS_HAVE_POSIX_TIMERS */
+
+/* Blas/Lapack available
+ * If working libraries for Blas/lapack support were found, then
+ *     #define SUNDIALS_BLAS_LAPACK
+ */
+/* #undef SUNDIALS_BLAS_LAPACK */
+
+/* SUPERLUMT available
+ * If working libraries for SUPERLUMT support were found, then
+ *     #define SUNDIALS_SUPERLUMT 
+ */
+/* #undef SUNDIALS_SUPERLUMT */
+/* #undef SUNDIALS_SUPERLUMT_THREAD_TYPE */
+
+/* KLU available
+ * If working libraries for KLU support were found, then
+ *     #define SUNDIALS_KLU 
+ */
+/* #undef SUNDIALS_KLU */
+
+/* Set if SUNDIALS is built with MPI support.
+ * 
+ */
+
+
+/* FNVECTOR: Allow user to specify different MPI communicator
+ * If it was found that the MPI implementation supports MPI_Comm_f2c, then
+ *      #define SUNDIALS_MPI_COMM_F2C 1
+ * otherwise
+ *      #define SUNDIALS_MPI_COMM_F2C 0
+ */
+#define SUNDIALS_MPI_COMM_F2C 0
+
+/* Mark SUNDIALS API functions for export/import
+ * When building shared SUNDIALS libraries under Windows, use
+ *      #define SUNDIALS_EXPORT __declspec(dllexport)
+ * When linking to shared SUNDIALS libraries under Windows, use
+ *      #define SUNDIALS_EXPORT __declspec(dllimport)
+ * In all other cases (other platforms or static libraries under
+ * Windows), the SUNDIALS_EXPORT macro is empty
+ */
+#ifdef BUILD_SUNDIALS_LIBRARY
+#define SUNDIALS_EXPORT __declspec(dllexport)
+#else
+#define SUNDIALS_EXPORT __declspec(dllimport)
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_dense.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_dense.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_dense.h	(revision 16222)
@@ -0,0 +1,211 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer: Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for a generic package of DENSE matrix
+ * operations, based on the DlsMat type defined in sundials_direct.h.
+ *
+ * There are two sets of dense solver routines listed in
+ * this file: one set uses type DlsMat defined below and the
+ * other set uses the type realtype ** for dense matrix arguments.
+ * Routines that work with the type DlsMat begin with "Dense".
+ * Routines that work with realtype** begin with "dense". 
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNDIALS_DENSE_H
+#define _SUNDIALS_DENSE_H
+
+#include <sundials/sundials_direct.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: DenseGETRF and DenseGETRS
+ * -----------------------------------------------------------------
+ * DenseGETRF performs the LU factorization of the M by N dense
+ * matrix A. This is done using standard Gaussian elimination
+ * with partial (row) pivoting. Note that this applies only
+ * to matrices with M >= N and full column rank.
+ *
+ * A successful LU factorization leaves the matrix A and the
+ * pivot array p with the following information:
+ *
+ * (1) p[k] contains the row number of the pivot element chosen
+ *     at the beginning of elimination step k, k=0, 1, ..., N-1.
+ *
+ * (2) If the unique LU factorization of A is given by PA = LU,
+ *     where P is a permutation matrix, L is a lower trapezoidal
+ *     matrix with all 1's on the diagonal, and U is an upper
+ *     triangular matrix, then the upper triangular part of A
+ *     (including its diagonal) contains U and the strictly lower
+ *     trapezoidal part of A contains the multipliers, I-L.
+ *
+ * For square matrices (M = N), L is unit lower triangular.
+ *
+ * DenseGETRF returns 0 if successful. Otherwise it encountered
+ * a zero diagonal element during the factorization. In this case
+ * it returns the column index (numbered from one) at which
+ * it encountered the zero.
+ *
+ * DenseGETRS solves the N-dimensional system A x = b using
+ * the LU factorization in A and the pivot information in p
+ * computed in DenseGETRF. The solution x is returned in b. This
+ * routine cannot fail if the corresponding call to DenseGETRF
+ * did not fail.
+ * DenseGETRS does NOT check for a square matrix!
+ *
+ * -----------------------------------------------------------------
+ * DenseGETRF and DenseGETRS are simply wrappers around denseGETRF
+ * and denseGETRS, respectively, which perform all the work by
+ * directly accessing the data in the DlsMat A (i.e. in A->cols).
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype DenseGETRF(DlsMat A, sunindextype *p);
+SUNDIALS_EXPORT void DenseGETRS(DlsMat A, sunindextype *p, realtype *b);
+
+SUNDIALS_EXPORT sunindextype denseGETRF(realtype **a, sunindextype m, sunindextype n, sunindextype *p);
+SUNDIALS_EXPORT void denseGETRS(realtype **a, sunindextype n, sunindextype *p, realtype *b);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : DensePOTRF and DensePOTRS
+ * -----------------------------------------------------------------
+ * DensePOTRF computes the Cholesky factorization of a real symmetric
+ * positive definite matrix A.
+ * -----------------------------------------------------------------
+ * DensePOTRS solves a system of linear equations A*X = B with a 
+ * symmetric positive definite matrix A using the Cholesky factorization
+ * A = L*L**T computed by DensePOTRF.
+ *
+ * -----------------------------------------------------------------
+ * DensePOTRF and DensePOTRS are simply wrappers around densePOTRF
+ * and densePOTRS, respectively, which perform all the work by
+ * directly accessing the data in the DlsMat A (i.e. the field cols)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype DensePOTRF(DlsMat A);
+SUNDIALS_EXPORT void DensePOTRS(DlsMat A, realtype *b);
+
+SUNDIALS_EXPORT sunindextype densePOTRF(realtype **a, sunindextype m);
+SUNDIALS_EXPORT void densePOTRS(realtype **a, sunindextype m, realtype *b);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions : DenseGEQRF and DenseORMQR
+ * -----------------------------------------------------------------
+ * DenseGEQRF computes a QR factorization of a real M-by-N matrix A:
+ * A = Q * R (with M>= N).
+ * 
+ * DenseGEQRF requires a temporary work vector wrk of length M.
+ * -----------------------------------------------------------------
+ * DenseORMQR computes the product w = Q * v where Q is a real 
+ * orthogonal matrix defined as the product of k elementary reflectors
+ *
+ *        Q = H(1) H(2) . . . H(k)
+ *
+ * as returned by DenseGEQRF. Q is an M-by-N matrix, v is a vector
+ * of length N and w is a vector of length M (with M >= N).
+ *
+ * DenseORMQR requires a temporary work vector wrk of length M.
+ *
+ * -----------------------------------------------------------------
+ * DenseGEQRF and DenseORMQR are simply wrappers around denseGEQRF
+ * and denseORMQR, respectively, which perform all the work by
+ * directly accessing the data in the DlsMat A (i.e. the field cols)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int DenseGEQRF(DlsMat A, realtype *beta, realtype *wrk);
+SUNDIALS_EXPORT int DenseORMQR(DlsMat A, realtype *beta, realtype *vn, realtype *vm, 
+			       realtype *wrk);
+
+SUNDIALS_EXPORT int denseGEQRF(realtype **a, sunindextype m, sunindextype n, realtype *beta,
+                               realtype *wrk);
+SUNDIALS_EXPORT int denseORMQR(realtype **a, sunindextype m, sunindextype n, realtype *beta,
+			       realtype *v, realtype *w, realtype *wrk);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : DenseCopy
+ * -----------------------------------------------------------------
+ * DenseCopy copies the contents of the M-by-N matrix A into the
+ * M-by-N matrix B.
+ * 
+ * DenseCopy is a wrapper around denseCopy which accesses the data
+ * in the DlsMat A and DlsMat B (i.e. the fields cols)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void DenseCopy(DlsMat A, DlsMat B);
+SUNDIALS_EXPORT void denseCopy(realtype **a, realtype **b, sunindextype m, sunindextype n);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: DenseScale
+ * -----------------------------------------------------------------
+ * DenseScale scales the elements of the M-by-N matrix A by the
+ * constant c and stores the result back in A.
+ *
+ * DenseScale is a wrapper around denseScale which performs the actual
+ * scaling by accessing the data in the DlsMat A (i.e. in A->cols).
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void DenseScale(realtype c, DlsMat A);
+SUNDIALS_EXPORT void denseScale(realtype c, realtype **a, sunindextype m, sunindextype n);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: denseAddIdentity
+ * -----------------------------------------------------------------
+ * denseAddIdentity adds the identity matrix to the n-by-n matrix
+ * stored in a realtype** array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void denseAddIdentity(realtype **a, sunindextype n);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: DenseMatvec
+ * -----------------------------------------------------------------
+ * DenseMatvec computes the matrix-vector product y = A*x, where A 
+ * is an M-by-N matrix, x is a vector of length N, and y is a vector
+ * of length M.  No error checking is performed on the length of the
+ * arrays x and y.  Only y is modified in this routine.
+ *
+ * DenseMatvec is a wrapper around denseMatvec which performs the 
+ * actual product by accessing the data in the DlsMat A.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void DenseMatvec(DlsMat A, realtype *x, realtype *y);
+SUNDIALS_EXPORT void denseMatvec(realtype **a, realtype *x, realtype *y, sunindextype m, sunindextype n);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_direct.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_direct.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_direct.h	(revision 16222)
@@ -0,0 +1,337 @@
+/* -----------------------------------------------------------------
+ * Programmer: Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This header file contains definitions and declarations for use by
+ * generic direct linear solvers for Ax = b. It defines types for
+ * dense and banded matrices and corresponding accessor macros.
+ * -----------------------------------------------------------------*/
+
+#ifndef _SUNDIALS_DIRECT_H
+#define _SUNDIALS_DIRECT_H
+
+#include <stdio.h>
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ *                C O N S T A N T S
+ * =================================================================
+ */
+
+/*
+ *  SUNDIALS_DENSE: dense matrix
+ *  SUNDIALS_BAND:  banded matrix
+ */
+
+#define SUNDIALS_DENSE 1
+#define SUNDIALS_BAND  2
+
+/*
+ * ==================================================================
+ * Type definitions
+ * ==================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Type : DlsMat
+ * -----------------------------------------------------------------
+ * The type DlsMat is defined to be a pointer to a structure
+ * with various sizes, a data field, and an array of pointers to
+ * the columns which defines a dense or band matrix for use in 
+ * direct linear solvers. The M and N fields indicates the number 
+ * of rows and columns, respectively. The data field is a one 
+ * dimensional array used for component storage. The cols field 
+ * stores the pointers in data for the beginning of each column.
+ * -----------------------------------------------------------------
+ * For DENSE matrices, the relevant fields in DlsMat are:
+ *    type  = SUNDIALS_DENSE
+ *    M     - number of rows
+ *    N     - number of columns
+ *    ldim  - leading dimension (ldim >= M)
+ *    data  - pointer to a contiguous block of realtype variables
+ *    ldata - length of the data array =ldim*N
+ *    cols  - array of pointers. cols[j] points to the first element 
+ *            of the j-th column of the matrix in the array data.
+ *
+ * The elements of a dense matrix are stored columnwise (i.e. columns 
+ * are stored one on top of the other in memory). 
+ * If A is of type DlsMat, then the (i,j)th element of A (with 
+ * 0 <= i < M and 0 <= j < N) is given by (A->data)[j*n+i]. 
+ *
+ * The DENSE_COL and DENSE_ELEM macros below allow a user to access 
+ * efficiently individual matrix elements without writing out explicit 
+ * data structure references and without knowing too much about the 
+ * underlying element storage. The only storage assumption needed is 
+ * that elements are stored columnwise and that a pointer to the 
+ * jth column of elements can be obtained via the DENSE_COL macro.
+ * -----------------------------------------------------------------
+ * For BAND matrices, the relevant fields in DlsMat are:
+ *    type  = SUNDIALS_BAND
+ *    M     - number of rows
+ *    N     - number of columns
+ *    mu    - upper bandwidth, 0 <= mu <= min(M,N)
+ *    ml    - lower bandwidth, 0 <= ml <= min(M,N)
+ *    s_mu  - storage upper bandwidth, mu <= s_mu <= N-1.
+ *            The dgbtrf routine writes the LU factors into the storage 
+ *            for A. The upper triangular factor U, however, may have 
+ *            an upper bandwidth as big as MIN(N-1,mu+ml) because of 
+ *            partial pivoting. The s_mu field holds the upper 
+ *            bandwidth allocated for A.
+ *    ldim  - leading dimension (ldim >= s_mu)
+ *    data  - pointer to a contiguous block of realtype variables
+ *    ldata - length of the data array =ldim*(s_mu+ml+1)
+ *    cols  - array of pointers. cols[j] points to the first element 
+ *            of the j-th column of the matrix in the array data.
+ *
+ * The BAND_COL, BAND_COL_ELEM, and BAND_ELEM macros below allow a 
+ * user to access individual matrix elements without writing out 
+ * explicit data structure references and without knowing too much 
+ * about the underlying element storage. The only storage assumption 
+ * needed is that elements are stored columnwise and that a pointer 
+ * into the jth column of elements can be obtained via the BAND_COL 
+ * macro. The BAND_COL_ELEM macro selects an element from a column
+ * which has already been isolated via BAND_COL. The macro 
+ * BAND_COL_ELEM allows the user to avoid the translation 
+ * from the matrix location (i,j) to the index in the array returned 
+ * by BAND_COL at which the (i,j)th element is stored. 
+ * -----------------------------------------------------------------
+ */
+
+typedef struct _DlsMat {
+  int type;
+  sunindextype M;
+  sunindextype N;
+  sunindextype ldim;
+  sunindextype mu;
+  sunindextype ml;
+  sunindextype s_mu;
+  realtype *data;
+  sunindextype ldata;
+  realtype **cols;
+} *DlsMat;
+
+/*
+ * ==================================================================
+ * Data accessor macros
+ * ==================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * DENSE_COL and DENSE_ELEM
+ * -----------------------------------------------------------------
+ *
+ * DENSE_COL(A,j) references the jth column of the M-by-N dense
+ * matrix A, 0 <= j < N. The type of the expression DENSE_COL(A,j) 
+ * is (realtype *). After the assignment col_j = DENSE_COL(A,j),
+ * col_j may be treated as an array indexed from 0 to M-1.
+ * The (i,j)-th element of A is thus referenced by col_j[i].
+ *
+ * DENSE_ELEM(A,i,j) references the (i,j)th element of the dense 
+ * M-by-N matrix A, 0 <= i < M ; 0 <= j < N.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#define DENSE_COL(A,j) ((A->cols)[j])
+#define DENSE_ELEM(A,i,j) ((A->cols)[j][i])
+
+/*
+ * -----------------------------------------------------------------
+ * BAND_COL, BAND_COL_ELEM, and BAND_ELEM
+ * -----------------------------------------------------------------
+ *  
+ * BAND_COL(A,j) references the diagonal element of the jth column 
+ * of the N by N band matrix A, 0 <= j <= N-1. The type of the 
+ * expression BAND_COL(A,j) is realtype *. The pointer returned by 
+ * the call BAND_COL(A,j) can be treated as an array which is 
+ * indexed from -(A->mu) to (A->ml).
+ * 
+ * BAND_COL_ELEM references the (i,j)th entry of the band matrix A 
+ * when used in conjunction with BAND_COL. The index (i,j) should 
+ * satisfy j-(A->mu) <= i <= j+(A->ml).
+ *
+ * BAND_ELEM(A,i,j) references the (i,j)th element of the M-by-N 
+ * band matrix A, where 0 <= i,j <= N-1. The location (i,j) should 
+ * further satisfy j-(A->mu) <= i <= j+(A->ml). 
+ *
+ * -----------------------------------------------------------------
+ */
+ 
+#define BAND_COL(A,j) (((A->cols)[j])+(A->s_mu))
+#define BAND_COL_ELEM(col_j,i,j) (col_j[(i)-(j)])
+#define BAND_ELEM(A,i,j) ((A->cols)[j][(i)-(j)+(A->s_mu)])
+
+/*
+ * ==================================================================
+ * Exported function prototypes (functions working on dlsMat)
+ * ==================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: NewDenseMat
+ * -----------------------------------------------------------------
+ * NewDenseMat allocates memory for an M-by-N dense matrix and
+ * returns the storage allocated (type DlsMat). NewDenseMat
+ * returns NULL if the request for matrix storage cannot be
+ * satisfied. See the above documentation for the type DlsMat
+ * for matrix storage details.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT DlsMat NewDenseMat(sunindextype M, sunindextype N);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: NewBandMat
+ * -----------------------------------------------------------------
+ * NewBandMat allocates memory for an M-by-N band matrix 
+ * with upper bandwidth mu, lower bandwidth ml, and storage upper
+ * bandwidth smu. Pass smu as follows depending on whether A will 
+ * be LU factored:
+ *
+ * (1) Pass smu = mu if A will not be factored.
+ *
+ * (2) Pass smu = MIN(N-1,mu+ml) if A will be factored.
+ *
+ * NewBandMat returns the storage allocated (type DlsMat) or
+ * NULL if the request for matrix storage cannot be satisfied.
+ * See the documentation for the type DlsMat for matrix storage
+ * details.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT DlsMat NewBandMat(sunindextype N, sunindextype mu, sunindextype ml, sunindextype smu);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: DestroyMat
+ * -----------------------------------------------------------------
+ * DestroyMat frees the memory allocated by NewDenseMat or NewBandMat
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void DestroyMat(DlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: NewIntArray
+ * -----------------------------------------------------------------
+ * NewIntArray allocates memory an array of N int's and returns
+ * the pointer to the memory it allocates. If the request for
+ * memory storage cannot be satisfied, it returns NULL.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int *NewIntArray(int N);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: NewIndexArray
+ * -----------------------------------------------------------------
+ * NewIndexArray allocates memory an array of N sunindextype's and
+ * returns the pointer to the memory it allocates. If the request
+ * for memory storage cannot be satisfied, it returns NULL.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype *NewIndexArray(sunindextype N);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: NewRealArray
+ * -----------------------------------------------------------------
+ * NewRealArray allocates memory an array of N realtype and returns
+ * the pointer to the memory it allocates. If the request for
+ * memory storage cannot be satisfied, it returns NULL.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype *NewRealArray(sunindextype N);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: DestroyArray
+ * -----------------------------------------------------------------
+ * DestroyArray frees memory allocated by NewIntArray, NewIndexArray,
+ * or NewRealArray.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void DestroyArray(void *p);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : AddIdentity
+ * -----------------------------------------------------------------
+ * AddIdentity adds 1.0 to the main diagonal (A_ii, i=0,1,...,N-1) of
+ * the M-by-N matrix A (M>= N) and stores the result back in A.
+ * AddIdentity is typically used with square matrices.
+ * AddIdentity does not check for M >= N and therefore a segmentation
+ * fault will occur if M < N!
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void AddIdentity(DlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SetToZero
+ * -----------------------------------------------------------------
+ * SetToZero sets all the elements of the M-by-N matrix A to 0.0.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SetToZero(DlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: PrintMat
+ * -----------------------------------------------------------------
+ * This function prints the M-by-N (dense or band) matrix A to
+ * outfile as it would normally appear on paper.
+ * It is intended as debugging tools with small values of M and N.
+ * The elements are printed using the %g/%lg/%Lg option. 
+ * A blank line is printed before and after the matrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void PrintMat(DlsMat A, FILE *outfile);
+
+
+/*
+ * ==================================================================
+ * Exported function prototypes (functions working on realtype**)
+ * ==================================================================
+ */
+
+SUNDIALS_EXPORT realtype **newDenseMat(sunindextype m, sunindextype n);
+SUNDIALS_EXPORT realtype **newBandMat(sunindextype n, sunindextype smu, sunindextype ml);
+SUNDIALS_EXPORT void destroyMat(realtype **a);
+SUNDIALS_EXPORT int *newIntArray(int n);
+SUNDIALS_EXPORT sunindextype *newIndexArray(sunindextype n);
+SUNDIALS_EXPORT realtype *newRealArray(sunindextype m);
+SUNDIALS_EXPORT void destroyArray(void *v);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_fconfig.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_fconfig.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_fconfig.h	(revision 16222)
@@ -0,0 +1,56 @@
+!
+! ----------------------------------------------------------------- 
+! Programmer(s): Daniel R. Reynolds @ SMU
+!-----------------------------------------------------------------
+! LLNS/SMU Copyright Start
+! Copyright (c) 2015, Southern Methodist University and 
+! Lawrence Livermore National Security
+!
+! This work was performed under the auspices of the U.S. Department 
+! of Energy by Southern Methodist University and Lawrence Livermore 
+! National Laboratory under Contract DE-AC52-07NA27344.
+! Produced at Southern Methodist University and the Lawrence 
+! Livermore National Laboratory.
+!
+! All rights reserved.
+! For details, see the LICENSE file.
+! LLNS/SMU Copyright End
+! Copyright (c) 2013, Southern Methodist University.
+! All rights reserved.
+! For details, see the LICENSE file.
+! ------------------------------------------------------------------
+! SUNDIALS fortran configuration input
+! ------------------------------------------------------------------
+
+!     Define precision of SUNDIALS data type 'realtype' as Fortran 
+!     parameter "REALTYPE"
+!
+!     Depending on the precision level, this value will be one of
+!          4  (SUNDIALS_SINGLE_PRECISION)
+!          8  (SUNDIALS_DOUBLE_PRECISION)
+!         16  (SUNDIALS_EXTENDED_PRECISION)
+!
+integer REALTYPE
+parameter (REALTYPE=8)
+
+!     Define type of vector indices in SUNDIALS 'sunindextype' as 
+!     the Fortran parameter "SUNINDEXTYPE"
+!
+!     Depending on the user choice of indextype, this will be one of
+!          4  (32BIT)
+!          8  (64BIT)
+!
+integer SUNINDEXTYPE
+parameter (SUNINDEXTYPE=8)
+
+!     If building with MPI enabled, define the logical flag 
+!     "SUNDIALS_MPI_COMM_F2C" indicating whether the user can specify
+!     a different MPI communicator than MPI_COMM_WORLD to FNVInitP
+!
+!          .true.   (communicator can differ from MPI_COMM_WORLD)
+!          .false.  (communicator must be MPI_COMM_WORLD)
+!
+!      logical SUNDIALS_MPI_COMM_F2C
+!      parameter (SUNDIALS_MPI_COMM_F2C=)
+
+
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_fnvector.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_fnvector.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_fnvector.h	(revision 16222)
@@ -0,0 +1,47 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Radu Serban and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This file (companion of nvector.h) contains definitions 
+ * needed for the initialization of vector operations in Fortran.
+ * -----------------------------------------------------------------
+ */
+
+
+#ifndef _FNVECTOR_H
+#define _FNVECTOR_H
+
+#ifndef _SUNDIALS_CONFIG_H
+#define _SUNDIALS_CONFIG_H
+#include <sundials/sundials_config.h>
+#endif
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* SUNDIALS solver IDs */
+
+#define FCMIX_CVODE   1
+#define FCMIX_IDA     2
+#define FCMIX_KINSOL  3
+#define FCMIX_ARKODE  4
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_iterative.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_iterative.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_iterative.h	(revision 16222)
@@ -0,0 +1,267 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Scott D. Cohen and Alan C. Hindmarsh @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This header file contains declarations intended for use by
+ * generic iterative solvers of Ax = b. The enumeration gives
+ * symbolic names for the type  of preconditioning to be used.
+ * The function type declarations give the prototypes for the
+ * functions to be called within an iterative linear solver, that
+ * are responsible for
+ *    multiplying A by a given vector v (ATimesFn), 
+ *    setting up a preconditioner P (PSetupFn), and
+ *    solving the preconditioner equation Pz = r (PSolveFn).
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _ITERATIVE_H
+#define _ITERATIVE_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*
+ * -----------------------------------------------------------------
+ * enum : types of preconditioning                                
+ * -----------------------------------------------------------------
+ * PREC_NONE  : The iterative linear solver should not use             
+ *              preconditioning.                                       
+ *                                                                
+ * PREC_LEFT  : The iterative linear solver uses preconditioning on    
+ *              the left only.                                         
+ *                                                                
+ * PREC_RIGHT : The iterative linear solver uses preconditioning on    
+ *              the right only.                                        
+ *                                                                
+ * PREC_BOTH  : The iterative linear solver uses preconditioning on    
+ *              both the left and the right.                           
+ * -----------------------------------------------------------------
+ */
+
+enum { PREC_NONE, PREC_LEFT, PREC_RIGHT, PREC_BOTH };
+
+/*
+ * -----------------------------------------------------------------
+ * enum : types of Gram-Schmidt routines                          
+ * -----------------------------------------------------------------
+ * MODIFIED_GS  : The iterative solver uses the modified          
+ *                Gram-Schmidt routine ModifiedGS listed in this  
+ *                file.                                           
+ *                                                                
+ * CLASSICAL_GS : The iterative solver uses the classical         
+ *                Gram-Schmidt routine ClassicalGS listed in this 
+ *                file.                                           
+ * -----------------------------------------------------------------
+ */
+
+enum { MODIFIED_GS = 1, CLASSICAL_GS = 2 };
+
+/*
+ * -----------------------------------------------------------------
+ * Type: ATimesFn                                                 
+ * -----------------------------------------------------------------
+ * An ATimesFn multiplies Av and stores the result in z. The      
+ * caller is responsible for allocating memory for the z vector.  
+ * The parameter A_data is a pointer to any information about A   
+ * which the function needs in order to do its job. The vector v  
+ * is unchanged. An ATimesFn returns 0 if successful and a        
+ * non-zero value if unsuccessful.                                
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*ATimesFn)(void *A_data, N_Vector v, N_Vector z);
+
+/* 
+ * -----------------------------------------------------------------
+ * Type: PSetupFn
+ * -----------------------------------------------------------------
+ * A PSetupFn is an integrator-supplied routine that accesses data
+ * stored in the integrator memory structure (P_data), and calls 
+ * the user-supplied, integrator-specific preconditioner setup 
+ * routine. 
+ * -----------------------------------------------------------------
+ */
+ 
+typedef int (*PSetupFn)(void *P_data);
+
+/*
+ * -----------------------------------------------------------------
+ * Type: PSolveFn                                                 
+ * -----------------------------------------------------------------
+ * A PSolveFn solves the preconditioner equation Pz = r for the   
+ * vector z. The caller is responsible for allocating memory for  
+ * the z vector. The parameter P_data is a pointer to any         
+ * information about P which the function needs in order to do    
+ * its job. The parameter lr is input, and indicates whether P    
+ * is to be taken as the left preconditioner or the right         
+ * preconditioner: lr = 1 for left and lr = 2 for right.          
+ * If preconditioning is on one side only, lr can be ignored.     
+ * If the preconditioner is iterative, then it should strive to 
+ * solve the preconditioner equation so that
+ *     || Pz - r ||_wrms < tol
+ * where the weight vector for the WRMS norm may be accessed from 
+ * the main integrator memory structure.
+ * The vector r should not be modified by the PSolveFn.
+ * A PSolveFn returns 0 if successful and a non-zero value if     
+ * unsuccessful.  On a failure, a negative return value indicates 
+ * an unrecoverable condition, while a positive value indicates   
+ * a recoverable one, in which the calling routine may reattempt  
+ * the solution after updating preconditioner data.               
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*PSolveFn)(void *P_data, N_Vector r, N_Vector z,
+                        realtype tol, int lr);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: ModifiedGS                                           
+ * -----------------------------------------------------------------
+ * ModifiedGS performs a modified Gram-Schmidt orthogonalization  
+ * of the N_Vector v[k] against the p unit N_Vectors at           
+ * v[k-1], v[k-2], ..., v[k-p].                                   
+ *                                                                
+ * v is an array of (k+1) N_Vectors v[i], i=0, 1, ..., k.         
+ * v[k-1], v[k-2], ..., v[k-p] are assumed to have L2-norm        
+ * equal to 1.                                                    
+ *                                                                
+ * h is the output k by k Hessenberg matrix of inner products.    
+ * This matrix must be allocated row-wise so that the (i,j)th     
+ * entry is h[i][j]. The inner products (v[i],v[k]),              
+ * i=i0, i0+1, ..., k-1, are stored at h[i][k-1]. Here            
+ * i0=SUNMAX(0,k-p).
+ *                                                                
+ * k is the index of the vector in the v array that needs to be   
+ * orthogonalized against previous vectors in the v array.        
+ *                                                                
+ * p is the number of previous vectors in the v array against     
+ * which v[k] is to be orthogonalized.                            
+ *                                                                
+ * new_vk_norm is a pointer to memory allocated by the caller to  
+ * hold the Euclidean norm of the orthogonalized vector v[k].     
+ *                                                                
+ * If (k-p) < 0, then ModifiedGS uses p=k. The orthogonalized     
+ * v[k] is NOT normalized and is stored over the old v[k]. Once   
+ * the orthogonalization has been performed, the Euclidean norm   
+ * of v[k] is stored in (*new_vk_norm).                           
+ *                                                                
+ * ModifiedGS returns 0 to indicate success. It cannot fail.      
+ * -----------------------------------------------------------------
+ */                                                                
+
+SUNDIALS_EXPORT int ModifiedGS(N_Vector *v, realtype **h, int k, int p, 
+			       realtype *new_vk_norm);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: ClassicalGS                                          
+ * -----------------------------------------------------------------
+ * ClassicalGS performs a classical Gram-Schmidt                  
+ * orthogonalization of the N_Vector v[k] against the p unit      
+ * N_Vectors at v[k-1], v[k-2], ..., v[k-p]. The parameters v, h, 
+ * k, p, and new_vk_norm are as described in the documentation    
+ * for ModifiedGS.                                                
+ *                                                                
+ * temp is an N_Vector which can be used as workspace by the      
+ * ClassicalGS routine.                                           
+ *                                                                
+ * s is a length k array of realtype which can be used as         
+ * workspace by the ClassicalGS routine.                          
+ *
+ * ClassicalGS returns 0 to indicate success. It cannot fail.     
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int ClassicalGS(N_Vector *v, realtype **h, int k, int p, 
+				realtype *new_vk_norm, N_Vector temp, realtype *s);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: QRfact                                               
+ * -----------------------------------------------------------------
+ * QRfact performs a QR factorization of the Hessenberg matrix H. 
+ *                                                                
+ * n is the problem size; the matrix H is (n+1) by n.             
+ *                                                                
+ * h is the (n+1) by n Hessenberg matrix H to be factored. It is  
+ * stored row-wise.                                               
+ *                                                                
+ * q is an array of length 2*n containing the Givens rotations    
+ * computed by this function. A Givens rotation has the form:     
+ * | c  -s |                                                      
+ * | s   c |.                                                     
+ * The components of the Givens rotations are stored in q as      
+ * (c, s, c, s, ..., c, s).                                       
+ *                                                                
+ * job is a control flag. If job==0, then a new QR factorization  
+ * is performed. If job!=0, then it is assumed that the first     
+ * n-1 columns of h have already been factored and only the last  
+ * column needs to be updated.                                    
+ *                                                                
+ * QRfact returns 0 if successful. If a zero is encountered on    
+ * the diagonal of the triangular factor R, then QRfact returns   
+ * the equation number of the zero entry, where the equations are 
+ * numbered from 1, not 0. If QRsol is subsequently called in     
+ * this situation, it will return an error because it could not   
+ * divide by the zero diagonal entry.                             
+ * -----------------------------------------------------------------
+ */                                                                
+
+SUNDIALS_EXPORT int QRfact(int n, realtype **h, realtype *q, int job);
+
+/*                                                                
+ * -----------------------------------------------------------------
+ * Function: QRsol                                                
+ * -----------------------------------------------------------------
+ * QRsol solves the linear least squares problem                  
+ *                                                                
+ * min (b - H*x, b - H*x), x in R^n,                              
+ *                                                                
+ * where H is a Hessenberg matrix, and b is in R^(n+1).           
+ * It uses the QR factors of H computed by QRfact.                
+ *                                                                
+ * n is the problem size; the matrix H is (n+1) by n.             
+ *                                                                
+ * h is a matrix (computed by QRfact) containing the upper        
+ * triangular factor R of the original Hessenberg matrix H.       
+ *                                                                
+ * q is an array of length 2*n (computed by QRfact) containing    
+ * the Givens rotations used to factor H.                         
+ *                                                                
+ * b is the (n+1)-vector appearing in the least squares problem   
+ * above.                                                         
+ *                                                                
+ * On return, b contains the solution x of the least squares      
+ * problem, if QRsol was successful.                              
+ *                                                                
+ * QRsol returns a 0 if successful.  Otherwise, a zero was        
+ * encountered on the diagonal of the triangular factor R.        
+ * In this case, QRsol returns the equation number (numbered      
+ * from 1, not 0) of the zero entry.                              
+ * -----------------------------------------------------------------
+ */                                                                
+
+SUNDIALS_EXPORT int QRsol(int n, realtype **h, realtype *q, realtype *b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_linearsolver.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_linearsolver.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_linearsolver.h	(revision 16222)
@@ -0,0 +1,364 @@
+/*
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Daniel Reynolds @ SMU
+ *                David Gardner, Carol Woodward, Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for a generic linear solver package.
+ * It defines the SUNLinearSolver structure (_generic_SUNLinearSolver)
+ * which contains the following fields:
+ *   - an implementation-dependent 'content' field which contains
+ *     any internal data required by the solver
+ *   - an 'ops' filed which contains a structure listing operations
+ *     acting on/by such solvers
+ *
+ * We consider both direct linear solvers and iterative linear solvers
+ * as available implementations of this package; as a result some of 
+ * the routines are applicable only to one type of linear solver (as 
+ * noted in the comments below).
+ *
+ * For most of the iterative linear solvers, instead of solving the 
+ * linear system A x = b directly, we apply the underlying iterative 
+ * algorithm to the transformed system 
+ *
+ *        Abar xbar = bbar
+ *
+ * where
+ *
+ *        Abar = S1 (P1-inverse) A (P2-inverse) (S2-inverse),
+ *        bbar = S1 (P1-inverse) b,
+ *        xbar = S2 P2 x,
+ * 
+ * and where 
+ *
+ *        P1 = left preconditioner
+ *        P2 = right preconditioner
+ *        S1 = diagonal matrix of scale factors for P1-inverse b
+ *        S2 = diagonal matrix of scale factors for P2 x.
+ * 
+ * The stopping tolerance on iterative linear solvers is on the  
+ * 2-norm of the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  tol.
+ * 
+ * We note that the Preconditioned Conjugate Gradient (PCG) solver 
+ * considers S1=S2 and P1=P2 (where each is approximately A^{1/2}), and 
+ * both scaling and preconditioning are applied symmetrically and 
+ * simultaneously, so that the user-supplied S and P are in fact 
+ * S1^2 and P1^2, i.e. P is approximately A and S is the corresponding 
+ * diagonal matrix of scale factors for P.  As such, in the PCG solver the 
+ * second scaling vector and the left/right "type" of P are ignored.
+ *
+ * -----------------------------------------------------------------
+ *
+ * Part I of this file contains enumeration constants for all 
+ * SUNDIALS-defined linear solver types, as well as a generic type for 
+ * user-supplied linear solver types.
+ *
+ * Part II of this file contains type declarations for the
+ * _generic_SUNLinearSolver and _generic_SUNLinearSolver_Ops structures, 
+ * as well as references to pointers to such structures 
+ * (SUNLinearSolver).
+ *
+ * Part III of this file contains the prototypes for the linear solver
+ * functions which operate on/by SUNLinearSolver objects.
+ *
+ * At a minimum, a particular implementation of a SUNLinearSolver must
+ * do the following:
+ *  - specify the 'content' field of SUNLinearSolver,
+ *  - implement the operations on/by those SUNLinearSolver,
+ *  - provide a constructor routine for new SUNLinearSolver objects
+ *
+ * Additionally, a SUNLinearSolver implementation may provide the 
+ * following:
+ *  - "Set" routines to control solver-specific parameters/options
+ *  - "Get" routines to access solver-specific performance metrics
+ *
+ * Part IV of this file contains error codes that may be returned by
+ * SUNLinearSolver objects.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINEARSOLVER_H
+#define _SUNLINEARSOLVER_H
+ 
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+ 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+ 
+  
+/*
+ * -----------------------------------------------------------------
+ * I. Implemented SUNLinearSolver types: 
+ *
+ * These type names may be modified, but a at a minimum a client 
+ * nonlinear solver and/or time integrator will want to know whether 
+ * matrix/factorization information can be reused (hence the DIRECT 
+ * and ITERATIVE types).
+ * -----------------------------------------------------------------
+ */
+ 
+typedef enum {
+  SUNLINEARSOLVER_DIRECT,
+  SUNLINEARSOLVER_ITERATIVE,
+  SUNLINEARSOLVER_CUSTOM
+} SUNLinearSolver_Type;
+
+  
+/* 
+ * -----------------------------------------------------------------
+ * II. Generic definition of SUNLinearSolver 
+ * -----------------------------------------------------------------
+ */
+ 
+/* Forward reference for pointer to SUNLinearSolver_Ops object */
+typedef struct _generic_SUNLinearSolver_Ops *SUNLinearSolver_Ops;
+ 
+/* Forward reference for pointer to SUNLinearSolver object */
+typedef struct _generic_SUNLinearSolver *SUNLinearSolver;
+ 
+/* Structure containing function pointers to linear solver operations */  
+struct _generic_SUNLinearSolver_Ops {
+  SUNLinearSolver_Type (*gettype)(SUNLinearSolver);
+  int                  (*setatimes)(SUNLinearSolver, void*, ATimesFn);
+  int                  (*setpreconditioner)(SUNLinearSolver, void*, 
+                                            PSetupFn, PSolveFn);
+  int                  (*setscalingvectors)(SUNLinearSolver,
+                                            N_Vector, N_Vector);
+  int                  (*initialize)(SUNLinearSolver);
+  int                  (*setup)(SUNLinearSolver, SUNMatrix);
+  int                  (*solve)(SUNLinearSolver, SUNMatrix, N_Vector, 
+                                N_Vector, realtype);
+  int                  (*numiters)(SUNLinearSolver);
+  realtype             (*resnorm)(SUNLinearSolver);
+  long int             (*lastflag)(SUNLinearSolver);
+  int                  (*space)(SUNLinearSolver, long int*, long int*);
+  N_Vector             (*resid)(SUNLinearSolver);
+  int                  (*free)(SUNLinearSolver);
+};
+ 
+/* A linear solver is a structure with an implementation-dependent
+   'content' field, and a pointer to a structure of linear solver
+   operations corresponding to that implementation. */
+struct _generic_SUNLinearSolver {
+  void *content;
+  struct _generic_SUNLinearSolver_Ops *ops;
+};
+
+  
+/*
+ * -----------------------------------------------------------------
+ * III. Functions exported by SUNLinearSolver module
+ * 
+ * SUNLinSolGetType
+ *   Returns an identifier for the linear solver type from 
+ *   enumeration SUNLinearSolver_Type.
+ *
+ * SUNLinSolSetATimes (iterative methods only)
+ *   Sets the function pointer for ATimes inside of an iterative 
+ *   linear solver object.  This function should only be called by a 
+ *   main integrator, who will either provide this via 
+ *   difference-quotients and vector operations, or by translating 
+ *   between the generic ATimes call and the integrator-specific, 
+ *   user-supplied routines.  This should return zero for a 
+ *   successful call, and a negative value for a failure.  Ideally, 
+ *   this should return one of the generic SUNLS_* error codes 
+ *   listed at the bottom of this file.
+ *
+ * SUNLinSolSetPreconditioner (iterative methods only)
+ *   Sets function pointers for PSetup and PSolve routines inside 
+ *   of iterative linear solver objects.  This function should only 
+ *   be called by a main integrator, who will provide translation 
+ *   between the generic PSetup and PSolve calls and the integrator-
+ *   specific user-supplied routines.  This should return
+ *   zero for a successful call, and a negative value for a failure.
+ *   Ideally, this should return one of the generic SUNLS_* error 
+ *   codes listed at the bottom of this file.
+ *
+ * SUNLinSolSetScalingVectors (iterative methods only)
+ *   Sets pointers to left/right scaling vectors for the linear
+ *   system solve.  Here, s1 is an N_Vector of positive scale factors
+ *   for P1-inv b, where P1 is the left preconditioner (the vector is 
+ *   not tested for positivity).  Pass NULL if no scaling on P1-inv b
+ *   is required.  Similarly, s2 is an N_Vector of positive scale 
+ *   factors for P2 x, where P2 is the right preconditioner (again 
+ *   not tested for positivity). Pass NULL if no scaling on P2 x is 
+ *   required.  This should return zero for a successful call, and a 
+ *   negative value for a failure.  Ideally, this should return one of
+ *   the generic SUNLS_* error codes listed at the bottom of this file.
+ *
+ * SUNLinSolInitialize
+ *   Performs linear solver initialization (assumes that all 
+ *   solver-specific options have been set).  This should return
+ *   zero for a successful call, and a negative value for a failure.  
+ *   Ideally, this should return one of the generic SUNLS_* error 
+ *   codes listed at the bottom of this file.
+ *
+ * SUNLinSolSetup
+ *   Performs any linear solver setup needed, based on an updated
+ *   system matrix A.  This may be called frequently (e.g. with a
+ *   full Newton method) or infrequently (for a modified Newton 
+ *   method), based on the type of integrator and/or nonlinear 
+ *   solver requesting the solves.  This should return
+ *   zero for a successful call, a positive value for a recoverable 
+ *   failure and a negative value for an unrecoverable failure.  
+ *   Ideally, this should return one of the generic SUNLS_* error 
+ *   codes listed at the bottom of this file.
+ *
+ * SUNLinSolSolve
+ *   Solves a linear system A*x = b.  If the solver is scaled, it 
+ *   uses the supplied scaling vectors.  If the solver is iterative, 
+ *   it attempts to solve to the specified tolerance (weighted 
+ *   2-norm).  If the solver is direct it ignores the input tolerance 
+ *   and scaling vectors, and if the solver does not support scaling 
+ *   then it should just use a 2-norm.  This should return zero for a
+ *   successful call, a positive value for a recoverable failure and 
+ *   a negative value for an unrecoverable failure.  Ideally, this 
+ *   should return one of the generic SUNLS_* error codes listed at 
+ *   the bottom of this file.
+ *
+ * SUNLinSolNumIters (iterative methods only)
+ *   Returns the number of linear iterations performed in the last 
+ *   'Solve' call.  
+ *
+ * SUNLinSolResNorm (iterative methods only)
+ *   Returns the final residual norm from the last 'Solve' call.
+ *
+ * SUNLinSolResid (iterative methods only)
+ *   If an iterative method computes the preconditioned initial 
+ *   residual and returns with a successful solve without performing 
+ *   any iterations (i.e. either the initial guess or the 
+ *   preconditioner is sufficiently accurate), then this 
+ *   function may be called.  It should return the N_Vector 
+ *   containing the preconditioned initial residual.
+ *
+ * SUNLinSolLastFlag (optional)
+ *   Returns the last error flag encountered within the linear solver,
+ *   allowing the user to investigate linear solver issues after 
+ *   failed solves.
+ *
+ * SUNLinSolSpace (optional)
+ *   Returns the integer and real workspace sizes for the linear
+ *   solver.
+ *
+ * SUNLinSolFree
+ *   Frees memory allocated by the linear solver.  This should return
+ *   zero for a successful call, and a negative value for a failure.
+ *
+ * ---------------------------------------------------------------
+ *
+ * The following table lists the linear solver functions used by 
+ * different modules in SUNDIALS.  The symbols in the table have 
+ * The following meaning:
+ * M - called by the modified Newton nonlinear solver
+ * I - called by the inexact Newton nonlinear solver
+ * P - called by the Picard nonlinear solver
+ * S - called by the integrator directly (and non-identity mass matrix)
+ *
+ *  LinearSolver
+ *  Functions           CVODE(S)  ARKode     IDA(S)      KINSOL
+ *  ------------------------------------------------------------
+ *  GetType             M I P#    M I P#     M I P#      M I P
+ *  SetATimes           I         I S+       I           I
+ *  SetPreconditioner   I*        I* S*      I*          I*
+ *  SetScalingVectors   I         I S+       I           I 
+ *  Initialize          M I P#    M I P# S   M I P#      M I P
+ *  Setup               M I P#    M I P# S   M I P#      M I P      
+ *  Solve               M I P#    M I P# S   M I P#      M I P
+ *  NumIters            I         I S+       I           I
+ *  ResNorm             I         I S+       I           I
+ *  Resid                                    I
+ *  LastFlag^
+ *  Space               M I P#    M I P# S   M I P#      M I P
+ *  Free                M I P#    M I P# S   M I P#      M I P
+ *  ------------------------------------------------------------
+ * Notes: * -- only if user calls integrator-specific 
+ *             preconditioner "set" routine
+ *        + -- only called when using a non-identity mass matrix
+ *             with an iterative linear solver
+ *        # -- planned (currently only available for KINSOL)         
+ *        ^ -- available for users to diagnose solver failures
+ * ---------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType(SUNLinearSolver S);
+
+SUNDIALS_EXPORT int SUNLinSolSetATimes(SUNLinearSolver S, void* A_data,
+                                       ATimesFn ATimes);
+  
+SUNDIALS_EXPORT int SUNLinSolSetPreconditioner(SUNLinearSolver S, void* P_data,
+                                               PSetupFn Pset, PSolveFn Psol);
+  
+SUNDIALS_EXPORT int SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1,
+                                               N_Vector s2);
+  
+SUNDIALS_EXPORT int SUNLinSolInitialize(SUNLinearSolver S);
+  
+SUNDIALS_EXPORT int SUNLinSolSetup(SUNLinearSolver S, SUNMatrix A);
+  
+SUNDIALS_EXPORT int SUNLinSolSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x,
+                                   N_Vector b, realtype tol);
+  
+SUNDIALS_EXPORT int SUNLinSolNumIters(SUNLinearSolver S);
+  
+SUNDIALS_EXPORT realtype SUNLinSolResNorm(SUNLinearSolver S);
+  
+SUNDIALS_EXPORT N_Vector SUNLinSolResid(SUNLinearSolver S);
+  
+SUNDIALS_EXPORT long int SUNLinSolLastFlag(SUNLinearSolver S);
+  
+SUNDIALS_EXPORT int SUNLinSolSpace(SUNLinearSolver S, long int *lenrwLS,
+                                   long int *leniwLS);
+  
+SUNDIALS_EXPORT int SUNLinSolFree(SUNLinearSolver S);
+
+
+/*
+ * -----------------------------------------------------------------
+ * IV. SUNLinearSolver error codes
+ * ---------------------------------------------------------------
+ */
+
+#define SUNLS_SUCCESS             0  /* successful/converged          */
+
+#define SUNLS_MEM_NULL           -1  /* mem argument is NULL          */
+#define SUNLS_ILL_INPUT          -2  /* illegal function input        */
+#define SUNLS_MEM_FAIL           -3  /* failed memory access          */
+#define SUNLS_ATIMES_FAIL_UNREC  -4  /* atimes unrecoverable failure  */
+#define SUNLS_PSET_FAIL_UNREC    -5  /* pset unrecoverable failure    */
+#define SUNLS_PSOLVE_FAIL_UNREC  -6  /* psolve unrecoverable failure  */
+#define SUNLS_PACKAGE_FAIL_UNREC -7  /* external package unrec. fail  */
+#define SUNLS_GS_FAIL            -8  /* Gram-Schmidt failure          */        
+#define SUNLS_QRSOL_FAIL         -9  /* QRsol found singular R        */
+
+#define SUNLS_RES_REDUCED         1  /* nonconv. solve, resid reduced */
+#define SUNLS_CONV_FAIL           2  /* nonconvergent solve           */
+#define SUNLS_ATIMES_FAIL_REC     3  /* atimes failed recoverably     */
+#define SUNLS_PSET_FAIL_REC       4  /* pset failed recoverably       */
+#define SUNLS_PSOLVE_FAIL_REC     5  /* psolve failed recoverably     */
+#define SUNLS_PACKAGE_FAIL_REC    6  /* external package recov. fail  */
+#define SUNLS_QRFACT_FAIL         7  /* QRfact found singular matrix  */
+#define SUNLS_LUFACT_FAIL         8  /* LUfact found singular matrix  */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_math.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_math.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_math.h	(revision 16222)
@@ -0,0 +1,133 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
+ *                Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for a simple C-language math library. The
+ * routines listed here work with the type realtype as defined in
+ * the header file sundials_types.h.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNDIALSMATH_H
+#define _SUNDIALSMATH_H
+
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Macros : MIN and MAX
+ * -----------------------------------------------------------------
+ * MIN(A,B) returns the minimum of A and B
+ *
+ * MAX(A,B) returns the maximum of A and B
+ *
+ * SQR(A) returns A^2
+ * -----------------------------------------------------------------
+ */
+
+#ifndef SUNMIN
+#define SUNMIN(A, B) ((A) < (B) ? (A) : (B))
+#endif
+
+#ifndef SUNMAX
+#define SUNMAX(A, B) ((A) > (B) ? (A) : (B))
+#endif
+
+#ifndef SUNSQR
+#define SUNSQR(A) ((A)*(A))
+#endif
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SUNRpowerI
+ * -----------------------------------------------------------------
+ * Usage : int exponent;
+ *         realtype base, ans;
+ *         ans = SUNRpowerI(base,exponent);
+ * -----------------------------------------------------------------
+ * SUNRpowerI returns the value of base^exponent, where base is of type
+ * realtype and exponent is of type int.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype SUNRpowerI(realtype base, int exponent);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SUNRpowerR
+ * -----------------------------------------------------------------
+ * Usage : realtype base, exponent, ans;
+ *         ans = SUNRpowerR(base,exponent);
+ * -----------------------------------------------------------------
+ * SUNRpowerR returns the value of base^exponent, where both base and
+ * exponent are of type realtype. If base < ZERO, then SUNRpowerR
+ * returns ZERO.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype SUNRpowerR(realtype base, realtype exponent);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SUNRsqrt
+ * -----------------------------------------------------------------
+ * Usage : realtype sqrt_x;
+ *         sqrt_x = SUNRsqrt(x);
+ * -----------------------------------------------------------------
+ * SUNRsqrt(x) returns the square root of x. If x < ZERO, then
+ * SUNRsqrt returns ZERO.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype SUNRsqrt(realtype x);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SUNRabs
+ * -----------------------------------------------------------------
+ * Usage : realtype abs_x;
+ *         abs_x = SUNRabs(x);
+ * -----------------------------------------------------------------
+ * SUNRabs(x) returns the absolute value of x.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype SUNRabs(realtype x);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SUNRexp
+ * -----------------------------------------------------------------
+ * Usage : realtype exp_x;
+ *         exp_x = SUNRexp(x);
+ * -----------------------------------------------------------------
+ * SUNRexp(x) returns e^x (base-e exponential function).
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype SUNRexp(realtype x);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_matrix.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_matrix.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_matrix.h	(revision 16222)
@@ -0,0 +1,196 @@
+/*
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Daniel Reynolds @ SMU
+ *                David Gardner, Carol Woodward, Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for a generic matrix package.
+ * It defines the SUNMatrix structure (_generic_SUNMatrix) which
+ * contains the following fields:
+ *   - an implementation-dependent 'content' field which contains
+ *     the description and actual data of the matrix
+ *   - an 'ops' filed which contains a structure listing operations
+ *     acting on such matrices
+ *
+ * Part I of this file contains enumeration constants for all 
+ * SUNDIALS-defined matrix types, as well as a generic type for 
+ * user-supplied matrix types.
+ *
+ * Part II of this file contains type declarations for the
+ * _generic_SUNMatrix and _generic_SUNMatrix_Ops structures, as well
+ * as references to pointers to such structures (SUNMatrix).
+ *
+ * Part III of this file contains the prototypes for the matrix
+ * functions which operate on SUNMatrix.
+ *
+ * At a minimum, a particular implementation of a SUNMatrix must
+ * do the following:
+ *  - specify the 'content' field of SUNMatrix,
+ *  - implement the operations on those SUNMatrix,
+ *  - provide a constructor routine for new SUNMatrix objects
+ *
+ * Additionally, a SUNMatrix implementation may provide the following:
+ *  - macros to access the underlying SUNMatrix data
+ *  - a routine to print the content of a SUNMatrix
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNMATRIX_H
+#define _SUNMATRIX_H
+ 
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+ 
+  
+/*
+ * -----------------------------------------------------------------
+ * I. Implemented SUNMatrix types
+ * -----------------------------------------------------------------
+ */
+ 
+typedef enum {
+  SUNMATRIX_DENSE, 
+  SUNMATRIX_BAND, 
+  SUNMATRIX_SPARSE, 
+  SUNMATRIX_CUSTOM
+} SUNMatrix_ID;
+
+  
+/*
+ * -----------------------------------------------------------------
+ * II. Generic definition of SUNMatrix 
+ * -----------------------------------------------------------------
+ */
+ 
+/* Forward reference for pointer to SUNMatrix_Ops object */
+typedef struct _generic_SUNMatrix_Ops *SUNMatrix_Ops;
+ 
+/* Forward reference for pointer to SUNMatrix object */
+typedef struct _generic_SUNMatrix *SUNMatrix;
+ 
+/* Structure containing function pointers to matrix operations  */  
+struct _generic_SUNMatrix_Ops {
+  SUNMatrix_ID (*getid)(SUNMatrix);
+  SUNMatrix    (*clone)(SUNMatrix);
+  void         (*destroy)(SUNMatrix);
+  int          (*zero)(SUNMatrix);
+  int          (*copy)(SUNMatrix, SUNMatrix);
+  int          (*scaleadd)(realtype, SUNMatrix, SUNMatrix);
+  int          (*scaleaddi)(realtype, SUNMatrix);
+  int          (*matvec)(SUNMatrix, N_Vector, N_Vector);
+  int          (*space)(SUNMatrix, long int*, long int*);
+};
+ 
+/* A matrix is a structure with an implementation-dependent
+   'content' field, and a pointer to a structure of matrix
+   operations corresponding to that implementation.  */
+struct _generic_SUNMatrix {
+  void *content;
+  struct _generic_SUNMatrix_Ops *ops;
+};
+
+  
+/*
+ * -----------------------------------------------------------------
+ * III. Functions exported by SUNMatrix module
+ *
+ * SUNMatGetID
+ *   Returns an identifier for the matrix type from the enumeration 
+ *   SUNMatrix_ID.  This will be queried by a given linear solver to 
+ *   assess compatibility.
+ *
+ * SUNMatClone
+ *   Creates a new matrix of the same type as an existing matrix.
+ *   It does not copy the matrix, but rather allocates storage for
+ *   the new matrix.
+ *
+ * SUNMatDestroy
+ *   Destroys a matrix created with SUNMatClone.
+ *
+ * SUNMatZero
+ *   Sets all matrix entries to zero
+ *
+ * SUNMatScaleAdd
+ *   Performs the operation A = c*A + B.  Returns an error if A 
+ *   and B have different types and/or dimensions.
+ *
+ * SUNMatCopy
+ *   Performs the operation B = A.  Should return an error if A and 
+ *   B have different types and/or dimensions.
+ *
+ * SUNMatScaleAddI
+ *   Performs the operation A = c*A + I.  Returns an error if A is 
+ *   not a square matrix.
+ *
+ * SUNMatMatvec
+ *   Performs the matrix-vector product y = A*x.  Returns an error if 
+ *   A, x and/or y have incompatible types and/or dimensions, or if 
+ *   x and y are the same vector.
+ *
+ * SUNMatSpace
+ *   Returns the real and integer workspace requirement for the 
+ *   SUNMatrix object.
+ *
+ * -----------------------------------------------------------------
+ *
+ * The following table lists the matrix functions used by
+ * different modules in SUNDIALS. The symbols in the table
+ * have the following meaning:
+ *   D  -  called by dense linear solver modules
+ *   B  -  called by band linear solver modules
+ *   I  -  called by iterative linear solver modules
+ *   S  -  called by sparse linear solver modules
+ *   BP -  called by band preconditioner module
+ *   DP -  called by band-block diagonal preconditioner module
+ *
+ *                                MODULES                  
+ * MATRIX        -----------------------------------------------
+ * FUNCTIONS     CVODE(S)      ARKode      IDA(S)       KINSOL    
+ * ----------------------------------------------------------------
+ *  GetID        D B S BP DP  D B S BP DP  D B S BP DP  D B S BP DP
+ *  Clone        D B S BP DP  D B S BP DP  BP DP
+ *  Destroy      D B S BP DP  D B S BP DP  BP DP
+ *  Zero         D B S BP DP  D B S BP DP  D B S BP DP  D B BP DP
+ *  Copy         D B S BP DP  D B S BP DP
+ *  ScaleAddI    D B S BP DP  D B S BP DP
+ *  ScaleAdd                  D B S BP DP
+ *  Matvec*                   D B S
+ *  Space        D B S BP DP  D B S BP DP  D B S BP DP  D B S BP DP
+ * -----------------------------------------------------------------
+ *  Note: MatrixMatvec is only called by ARKode when solving 
+ *        problems having non-identity mass matrix
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID(SUNMatrix A);
+SUNDIALS_EXPORT SUNMatrix SUNMatClone(SUNMatrix A);
+SUNDIALS_EXPORT void SUNMatDestroy(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatZero(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatCopy(SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAdd(realtype c, SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAddI(realtype c, SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatMatvec(SUNMatrix A, N_Vector x, N_Vector y);
+SUNDIALS_EXPORT int SUNMatSpace(SUNMatrix A, long int *lenrw,
+                                long int *leniw);
+ 
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_mpi.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_mpi.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_mpi.h	(revision 16222)
@@ -0,0 +1,54 @@
+/* -----------------------------------------------------------------
+ * Programmer(s): Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department
+ * of Energy by Lawrence Livermore National Laboratory in part under
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This header file contains definitions of MPI data types, which
+ * are used by MPI parallel vector implementations.
+ * -----------------------------------------------------------------*/
+
+#ifndef _SUNDIALS_MPI_H
+#define _SUNDIALS_MPI_H
+
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_mpi_types.h>
+
+
+#if SUNDIALS_MPI_ENABLED
+
+#include <mpi.h>
+#define SUNMPI_COMM_WORLD MPI_COMM_WORLD
+
+typedef MPI_Comm SUNMPI_Comm;
+
+#else
+
+#define SUNMPI_COMM_WORLD 0
+
+typedef int SUNMPI_Comm;
+
+#endif
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+SUNDIALS_EXPORT int SUNMPI_Comm_size(SUNMPI_Comm comm, int *size);
+SUNDIALS_EXPORT realtype SUNMPI_Allreduce_scalar(realtype d, int op, SUNMPI_Comm comm);
+SUNDIALS_EXPORT void SUNMPI_Allreduce(realtype *d, int nvec, int op, SUNMPI_Comm comm);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* _SUNDIALS_MPI_H */
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_mpi_types.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_mpi_types.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_mpi_types.h	(revision 16222)
@@ -0,0 +1,36 @@
+/* -----------------------------------------------------------------
+ * Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban,
+ *                Aaron Collier, and Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This header file contains definitions of MPI data types, which 
+ * are used by MPI parallel vector implementations.
+ * -----------------------------------------------------------------*/
+
+#include <sundials/sundials_types.h>
+
+/* define MPI data types */
+
+#if defined(SUNDIALS_SINGLE_PRECISION)
+  #define PVEC_REAL_MPI_TYPE MPI_FLOAT
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  #define PVEC_REAL_MPI_TYPE MPI_DOUBLE
+#elif defined(SUNDIALS_EXTENDED_PRECISION)
+  #define PVEC_REAL_MPI_TYPE MPI_LONG_DOUBLE
+#endif
+
+#if defined(SUNDIALS_INT64_T)
+  #define PVEC_INTEGER_MPI_TYPE MPI_INT64_T
+#elif defined(SUNDIALS_INT32_T)
+  #define PVEC_INTEGER_MPI_TYPE MPI_INT32_T
+#endif
+
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_nvector.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_nvector.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_nvector.h	(revision 16222)
@@ -0,0 +1,405 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Radu Serban and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for a generic NVECTOR package.
+ * It defines the N_Vector structure (_generic_N_Vector) which
+ * contains the following fields:
+ *   - an implementation-dependent 'content' field which contains
+ *     the description and actual data of the vector
+ *   - an 'ops' filed which contains a structure listing operations
+ *     acting on such vectors
+ *
+ * Part I of this file contains type declarations for the
+ * _generic_N_Vector and _generic_N_Vector_Ops structures, as well
+ * as references to pointers to such structures (N_Vector).
+ *
+ * Part II of this file contains the prototypes for the vector
+ * functions which operate on N_Vector.
+ *
+ * At a minimum, a particular implementation of an NVECTOR must
+ * do the following:
+ *  - specify the 'content' field of N_Vector,
+ *  - implement the operations on those N_Vectors,
+ *  - provide a constructor routine for new vectors
+ *
+ * Additionally, an NVECTOR implementation may provide the following:
+ *  - macros to access the underlying N_Vector data
+ *  - a constructor for an array of N_Vectors
+ *  - a constructor for an empty N_Vector (i.e., a new N_Vector with
+ *    a NULL data pointer).
+ *  - a routine to print the content of an N_Vector
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _NVECTOR_H
+#define _NVECTOR_H
+
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  
+/*
+ * -----------------------------------------------------------------
+ * Implemented N_Vector types
+ * -----------------------------------------------------------------
+ */
+  
+typedef enum {
+  SUNDIALS_NVEC_SERIAL, 
+  SUNDIALS_NVEC_PARALLEL, 
+  SUNDIALS_NVEC_OPENMP, 
+  SUNDIALS_NVEC_PTHREADS, 
+  SUNDIALS_NVEC_PARHYP, 
+  SUNDIALS_NVEC_PETSC,
+  SUNDIALS_NVEC_CUDA,
+  SUNDIALS_NVEC_RAJA,
+  SUNDIALS_NVEC_CUSTOM
+} N_Vector_ID;
+  
+/*
+ * -----------------------------------------------------------------
+ * Generic definition of N_Vector
+ * -----------------------------------------------------------------
+ */
+
+/* Forward reference for pointer to N_Vector_Ops object */
+typedef struct _generic_N_Vector_Ops *N_Vector_Ops;
+
+/* Forward reference for pointer to N_Vector object */
+typedef struct _generic_N_Vector *N_Vector;
+
+/* Define array of N_Vectors */
+typedef N_Vector *N_Vector_S;
+
+/* Structure containing function pointers to vector operations  */  
+struct _generic_N_Vector_Ops {
+  N_Vector_ID (*nvgetvectorid)(N_Vector);
+  N_Vector    (*nvclone)(N_Vector);
+  N_Vector    (*nvcloneempty)(N_Vector);
+  void        (*nvdestroy)(N_Vector);
+  void        (*nvspace)(N_Vector, sunindextype *, sunindextype *);
+  realtype*   (*nvgetarraypointer)(N_Vector);
+  void        (*nvsetarraypointer)(realtype *, N_Vector);
+  void        (*nvlinearsum)(realtype, N_Vector, realtype, N_Vector, N_Vector); 
+  void        (*nvconst)(realtype, N_Vector);
+  void        (*nvprod)(N_Vector, N_Vector, N_Vector);
+  void        (*nvdiv)(N_Vector, N_Vector, N_Vector);
+  void        (*nvscale)(realtype, N_Vector, N_Vector);
+  void        (*nvabs)(N_Vector, N_Vector);
+  void        (*nvinv)(N_Vector, N_Vector);
+  void        (*nvaddconst)(N_Vector, realtype, N_Vector);
+  realtype    (*nvdotprod)(N_Vector, N_Vector);
+  realtype    (*nvmaxnorm)(N_Vector);
+  realtype    (*nvwrmsnorm)(N_Vector, N_Vector);
+  realtype    (*nvwrmsnormmask)(N_Vector, N_Vector, N_Vector);
+  realtype    (*nvmin)(N_Vector);
+  realtype    (*nvwl2norm)(N_Vector, N_Vector);
+  realtype    (*nvl1norm)(N_Vector);
+  void        (*nvcompare)(realtype, N_Vector, N_Vector);
+  booleantype (*nvinvtest)(N_Vector, N_Vector);
+  booleantype (*nvconstrmask)(N_Vector, N_Vector, N_Vector);
+  realtype    (*nvminquotient)(N_Vector, N_Vector);
+};
+
+/*
+ * -----------------------------------------------------------------
+ * A vector is a structure with an implementation-dependent
+ * 'content' field, and a pointer to a structure of vector
+ * operations corresponding to that implementation.
+ * -----------------------------------------------------------------
+ */
+
+struct _generic_N_Vector {
+  void *content;
+  struct _generic_N_Vector_Ops *ops;
+};
+  
+/*
+ * -----------------------------------------------------------------
+ * Functions exported by NVECTOR module
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * N_VGetVectorID
+ *   Returns an identifier for the vector type from enumeration 
+ *   N_Vector_ID.
+ *
+ * N_VClone
+ *   Creates a new vector of the same type as an existing vector.
+ *   It does not copy the vector, but rather allocates storage for
+ *   the new vector.
+ *
+ * N_VCloneEmpty
+ *   Creates a new vector of the same type as an existing vector,
+ *   but does not allocate storage.
+ *
+ * N_VDestroy
+ *   Destroys a vector created with N_VClone.
+ *
+ * N_VSpace
+ *   Returns space requirements for one N_Vector (type 'realtype' in
+ *   lrw and type 'sunindextype' in liw).
+ *
+ * N_VGetArrayPointer
+ *   Returns a pointer to the data component of the given N_Vector.
+ *   NOTE: This function assumes that the internal data is stored
+ *   as a contiguous 'realtype' array. This routine is only used in
+ *   the solver-specific interfaces to the dense and banded linear
+ *   solvers, as well as the interfaces to  the banded preconditioners
+ *   distributed with SUNDIALS.
+ *   
+ * N_VSetArrayPointer
+ *   Overwrites the data field in the given N_Vector with a user-supplied
+ *   array of type 'realtype'.
+ *   NOTE: This function assumes that the internal data is stored
+ *   as a contiguous 'realtype' array. This routine is only used in
+ *   the interfaces to the dense linear solver.
+ *
+ * N_VLinearSum
+ *   Performs the operation z = a*x + b*y
+ *
+ * N_VConst
+ *   Performs the operation z[i] = c for i = 0, 1, ..., N-1
+ *
+ * N_VProd
+ *   Performs the operation z[i] = x[i]*y[i] for i = 0, 1, ..., N-1
+ *
+ * N_VDiv
+ *   Performs the operation z[i] = x[i]/y[i] for i = 0, 1, ..., N-1
+ *
+ * N_VScale
+ *   Performs the operation z = c*x
+ *
+ * N_VAbs
+ *   Performs the operation z[i] = |x[i]| for i = 0, 1, ..., N-1
+ *
+ * N_VInv
+ *   Performs the operation z[i] = 1/x[i] for i = 0, 1, ..., N-1
+ *   This routine does not check for division by 0. It should be
+ *   called only with an N_Vector x which is guaranteed to have
+ *   all non-zero components.
+ *
+ * N_VAddConst
+ *   Performs the operation z[i] = x[i] + b   for i = 0, 1, ..., N-1
+ *
+ * N_VDotProd
+ *   Returns the dot product of two vectors:
+ *         sum (i = 0 to N-1) {x[i]*y[i]}
+ *
+ * N_VMaxNorm
+ *   Returns the maximum norm of x:
+ *         max (i = 0 to N-1) ABS(x[i])
+ *
+ * N_VWrmsNorm
+ *   Returns the weighted root mean square norm of x with weight 
+ *   vector w:
+ *         sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})/N]
+ *
+ * N_VWrmsNormMask
+ *   Returns the weighted root mean square norm of x with weight
+ *   vector w, masked by the elements of id:
+ *         sqrt [(sum (i = 0 to N-1) {(x[i]*w[i]*msk[i])^2})/N]
+ *   where msk[i] = 1.0 if id[i] > 0 and
+ *         msk[i] = 0.0 if id[i] < 0
+ *
+ * N_VMin
+ *   Returns the smallest element of x:
+ *         min (i = 0 to N-1) x[i]
+ *
+ * N_VWL2Norm
+ *   Returns the weighted Euclidean L2 norm of x with weight 
+ *   vector w:
+ *         sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})]
+ *
+ * N_VL1Norm
+ *   Returns the L1 norm of x:
+ *         sum (i = 0 to N-1) {ABS(x[i])}
+ *
+ * N_VCompare
+ *   Performs the operation
+ *          z[i] = 1.0 if ABS(x[i]) >= c   i = 0, 1, ..., N-1
+ *                 0.0 otherwise
+ *
+ * N_VInvTest
+ *   Performs the operation z[i] = 1/x[i] with a test for 
+ *   x[i] == 0.0 before inverting x[i].
+ *   This routine returns SUNTRUE if all components of x are non-zero 
+ *   (successful inversion) and returns SUNFALSE otherwise.
+ *
+ * N_VConstrMask
+ *   Performs the operation : 
+ *       m[i] = 1.0 if constraint test fails for x[i]
+ *       m[i] = 0.0 if constraint test passes for x[i]
+ *   where the constraint tests are as follows:
+ *      If c[i] = +2.0, then x[i] must be >  0.0.
+ *      If c[i] = +1.0, then x[i] must be >= 0.0.
+ *      If c[i] = -1.0, then x[i] must be <= 0.0.
+ *      If c[i] = -2.0, then x[i] must be <  0.0.
+ *   This routine returns a boolean SUNFALSE if any element failed
+ *   the constraint test, SUNTRUE if all passed. It also sets a
+ *   mask vector m, with elements equal to 1.0 where the
+ *   corresponding constraint test failed, and equal to 0.0
+ *   where the constraint test passed.
+ *   This routine is specialized in that it is used only for
+ *   constraint checking.
+ *
+ * N_VMinQuotient
+ *   Performs the operation : 
+ *       minq  = min ( num[i]/denom[i]) over all i such that   
+ *       denom[i] != 0.
+ *   This routine returns the minimum of the quotients obtained
+ *   by term-wise dividing num[i] by denom[i]. A zero element
+ *   in denom will be skipped. If no such quotients are found,
+ *   then the large value BIG_REAL is returned.
+ *
+ * -----------------------------------------------------------------
+ *
+ * The following table lists the vector functions used by
+ * different modules in SUNDIALS. The symbols in the table
+ * have the following meaning:
+ * S    -  called by the solver;
+ * D    -  called by the dense linear solver module
+ * B    -  called by the band linear solver module
+ * Di   -  called by the diagonal linear solver module
+ * I    -  called by the iterative linear solver module
+ * BP   -  called by the band preconditioner module
+ * BBDP -  called by the band-block diagonal preconditioner module
+ * F    -  called by the Fortran-to-C interface
+ *
+ *                  ------------------------------------------------
+ *                                         MODULES                  
+ * NVECTOR          ------------------------------------------------
+ * FUNCTIONS          CVODE/CVODES          IDA             KINSOL    
+ * -----------------------------------------------------------------
+ * N_VGetVectorID     
+ * -----------------------------------------------------------------
+ * N_VClone           S Di I                S I BBDP        S I BBDP
+ * -----------------------------------------------------------------
+ * N_VCloneEmpty      F                     F               F
+ * -----------------------------------------------------------------
+ * N_VDestroy         S Di I                S I BBDP        S I BBDP
+ * -----------------------------------------------------------------
+ * N_VSpace           S                     S               S         
+ * -----------------------------------------------------------------
+ * N_VGetArrayPointer D B BP BBDP F         D B BBDP        BBDP F     
+ * -----------------------------------------------------------------
+ * N_VSetArrayPointer D F                   D               F
+ * -----------------------------------------------------------------
+ * N_VLinearSum       S D Di I              S D I           S I       
+ * -----------------------------------------------------------------
+ * N_VConst           S I                   S I             I       
+ * -----------------------------------------------------------------
+ * N_VProd            S Di I                S I             S I       
+ * -----------------------------------------------------------------
+ * N_VDiv             S Di I                S I             S I
+ * -----------------------------------------------------------------
+ * N_VScale           S D B Di I BP BBDP    S D B I BBDP    S I BBDP  
+ * -----------------------------------------------------------------
+ * N_VAbs             S                     S               S         
+ * -----------------------------------------------------------------
+ * N_VInv             S Di                  S               S         
+ * -----------------------------------------------------------------
+ * N_VAddConst        S Di                  S                        
+ * -----------------------------------------------------------------
+ * N_VDotProd         I                     I               I         
+ * -----------------------------------------------------------------
+ * N_VMaxNorm         S                     S               S         
+ * -----------------------------------------------------------------
+ * N_VWrmsNorm        S D B I BP BBDP       S                         
+ * -----------------------------------------------------------------
+ * N_VWrmsNormMask                          S                         
+ * -----------------------------------------------------------------
+ * N_VMin             S                     S               S         
+ * -----------------------------------------------------------------
+ * N_VWL2Norm                                               S I       
+ * -----------------------------------------------------------------
+ * N_VL1Norm                                                I
+ * -----------------------------------------------------------------
+ * N_VCompare         Di                    S                         
+ * -----------------------------------------------------------------
+ * N_VInvTest         Di                                              
+ * -----------------------------------------------------------------
+ * N_VConstrMask                            S               S         
+ * -----------------------------------------------------------------
+ * N_VMinQuotient                           S               S         
+ * -----------------------------------------------------------------
+ */
+  
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VClone(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VCloneEmpty(N_Vector w);
+SUNDIALS_EXPORT void N_VDestroy(N_Vector v);
+SUNDIALS_EXPORT void N_VSpace(N_Vector v, sunindextype *lrw, sunindextype *liw);
+SUNDIALS_EXPORT realtype *N_VGetArrayPointer(N_Vector v);
+SUNDIALS_EXPORT void N_VSetArrayPointer(realtype *v_data, N_Vector v);
+SUNDIALS_EXPORT void N_VLinearSum(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VConst(realtype c, N_Vector z);
+SUNDIALS_EXPORT void N_VProd(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VDiv(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VScale(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAbs(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VInv(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAddConst(N_Vector x, realtype b, N_Vector z);
+SUNDIALS_EXPORT realtype N_VDotProd(N_Vector x, N_Vector y);
+SUNDIALS_EXPORT realtype N_VMaxNorm(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWrmsNorm(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VWrmsNormMask(N_Vector x, N_Vector w, N_Vector id);
+SUNDIALS_EXPORT realtype N_VMin(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWL2Norm(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VL1Norm(N_Vector x);
+SUNDIALS_EXPORT void N_VCompare(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VInvTest(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VConstrMask(N_Vector c, N_Vector x, N_Vector m);
+SUNDIALS_EXPORT realtype N_VMinQuotient(N_Vector num, N_Vector denom);
+
+/*
+ * -----------------------------------------------------------------
+ * Additional functions exported by NVECTOR module
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * N_VCloneEmptyVectorArray
+ *   Creates (by cloning 'w') an array of 'count' empty N_Vectors 
+ *
+ * N_VCloneVectorArray
+ *   Creates (by cloning 'w') an array of 'count' N_Vectors 
+ *
+ * N_VDestroyVectorArray
+ *   Frees memory for an array of 'count' N_Vectors that was
+ *   created by a call to N_VCloneVectorArray
+ *
+ * These functions are used by the SPGMR iterative linear solver 
+ * module and by the CVODES and IDAS solvers.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneEmptyVectorArray(int count, N_Vector w);
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray(int count, N_Vector w);
+SUNDIALS_EXPORT void N_VDestroyVectorArray(N_Vector *vs, int count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_pcg.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_pcg.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_pcg.h	(revision 16222)
@@ -0,0 +1,156 @@
+/*---------------------------------------------------------------
+ Programmer(s): Daniel R. Reynolds @ SMU
+ ----------------------------------------------------------------
+ Copyright (c) 2013, Southern Methodist University.
+ All rights reserved.
+ For details, see the LICENSE file.
+ ----------------------------------------------------------------
+ This is the header for the preconditioned conjugate gradient 
+ solver in SUNDIALS.
+ ---------------------------------------------------------------*/
+
+#ifndef _PCG_H
+#define _PCG_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ Types: struct PcgMemRec and struct *PcgMem
+ ----------------------------------------------------------------
+ A variable declaration of type struct *PcgMem denotes a pointer
+ to a data structure of type struct PcgMemRec. The PcgMemRec
+ structure contains numerous fields that must be accessed by the
+ PCG linear solver module.
+  * l_max  maximum Krylov subspace dimension that PcgSolve will
+       be permitted to use
+  * r  vector (type N_Vector) which holds the preconditioned 
+       linear system residual
+  * p, z and Ap vectors (type N_Vector) used for workspace by
+       the PCG algorithm
+  * vtemp  scratch vector (type N_Vector) used as temporary 
+       vector storage
+ --------------------------------------------------------------*/
+typedef struct {
+  int l_max;
+  N_Vector r;
+  N_Vector p;
+  N_Vector z;
+  N_Vector Ap;
+} PcgMemRec, *PcgMem;
+
+/*---------------------------------------------------------------
+ Function : PcgMalloc
+ ----------------------------------------------------------------
+ PcgMalloc allocates additional memory needed by the PCG linear 
+ solver module.
+
+   l_max  maximum Krylov subspace dimension that PcgSolve will
+          be permitted to use
+
+   vec_tmpl implementation-specific template vector (of type 
+          N_Vector)
+
+ If successful, PcgMalloc returns a non-NULL memory pointer. If
+ an error occurs, then a NULL pointer is returned.
+ --------------------------------------------------------------*/
+
+SUNDIALS_EXPORT PcgMem PcgMalloc(int l_max, N_Vector vec_tmpl);
+
+/*---------------------------------------------------------------
+ Function : PcgSolve
+ ----------------------------------------------------------------
+ PcgSolve solves the linear system Ax = b by means of a 
+ preconditioned Conjugate-Gradient (PCG) iterative method.
+
+  mem  pointer to an internal memory block allocated during a
+       prior call to PcgMalloc
+
+  A_data  pointer to a data structure containing information
+       about the coefficient matrix A (passed to user-supplied
+       function referenced by atimes (function pointer))
+
+  x  vector (type N_Vector) containing initial guess x_0 upon
+       entry, but which upon return contains an approximate 
+       solution of the linear system Ax = b (solution only 
+       valid if return value is either PCG_SUCCESS or 
+       PCG_RES_REDUCED)
+
+  b  vector (type N_Vector) set to the right-hand side vector b
+       of the linear system (unchanged by function)
+
+  pretype  variable (type int) indicating the type of
+       preconditioning to be used (see sundials_iterative.h);
+       Note: since CG is for symmetric problems, preconditioning 
+       is applied symmetrically by default, so any nonzero flag 
+       will indicate to use the preconditioner.
+
+  delta  tolerance on the L2 norm of the residual (if the 
+       return value == PCG_SUCCESS, then ||b-Ax||_L2 <= delta)
+
+  P_data  pointer to a data structure containing preconditioner
+       information (passed to user-supplied function referenced
+       by psolve (function pointer))
+
+  w  vector (type N_Vector) used in computing the residual norm 
+       for stopping solver (unchanged by function).  This is 
+       needed since PCG cannot utilize the same scaling vectors 
+       as used in the other SUNDIALS solvers, due to 
+       symmetry-breaking nature of scaling operators.
+
+  atimes  user-supplied routine responsible for computing the
+       matrix-vector product Ax (see sundials_iterative.h)
+
+  psolve  user-supplied routine responsible for solving the
+       preconditioned linear system Pz = r (ignored if
+       pretype == PREC_NONE) (see sundials_iterative.h)
+
+  res_norm  pointer (type realtype*) to the L2 norm of the
+       residual (if return value is either PCG_SUCCESS or 
+       PCG_RES_REDUCED, then
+            *res_norm = ||b-Ax||_L2, where x is
+       the computed approximate solution)
+
+  nli  pointer (type int*) to the total number of linear
+       iterations performed
+
+  nps  pointer (type int*) to the total number of calls made
+       to the psolve routine
+ --------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int PcgSolve(PcgMem mem, void *A_data, N_Vector x, N_Vector b,
+			     int pretype, realtype delta, void *P_data, 
+			     N_Vector w, ATimesFn atimes, PSolveFn psolve,
+			     realtype *res_norm, int *nli, int *nps);
+
+/* Return values for PcgSolve */
+#define PCG_SUCCESS            0  /* PCG algorithm converged          */
+#define PCG_RES_REDUCED        1  /* PCG did NOT converge, but the
+				       residual was reduced           */
+#define PCG_CONV_FAIL          2  /* PCG algorithm failed to converge */
+#define PCG_PSOLVE_FAIL_REC    3  /* psolve failed recoverably        */
+#define PCG_ATIMES_FAIL_REC    4  /* atimes failed recoverably        */
+#define PCG_PSET_FAIL_REC      5  /* pset faild recoverably           */
+
+#define PCG_MEM_NULL          -1  /* mem argument is NULL             */
+#define PCG_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag     */
+#define PCG_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably      */
+#define PCG_PSET_FAIL_UNREC   -4  /* pset failed unrecoverably        */
+
+/*---------------------------------------------------------------
+ Function : PcgFree
+ ----------------------------------------------------------------
+ PcgFree frees the memory allocated by a call to PcgMalloc.
+ It is illegal to use the pointer mem after a call to PcgFree.
+ ---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT void PcgFree(PcgMem mem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_sparse.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_sparse.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_sparse.h	(revision 16222)
@@ -0,0 +1,237 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer: Carol Woodward, Slaven Peles @ LLNL,
+ *             Daniel R. Reynolds @ SMU.
+ * -----------------------------------------------------------------
+ * For details, see the LICENSE file.
+ * -----------------------------------------------------------------
+ * This header file contains definitions and declarations for use by
+ * sparse linear solvers for Ax = b. 
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNDIALS_SPARSE_H
+#define _SUNDIALS_SPARSE_H
+
+#include <stdio.h>
+
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_direct.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * ==================================================================
+ * Type definitions
+ * ==================================================================
+ */
+
+#define CSC_MAT 0
+#define CSR_MAT 1
+
+/*
+ * -----------------------------------------------------------------
+ * Type : SlsMat
+ * -----------------------------------------------------------------
+ * The type SlsMat is defined to be a pointer to a structure
+ * with various sizes, a data field, and arrays for the row and 
+ * column information for the sparse matrix entries.
+ * The M and N fields indicates the number 
+ * of rows and columns, respectively. The data field is a one 
+ * dimensional array used for component storage. The NNZ field indicates
+ * the number of nonzero entries in the matrix. The integer array, asub, 
+ * holds the row index for each of the matrix entries.  The integer
+ * array, xa, holds the index entry for the starting value of each column.
+ * -----------------------------------------------------------------
+ * The relevant fields in DlsMat are:
+ *    M     - number of rows
+ *    N     - number of columns
+ *    NNZ   - the number of nonzero entries in the matrix
+ *    NP    - number of index pointers
+ *    data  - pointer to a contiguous block of realtype variables
+ *    sparsetype - type of sparse matrix: compressed sparse column or row
+ *    indexvals  - indices of each nonzero entry (columns or rows)
+ *    indexptrs  - starting index of the first entry in data for each slice
+ *    rowvals - pointer to row indices of each nonzero entry
+ *    colptrs - pointer to starting indices in data array for each column
+ *    colvals - pointer to column indices of each nonzero entry
+ *    rowptrs - pointer to starting indices in data array for each row
+ *
+ * The nonzero entries of the matrix are stored in
+ * compressed column format.  Row indices of entries in 
+ * column j are stored in rowvals[colptrs[j]] through rowvals[colptrs[j+i]-1]
+ * and corresponding numerical values of the matrix are stored 
+ * in the same entries of data.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct _SlsMat {
+  int M;
+  int N;
+  int NNZ;
+  int NP;
+  realtype *data;
+  int sparsetype;
+  int *indexvals;
+  int *indexptrs;
+  /* CSC indices */
+  int **rowvals;
+  int **colptrs;
+  /* CSR indices */
+  int **colvals;
+  int **rowptrs;
+} *SlsMat;
+
+/*
+ * ==================================================================
+ * Exported function prototypes (functions working on SlsMat)
+ * ==================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SparseNewMat
+ * -----------------------------------------------------------------
+ * SparseNewMat allocates memory for a compressed column sparse
+ * matrix with M rows, N columns, NNZ nonzeros and of sparsetype 
+ * type (CSC or CSR matrix). SparseNewMat returns NULL if the 
+ * request for matrix storage cannot be satisfied. See the above 
+ * documentation for the type SlsMat for matrix storage details.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SlsMat SparseNewMat(int M, int N, int NNZ, int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SparseFromDenseMat
+ * -----------------------------------------------------------------
+ * SlsConvertDense creates a new CSC matrix from an existing
+ * dense/band matrix by copying all nonzero values into the sparse 
+ * matrix structure.  SlsConvertDense returns NULL if the request 
+ * for matrix storage cannot be satisfied. 
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SlsMat SparseFromDenseMat(const DlsMat A, int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseDestroyMat
+ * -----------------------------------------------------------------
+ * SparseDestroyMat frees the memory allocated by SparseNewMat
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseDestroyMat(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SparseSetMatToZero
+ * -----------------------------------------------------------------
+ * SetToZero sets all the elements of the sparse matrix A to 0.0.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseSetMatToZero(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseCopyMat
+ * -----------------------------------------------------------------
+ * This function copies sparse matrix A into sparse matrix B.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseCopyMat(const SlsMat A, SlsMat B);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseScaleMat
+ * -----------------------------------------------------------------
+ * This function scales all data entries of a sparse matrix A 
+ * by the realtype number in b.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseScaleMat(realtype b, SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseAddIdentityMat
+ * -----------------------------------------------------------------
+ * This function adds 1 to every diagonal entry of A.
+ * Note that the resulting matrix may have more nonzero entries than 
+ * the original.  This is accounted for, so that the return matrix 
+ * may be larger than the one sent in.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseAddIdentityMat(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseAddMat
+ * -----------------------------------------------------------------
+ * This function adds two sparse matrices: A = A+B.
+ * Note that the resulting matrix may have more nonzero entries than
+ * either of the original matrices.  This is accounted for, so that 
+ * the return matrix may be larger than the ones sent in.  Upon 
+ * successful completion, the return value is zero; otherwise 1 is 
+ * returned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseAddMat(SlsMat A, const SlsMat B);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseReallocMat
+ * -----------------------------------------------------------------
+ * This function reallocs internal arrays so that the resulting matrix 
+ * holds colptrs[N] nonzeros.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseReallocMat(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseMatvec
+ * -----------------------------------------------------------------
+ * This function computes the matrix-vector product, y=A*x, where A
+ * is a sparse matrix of dimension MxN, x is a realtype array of 
+ * length N, and y is a realtype array of length M. Upon successful
+ * completion, the return value is zero; otherwise 1 is returned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseMatvec(const SlsMat A, const realtype *x, realtype *y);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparsePrintMat
+ * -----------------------------------------------------------------
+ * This function prints the compressed column matrix information for 
+ * matrix A to standard output.
+ * It is intended as a debugging tool with small values of NNZ.
+ * The elements are printed using the %g/%lg/%Lg option. 
+ * A blank line is printed before and after the matrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SparsePrintMat(const SlsMat A, FILE* outfile);
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spbcgs.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spbcgs.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spbcgs.h	(revision 16222)
@@ -0,0 +1,204 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer(s): Peter Brown and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the implementation of the scaled,
+ * preconditioned Bi-CGSTAB (SPBCG) iterative linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SPBCG_H
+#define _SPBCG_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Types: struct SpbcgMemRec and struct *SpbcgMem
+ * -----------------------------------------------------------------
+ * A variable declaration of type struct *SpbcgMem denotes a pointer
+ * to a data structure of type struct SpbcgMemRec. The SpbcgMemRec
+ * structure contains numerous fields that must be accessed by the
+ * SPBCG linear solver module.
+ *
+ *  l_max  maximum Krylov subspace dimension that SpbcgSolve will
+ *         be permitted to use
+ *
+ *  r  vector (type N_Vector) which holds the scaled, preconditioned
+ *     linear system residual
+ *
+ *  r_star  vector (type N_Vector) which holds the initial scaled,
+ *          preconditioned linear system residual
+ *
+ *  p, q, u and Ap  vectors (type N_Vector) used for workspace by
+ *                  the SPBCG algorithm
+ *
+ *  vtemp  scratch vector (type N_Vector) used as temporary vector
+ *         storage
+ * -----------------------------------------------------------------
+ */
+
+typedef struct {
+
+  int l_max;
+
+  N_Vector r_star;
+  N_Vector r;
+  N_Vector p;
+  N_Vector q;
+  N_Vector u;
+  N_Vector Ap;
+  N_Vector vtemp;
+
+} SpbcgMemRec, *SpbcgMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SpbcgMalloc
+ * -----------------------------------------------------------------
+ * SpbcgMalloc allocates additional memory needed by the SPBCG
+ * linear solver module.
+ *
+ *  l_max  maximum Krylov subspace dimension that SpbcgSolve will
+ *         be permitted to use
+ *
+ *  vec_tmpl  implementation-specific template vector (type N_Vector)
+ *            (created using either N_VNew_Serial or N_VNew_Parallel)
+ *
+ * If successful, SpbcgMalloc returns a non-NULL memory pointer. If
+ * an error occurs, then a NULL pointer is returned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SpbcgMem SpbcgMalloc(int l_max, N_Vector vec_tmpl);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SpbcgSolve
+ * -----------------------------------------------------------------
+ * SpbcgSolve solves the linear system Ax = b by means of a scaled
+ * preconditioned Bi-CGSTAB (SPBCG) iterative method.
+ *
+ *  mem  pointer to an internal memory block allocated during a
+ *       prior call to SpbcgMalloc
+ *
+ *  A_data  pointer to a data structure containing information
+ *          about the coefficient matrix A (passed to user-supplied
+ *          function referenced by atimes (function pointer))
+ *
+ *  x  vector (type N_Vector) containing initial guess x_0 upon
+ *     entry, but which upon return contains an approximate solution
+ *     of the linear system Ax = b (solution only valid if return
+ *     value is either SPBCG_SUCCESS or SPBCG_RES_REDUCED)
+ *
+ *  b  vector (type N_Vector) set to the right-hand side vector b
+ *     of the linear system (undisturbed by function)
+ *
+ *  pretype  variable (type int) indicating the type of
+ *           preconditioning to be used (see sundials_iterative.h)
+ *
+ *  delta  tolerance on the L2 norm of the scaled, preconditioned
+ *         residual (if return value == SPBCG_SUCCESS, then
+ *         ||sb*P1_inv*(b-Ax)||_L2 <= delta)
+ *
+ *  P_data  pointer to a data structure containing preconditioner
+ *          information (passed to user-supplied function referenced
+ *          by psolve (function pointer))
+ *
+ *  sx  vector (type N_Vector) containing positive scaling factors
+ *      for x (pass sx == NULL if scaling NOT required)
+ *
+ *  sb  vector (type N_Vector) containing positive scaling factors
+ *      for b (pass sb == NULL if scaling NOT required)
+ *
+ *  atimes  user-supplied routine responsible for computing the
+ *          matrix-vector product Ax (see sundials_iterative.h)
+ *
+ *  psolve  user-supplied routine responsible for solving the
+ *          preconditioned linear system Pz = r (ignored if
+ *          pretype == PREC_NONE) (see sundials_iterative.h)
+ *
+ *  res_norm  pointer (type realtype*) to the L2 norm of the
+ *            scaled, preconditioned residual (if return value
+ *            is either SPBCG_SUCCESS or SPBCG_RES_REDUCED, then
+ *            *res_norm = ||sb*P1_inv*(b-Ax)||_L2, where x is
+ *            the computed approximate solution, sb is the diagonal
+ *            scaling matrix for the right-hand side b, and P1_inv
+ *            is the inverse of the left-preconditioner matrix)
+ *
+ *  nli  pointer (type int*) to the total number of linear
+ *       iterations performed
+ *
+ *  nps  pointer (type int*) to the total number of calls made
+ *       to the psolve routine
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SpbcgSolve(SpbcgMem mem, void *A_data, N_Vector x, N_Vector b,
+			       int pretype, realtype delta, void *P_data, N_Vector sx,
+			       N_Vector sb, ATimesFn atimes, PSolveFn psolve,
+			       realtype *res_norm, int *nli, int *nps);
+
+/* Return values for SpbcgSolve */
+
+#define SPBCG_SUCCESS            0  /* SPBCG algorithm converged          */
+#define SPBCG_RES_REDUCED        1  /* SPBCG did NOT converge, but the
+				       residual was reduced               */
+#define SPBCG_CONV_FAIL          2  /* SPBCG algorithm failed to converge */
+#define SPBCG_PSOLVE_FAIL_REC    3  /* psolve failed recoverably          */
+#define SPBCG_ATIMES_FAIL_REC    4  /* atimes failed recoverably          */
+#define SPBCG_PSET_FAIL_REC      5  /* pset faild recoverably             */
+
+#define SPBCG_MEM_NULL          -1  /* mem argument is NULL               */
+#define SPBCG_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag       */
+#define SPBCG_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably        */
+#define SPBCG_PSET_FAIL_UNREC   -4  /* pset failed unrecoverably          */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SpbcgFree
+ * -----------------------------------------------------------------
+ * SpbcgFree frees the memory allocated by a call to SpbcgMalloc.
+ * It is illegal to use the pointer mem after a call to SpbcgFree.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SpbcgFree(SpbcgMem mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Macro : SPBCG_VTEMP
+ * -----------------------------------------------------------------
+ * This macro provides access to the vector r in the
+ * memory block of the SPBCG module. The argument mem is the
+ * memory pointer returned by SpbcgMalloc, of type SpbcgMem,
+ * and the macro value is of type N_Vector.
+ *
+ * Note: Only used by IDA (r contains P_inverse F if nli_inc == 0).
+ * -----------------------------------------------------------------
+ */
+
+#define SPBCG_VTEMP(mem) (mem->r)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spfgmr.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spfgmr.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spfgmr.h	(revision 16222)
@@ -0,0 +1,284 @@
+/* -----------------------------------------------------------------
+ Programmer(s): Daniel R. Reynolds and Hilari C. Tiedeman @ SMU
+ -------------------------------------------------------------------
+ Copyright (c) 2011, Southern Methodist University.
+ All rights reserved.
+ For details, see the LICENSE file.
+ -------------------------------------------------------------------
+ This is the header file for the implementation of SPFGMR Krylov
+ iterative linear solver.  The SPFGMR algorithm is based on the
+ Scaled Preconditioned Flexible GMRES (Generalized Minimal Residual)
+ method [Y. Saad, SIAM J. Sci. Comput., 1993].
+
+ The SPFGMR algorithm solves a linear system A x = b.
+ Preconditioning is only allowed on the right.
+ Scaling is allowed on the right, and restarts are also allowed.
+ We denote the preconditioner and scaling matrices as follows:
+   P = right preconditioner
+   S1 = diagonal matrix of scale factors for P-inverse b
+   S2 = diagonal matrix of scale factors for x
+ The matrices A and P are not required explicitly; only
+ routines that provide A and P-inverse as operators are required.
+
+ In this notation, SPFGMR applies the underlying FGMRES method to
+ the equivalent transformed system
+   Abar xbar = bbar , where
+   Abar = S1 A (P-inverse) (S2-inverse),
+   bbar = S1 b , and   xbar = S2 P x .
+
+ The scaling matrix must be chosen so that the vectors S1 b and 
+ S2 P x have dimensionless components.  If preconditioning is not 
+ performed (P = I), then S2 must be a scaling for x, while S1 is a
+ scaling for b.  Similarly, if preconditioning is performed, then S1
+ must be a scaling for b, while S2 is a scaling for P x, and may 
+ also be taken as a scaling for b. 
+
+ The stopping test for the SPFGMR iterations is on the L2 norm of
+ the scaled preconditioned residual:
+      || bbar - Abar xbar ||_2  <  delta
+ with an input test constant delta.
+
+ The usage of this SPFGMR solver involves supplying two routines
+ and making three calls.  The user-supplied routines are
+    atimes (A_data, x, y) to compute y = A x, given x,
+ and
+    psolve (P_data, y, x, lr)
+                to solve P x = y for x, given y.
+ The three user calls are:
+    mem  = SpfgmrMalloc(lmax, vec_tmpl);
+           to initialize memory,
+    flag = SpfgmrSolve(mem,A_data,x,b,...,
+                       P_data,s1,s2,atimes,psolve,...);
+           to solve the system, and
+    SpfgmrFree(mem);
+           to free the memory created by SpfgmrMalloc.
+ Complete details for specifying atimes and psolve and for the
+ usage calls are given in the paragraphs below and in iterative.h.
+ -----------------------------------------------------------------*/
+
+#ifndef _SPFGMR_H
+#define _SPFGMR_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------
+ Types: SpfgmrMemRec, SpfgmrMem
+ -------------------------------------------------------------------
+ SpfgmrMem is a pointer to an SpfgmrMemRec which contains
+ the memory needed by SpfgmrSolve. The SpfgmrMalloc routine
+ returns a pointer of type SpfgmrMem which should then be passed
+ in subsequent calls to SpfgmrSolve. The SpfgmrFree routine frees
+ the memory allocated by SpfgmrMalloc.
+
+ l_max is the maximum Krylov dimension that SpfgmrSolve will be
+ permitted to use.
+
+ V is the array of Krylov basis vectors v_1, ..., v_(l_max+1),
+ stored in V[0], ..., V[l_max], where l_max is the second
+ parameter to SpfgmrMalloc. Each v_i is a vector of type
+ N_Vector.
+
+ Z is the array of preconditioned basis vectors z_1, ..., 
+ z_(l_max+1), stored in Z[0], ..., Z[l_max], where l_max is the 
+ second parameter to SpfgmrMalloc. Each z_i is a vector of type
+ N_Vector.
+
+ Hes is the (l_max+1) x l_max Hessenberg matrix. It is stored
+ row-wise so that the (i,j)th element is given by Hes[i][j].
+
+ givens is a length 2*l_max array which represents the
+ Givens rotation matrices that arise in the algorithm. The
+ Givens rotation matrices F_0, F_1, ..., F_j, where F_i is
+
+             1
+               1
+                 c_i  -s_i      <--- row i
+                 s_i   c_i
+                           1
+                             1
+
+ are represented in the givens vector as
+ givens[0]=c_0, givens[1]=s_0, givens[2]=c_1, givens[3]=s_1,
+ ..., givens[2j]=c_j, givens[2j+1]=s_j.
+
+ xcor is a vector (type N_Vector) which holds the scaled,
+ preconditioned correction to the initial guess.
+
+ yg is a length (l_max+1) array of realtype used to hold "short"
+ vectors (e.g. y and g).
+
+ vtemp is a vector (type N_Vector) used as temporary vector
+ storage during calculations.
+ -----------------------------------------------------------------*/
+typedef struct _SpfgmrMemRec {
+  int l_max;
+  N_Vector *V;
+  N_Vector *Z;
+  realtype **Hes;
+  realtype *givens;
+  N_Vector xcor;
+  realtype *yg;
+  N_Vector vtemp;
+} SpfgmrMemRec, *SpfgmrMem;
+
+/*----------------------------------------------------------------
+ Function : SpfgmrMalloc
+ -----------------------------------------------------------------
+ SpfgmrMalloc allocates the memory used by SpfgmrSolve. It
+ returns a pointer of type SpfgmrMem which the user of the
+ SPGMR package should pass to SpfgmrSolve. The parameter l_max
+ is the maximum Krylov dimension that SpfgmrSolve will be
+ permitted to use. The parameter vec_tmpl is a pointer to an
+ N_Vector used as a template to create new vectors by duplication.
+ This routine returns NULL if there is a memory request failure.
+ ---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT SpfgmrMem SpfgmrMalloc(int l_max, N_Vector vec_tmpl);
+
+/*----------------------------------------------------------------
+ Function : SpfgmrSolve
+ -----------------------------------------------------------------
+ SpfgmrSolve solves the linear system Ax = b using the SPFGMR
+ method. The return values are given by the symbolic constants
+ below. The first SpfgmrSolve parameter is a pointer to memory
+ allocated by a prior call to SpfgmrMalloc.
+
+ mem is the pointer returned by SpfgmrMalloc to the structure
+ containing the memory needed by SpfgmrSolve.
+
+ A_data is a pointer to information about the coefficient
+ matrix A. This pointer is passed to the user-supplied function
+ atimes.
+
+ x is the initial guess x_0 upon entry and the solution
+ N_Vector upon exit with return value SPFGMR_SUCCESS or
+ SPFGMR_RES_REDUCED. For all other return values, the output x
+ is undefined.
+
+ b is the right hand side N_Vector. It is undisturbed by this
+ function.
+
+ pretype is the type of preconditioning to be used. Its
+ legal possible values are enumerated in iterative.h. These
+ values are PREC_NONE, PREC_LEFT, PREC_RIGHT and PREC_BOTH; 
+ however since this solver can only precondition on the right, 
+ then right-preconditioning will be done if any of the values 
+ PREC_LEFT, PREC_RIGHT or PREC_BOTH are provided..
+
+ gstype is the type of Gram-Schmidt orthogonalization to be
+ used. Its legal values are enumerated in iterativ.h. These
+ values are MODIFIED_GS=0 and CLASSICAL_GS=1.
+
+ delta is the tolerance on the L2 norm of the scaled,
+ preconditioned residual. On return with value SPFGMR_SUCCESS,
+ this residual satisfies || s1 P1_inv (b - Ax) ||_2 <= delta.
+
+ max_restarts is the maximum number of times the algorithm is
+ allowed to restart.
+
+ maxit is the maximum number of iterations allowed within the 
+ solve.  This value must be less than or equal to the "l_max" 
+ value previously supplied to SpfgmrMalloc.  If maxit is too 
+ large, l_max will be used instead.
+
+ P_data is a pointer to preconditioner information. This
+ pointer is passed to the user-supplied function psolve.
+
+ s1 is an N_Vector of positive scale factors for b. (Not 
+ tested for positivity.)  Pass NULL if no scaling on b is 
+ required.
+
+ s2 is an N_Vector of positive scale factors for P x, where
+ P is the right preconditioner. (Not tested for positivity.)
+ Pass NULL if no scaling on P x is required.
+
+ atimes is the user-supplied function which performs the
+ operation of multiplying A by a given vector. Its description
+ is given in iterative.h.
+
+ psolve is the user-supplied function which solves a
+ preconditioner system Pz = r, where P is P1 or P2. Its full
+ description is given in iterative.h. The psolve function will
+ not be called if pretype is NONE; in that case, the user
+ should pass NULL for psolve.
+
+ res_norm is a pointer to the L2 norm of the scaled,
+ preconditioned residual. On return with value SPFGMR_SUCCESS or
+ SPFGMR_RES_REDUCED, (*res_norm) contains the value
+ || s1 (b - Ax) ||_2 for the computed solution x.
+ For all other return values, (*res_norm) is undefined. The
+ caller is responsible for allocating the memory (*res_norm)
+ to be filled in by SpfgmrSolve.
+
+ nli is a pointer to the number of linear iterations done in
+ the execution of SpfgmrSolve. The caller is responsible for
+ allocating the memory (*nli) to be filled in by SpfgmrSolve.
+
+ nps is a pointer to the number of calls made to psolve during
+ the execution of SpfgmrSolve. The caller is responsible for
+ allocating the memory (*nps) to be filled in by SpfgmrSolve.
+
+ Note: Repeated calls can be made to SpfgmrSolve with varying
+ input arguments. If, however, the problem size N or the
+ maximum Krylov dimension l_max changes, then a call to
+ SpfgmrMalloc must be made to obtain new memory for SpfgmrSolve
+ to use.
+ ---------------------------------------------------------------*/
+     
+SUNDIALS_EXPORT int SpfgmrSolve(SpfgmrMem mem, void *A_data, N_Vector x, 
+				N_Vector b, int pretype, int gstype, 
+				realtype delta, int max_restarts, 
+				int maxit, void *P_data, N_Vector s1, 
+				N_Vector s2, ATimesFn atimes, PSolveFn psolve, 
+				realtype *res_norm, int *nli, int *nps);
+
+
+/* Return values for SpfgmrSolve */
+#define SPFGMR_SUCCESS            0  /* Converged                     */
+#define SPFGMR_RES_REDUCED        1  /* Did not converge, but reduced
+                                        norm of residual              */
+#define SPFGMR_CONV_FAIL          2  /* Failed to converge            */
+#define SPFGMR_QRFACT_FAIL        3  /* QRfact found singular matrix  */
+#define SPFGMR_PSOLVE_FAIL_REC    4  /* psolve failed recoverably     */
+#define SPFGMR_ATIMES_FAIL_REC    5  /* atimes failed recoverably     */
+#define SPFGMR_PSET_FAIL_REC      6  /* pset faild recoverably        */
+
+#define SPFGMR_MEM_NULL          -1  /* mem argument is NULL          */
+#define SPFGMR_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag  */
+#define SPFGMR_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably   */
+#define SPFGMR_GS_FAIL           -4  /* Gram-Schmidt routine faiuled  */        
+#define SPFGMR_QRSOL_FAIL        -5  /* QRsol found singular R        */
+#define SPFGMR_PSET_FAIL_UNREC   -6  /* pset failed unrecoverably     */
+
+/*----------------------------------------------------------------
+ Function : SpfgmrFree
+ -----------------------------------------------------------------
+ SpfgmrMalloc frees the memory allocated by SpfgmrMalloc. It is
+ illegal to use the pointer mem after a call to SpfgmrFree.
+ ---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT void SpfgmrFree(SpfgmrMem mem);
+
+/*----------------------------------------------------------------
+ Macro: SPFGMR_VTEMP
+ -----------------------------------------------------------------
+ This macro provides access to the work vector vtemp in the
+ memory block of the SPFGMR module.  The argument mem is the
+ memory pointer returned by SpfgmrMalloc, of type SpfgmrMem,
+ and the macro value is of type N_Vector.
+ On a return from SpfgmrSolve with *nli = 0, this vector
+ contains the scaled preconditioned initial residual,
+ s1 * P1_inverse * (b - A x_0).
+ ---------------------------------------------------------------*/
+
+#define SPFGMR_VTEMP(mem) (mem->vtemp)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spgmr.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spgmr.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_spgmr.h	(revision 16222)
@@ -0,0 +1,301 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
+ *                Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the implementation of SPGMR Krylov
+ * iterative linear solver.  The SPGMR algorithm is based on the
+ * Scaled Preconditioned GMRES (Generalized Minimal Residual)
+ * method.
+ *
+ * The SPGMR algorithm solves a linear system A x = b.
+ * Preconditioning is allowed on the left, right, or both.
+ * Scaling is allowed on both sides, and restarts are also allowed.
+ * We denote the preconditioner and scaling matrices as follows:
+ *   P1 = left preconditioner
+ *   P2 = right preconditioner
+ *   S1 = diagonal matrix of scale factors for P1-inverse b
+ *   S2 = diagonal matrix of scale factors for P2 x
+ * The matrices A, P1, and P2 are not required explicitly; only
+ * routines that provide A, P1-inverse, and P2-inverse as
+ * operators are required.
+ *
+ * In this notation, SPGMR applies the underlying GMRES method to
+ * the equivalent transformed system
+ *   Abar xbar = bbar , where
+ *   Abar = S1 (P1-inverse) A (P2-inverse) (S2-inverse) ,
+ *   bbar = S1 (P1-inverse) b , and   xbar = S2 P2 x .
+ *
+ * The scaling matrices must be chosen so that vectors S1
+ * P1-inverse b and S2 P2 x have dimensionless components.
+ * If preconditioning is done on the left only (P2 = I), by a
+ * matrix P, then S2 must be a scaling for x, while S1 is a
+ * scaling for P-inverse b, and so may also be taken as a scaling
+ * for x.  Similarly, if preconditioning is done on the right only
+ * (P1 = I, P2 = P), then S1 must be a scaling for b, while S2 is
+ * a scaling for P x, and may also be taken as a scaling for b.
+ *
+ * The stopping test for the SPGMR iterations is on the L2 norm of
+ * the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  delta
+ * with an input test constant delta.
+ *
+ * The usage of this SPGMR solver involves supplying two routines
+ * and making three calls.  The user-supplied routines are
+ *    atimes (A_data, x, y) to compute y = A x, given x,
+ * and
+ *    psolve (P_data, y, x, lr)
+ *                to solve P1 x = y or P2 x = y for x, given y.
+ * The three user calls are:
+ *    mem  = SpgmrMalloc(lmax, vec_tmpl);
+ *           to initialize memory,
+ *    flag = SpgmrSolve(mem,A_data,x,b,...,
+ *                      P_data,s1,s2,atimes,psolve,...);
+ *           to solve the system, and
+ *    SpgmrFree(mem);
+ *           to free the memory created by SpgmrMalloc.
+ * Complete details for specifying atimes and psolve and for the
+ * usage calls are given below and in sundials_iterative.h.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SPGMR_H
+#define _SPGMR_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Types: SpgmrMemRec, SpgmrMem
+ * -----------------------------------------------------------------
+ * SpgmrMem is a pointer to an SpgmrMemRec which contains
+ * the memory needed by SpgmrSolve. The SpgmrMalloc routine
+ * returns a pointer of type SpgmrMem which should then be passed
+ * in subsequent calls to SpgmrSolve. The SpgmrFree routine frees
+ * the memory allocated by SpgmrMalloc.
+ *
+ * l_max is the maximum Krylov dimension that SpgmrSolve will be
+ * permitted to use.
+ *
+ * V is the array of Krylov basis vectors v_1, ..., v_(l_max+1),
+ * stored in V[0], ..., V[l_max], where l_max is the second
+ * parameter to SpgmrMalloc. Each v_i is a vector of type
+ * N_Vector.
+ *
+ * Hes is the (l_max+1) x l_max Hessenberg matrix. It is stored
+ * row-wise so that the (i,j)th element is given by Hes[i][j].
+ *
+ * givens is a length 2*l_max array which represents the
+ * Givens rotation matrices that arise in the algorithm. The
+ * Givens rotation matrices F_0, F_1, ..., F_j, where F_i is
+ *
+ *             1
+ *               1
+ *                 c_i  -s_i      <--- row i
+ *                 s_i   c_i
+ *                           1
+ *                             1
+ *
+ * are represented in the givens vector as
+ * givens[0]=c_0, givens[1]=s_0, givens[2]=c_1, givens[3]=s_1,
+ * ..., givens[2j]=c_j, givens[2j+1]=s_j.
+ *
+ * xcor is a vector (type N_Vector) which holds the scaled,
+ * preconditioned correction to the initial guess.
+ *
+ * yg is a length (l_max+1) array of realtype used to hold "short"
+ * vectors (e.g. y and g).
+ *
+ * vtemp is a vector (type N_Vector) used as temporary vector
+ * storage during calculations.
+ * -----------------------------------------------------------------
+ */
+  
+typedef struct _SpgmrMemRec {
+
+  int l_max;
+
+  N_Vector *V;
+  realtype **Hes;
+  realtype *givens;
+  N_Vector xcor;
+  realtype *yg;
+  N_Vector vtemp;
+
+} SpgmrMemRec, *SpgmrMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SpgmrMalloc
+ * -----------------------------------------------------------------
+ * SpgmrMalloc allocates the memory used by SpgmrSolve. It
+ * returns a pointer of type SpgmrMem which the user of the
+ * SPGMR package should pass to SpgmrSolve. The parameter l_max
+ * is the maximum Krylov dimension that SpgmrSolve will be
+ * permitted to use. The parameter vec_tmpl is a pointer to an
+ * N_Vector used as a template to create new vectors by duplication.
+ * This routine returns NULL if there is a memory request failure.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SpgmrMem SpgmrMalloc(int l_max, N_Vector vec_tmpl);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SpgmrSolve
+ * -----------------------------------------------------------------
+ * SpgmrSolve solves the linear system Ax = b using the SPGMR
+ * method. The return values are given by the symbolic constants
+ * below. The first SpgmrSolve parameter is a pointer to memory
+ * allocated by a prior call to SpgmrMalloc.
+ *
+ * mem is the pointer returned by SpgmrMalloc to the structure
+ * containing the memory needed by SpgmrSolve.
+ *
+ * A_data is a pointer to information about the coefficient
+ * matrix A. This pointer is passed to the user-supplied function
+ * atimes.
+ *
+ * x is the initial guess x_0 upon entry and the solution
+ * N_Vector upon exit with return value SPGMR_SUCCESS or
+ * SPGMR_RES_REDUCED. For all other return values, the output x
+ * is undefined.
+ *
+ * b is the right hand side N_Vector. It is undisturbed by this
+ * function.
+ *
+ * pretype is the type of preconditioning to be used. Its
+ * legal values are enumerated in sundials_iterative.h. These
+ * values are PREC_NONE=0, PREC_LEFT=1, PREC_RIGHT=2, and
+ * PREC_BOTH=3.
+ *
+ * gstype is the type of Gram-Schmidt orthogonalization to be
+ * used. Its legal values are enumerated in sundials_iterative.h.
+ * These values are MODIFIED_GS=0 and CLASSICAL_GS=1.
+ *
+ * delta is the tolerance on the L2 norm of the scaled,
+ * preconditioned residual. On return with value SPGMR_SUCCESS,
+ * this residual satisfies || s1 P1_inv (b - Ax) ||_2 <= delta.
+ *
+ * max_restarts is the maximum number of times the algorithm is
+ * allowed to restart.
+ *
+ * P_data is a pointer to preconditioner information. This
+ * pointer is passed to the user-supplied function psolve.
+ *
+ * s1 is an N_Vector of positive scale factors for P1-inv b, where
+ * P1 is the left preconditioner. (Not tested for positivity.)
+ * Pass NULL if no scaling on P1-inv b is required.
+ *
+ * s2 is an N_Vector of positive scale factors for P2 x, where
+ * P2 is the right preconditioner. (Not tested for positivity.)
+ * Pass NULL if no scaling on P2 x is required.
+ *
+ * atimes is the user-supplied function which performs the
+ * operation of multiplying A by a given vector. Its description
+ * is given in sundials_iterative.h.
+ *
+ * psolve is the user-supplied function which solves a
+ * preconditioner system Pz = r, where P is P1 or P2. Its full
+ * description is given in sundials_iterative.h. The psolve function
+ * will not be called if pretype is NONE; in that case, the user
+ * should pass NULL for psolve.
+ *
+ * res_norm is a pointer to the L2 norm of the scaled,
+ * preconditioned residual. On return with value SPGMR_SUCCESS or
+ * SPGMR_RES_REDUCED, (*res_norm) contains the value
+ * || s1 P1_inv (b - Ax) ||_2 for the computed solution x.
+ * For all other return values, (*res_norm) is undefined. The
+ * caller is responsible for allocating the memory (*res_norm)
+ * to be filled in by SpgmrSolve.
+ *
+ * nli is a pointer to the number of linear iterations done in
+ * the execution of SpgmrSolve. The caller is responsible for
+ * allocating the memory (*nli) to be filled in by SpgmrSolve.
+ *
+ * nps is a pointer to the number of calls made to psolve during
+ * the execution of SpgmrSolve. The caller is responsible for
+ * allocating the memory (*nps) to be filled in by SpgmrSolve.
+ *
+ * Note: Repeated calls can be made to SpgmrSolve with varying
+ * input arguments. If, however, the problem size N or the
+ * maximum Krylov dimension l_max changes, then a call to
+ * SpgmrMalloc must be made to obtain new memory for SpgmrSolve
+ * to use.
+ * -----------------------------------------------------------------
+ */                                                                
+     
+SUNDIALS_EXPORT int SpgmrSolve(SpgmrMem mem, void *A_data, N_Vector x, N_Vector b,
+			       int pretype, int gstype, realtype delta, 
+			       int max_restarts, void *P_data, N_Vector s1, 
+			       N_Vector s2, ATimesFn atimes, PSolveFn psolve, 
+			       realtype *res_norm, int *nli, int *nps);
+
+
+/* Return values for SpgmrSolve */
+
+#define SPGMR_SUCCESS            0  /* Converged                     */
+#define SPGMR_RES_REDUCED        1  /* Did not converge, but reduced
+                                       norm of residual              */
+#define SPGMR_CONV_FAIL          2  /* Failed to converge            */
+#define SPGMR_QRFACT_FAIL        3  /* QRfact found singular matrix  */
+#define SPGMR_PSOLVE_FAIL_REC    4  /* psolve failed recoverably     */
+#define SPGMR_ATIMES_FAIL_REC    5  /* atimes failed recoverably     */
+#define SPGMR_PSET_FAIL_REC      6  /* pset faild recoverably        */
+
+#define SPGMR_MEM_NULL          -1  /* mem argument is NULL          */
+#define SPGMR_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag  */
+#define SPGMR_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably   */
+#define SPGMR_GS_FAIL           -4  /* Gram-Schmidt routine faiuled  */        
+#define SPGMR_QRSOL_FAIL        -5  /* QRsol found singular R        */
+#define SPGMR_PSET_FAIL_UNREC   -6  /* pset failed unrecoverably     */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SpgmrFree
+ * -----------------------------------------------------------------
+ * SpgmrMalloc frees the memory allocated by SpgmrMalloc. It is
+ * illegal to use the pointer mem after a call to SpgmrFree.
+ * -----------------------------------------------------------------
+ */                                                                
+
+SUNDIALS_EXPORT void SpgmrFree(SpgmrMem mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Macro: SPGMR_VTEMP
+ * -----------------------------------------------------------------
+ * This macro provides access to the work vector vtemp in the
+ * memory block of the SPGMR module.  The argument mem is the
+ * memory pointer returned by SpgmrMalloc, of type SpgmrMem,
+ * and the macro value is of type N_Vector.
+ * On a return from SpgmrSolve with *nli = 0, this vector
+ * contains the scaled preconditioned initial residual,
+ * s1 * P1_inverse * (b - A x_0).
+ * -----------------------------------------------------------------
+ */
+
+#define SPGMR_VTEMP(mem) (mem->vtemp)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_sptfqmr.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_sptfqmr.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_sptfqmr.h	(revision 16222)
@@ -0,0 +1,259 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer(s): Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the implementation of the scaled
+ * preconditioned Transpose-Free Quasi-Minimal Residual (SPTFQMR)
+ * linear solver.
+ *
+ * The SPTFQMR algorithm solves a linear system of the form Ax = b.
+ * Preconditioning is allowed on the left (PREC_LEFT), right
+ * (PREC_RIGHT), or both (PREC_BOTH).  Scaling is allowed on both
+ * sides.  We denote the preconditioner and scaling matrices as
+ * follows:
+ *   P1 = left preconditioner
+ *   P2 = right preconditioner
+ *   S1 = diagonal matrix of scale factors for P1-inverse b
+ *   S2 = diagonal matrix of scale factors for P2 x
+ * The matrices A, P1, and P2 are not required explicitly; only
+ * routines that provide A, P1-inverse, and P2-inverse as operators
+ * are required.
+ *
+ * In this notation, SPTFQMR applies the underlying TFQMR method to
+ * the equivalent transformed system:
+ *   Abar xbar = bbar, where
+ *   Abar = S1 (P1-inverse) A (P2-inverse) (S2-inverse),
+ *   bbar = S1 (P1-inverse) b, and
+ *   xbar = S2 P2 x.
+ *
+ * The scaling matrices must be chosen so that vectors
+ * S1 P1-inverse b and S2 P2 x have dimensionless components.  If
+ * preconditioning is done on the left only (P2 = I), by a matrix P,
+ * then S2 must be a scaling for x, while S1 is a scaling for
+ * P-inverse b, and so may also be taken as a scaling for x.
+ * Similarly, if preconditioning is done on the right only (P1 = I,
+ * P2 = P), then S1 must be a scaling for b, while S2 is a scaling
+ * for P x, and may also be taken as a scaling for b.
+ *
+ * The stopping test for the SPTFQMR iterations is on the L2-norm of
+ * the scaled preconditioned residual:
+ *   || bbar - Abar xbar ||_2 < delta
+ * with an input test constant delta.
+ *
+ * The usage of this SPTFQMR solver involves supplying two routines
+ * and making three calls.  The user-supplied routines are:
+ *   atimes(A_data, x, y) to compute y = A x, given x,
+ * and
+ *   psolve(P_data, y, x, lr) to solve P1 x = y or P2 x = y for x,
+ *                            given y.
+ * The three user calls are:
+ *   mem  = SptfqmrMalloc(lmax, vec_tmpl);
+ *          to initialize memory
+ *   flag = SptfqmrSolve(mem, A_data, x, b, pretype, delta, P_data,
+ *                       sx, sb, atimes, psolve, res_norm, nli, nps);
+ *          to solve the system, and
+ *   SptfqmrFree(mem);
+ *          to free the memory allocated by SptfqmrMalloc().
+ * Complete details for specifying atimes() and psolve() and for the
+ * usage calls are given in the paragraphs below and in the header
+ * file sundials_iterative.h.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SPTFQMR_H
+#define _SPTFQMR_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Types: struct SptfqmrMemRec and struct *SptfqmrMem
+ * -----------------------------------------------------------------
+ * A variable declaration of type struct *SptfqmrMem denotes a pointer
+ * to a data structure of type struct SptfqmrMemRec. The SptfqmrMemRec
+ * structure contains numerous fields that must be accessed by the
+ * SPTFQMR linear solver module.
+ *
+ *  l_max  maximum Krylov subspace dimension that SptfqmrSolve will
+ *         be permitted to use
+ *
+ *  r_star  vector (type N_Vector) which holds the initial scaled,
+ *          preconditioned linear system residual
+ *
+ *  q/d/v/p/u/r  vectors (type N_Vector) used for workspace by
+ *               the SPTFQMR algorithm
+ *
+ *  vtemp1/vtemp2/vtemp3  scratch vectors (type N_Vector) used as
+ *                        temporary storage
+ * -----------------------------------------------------------------
+ */
+
+typedef struct {
+
+  int l_max;
+
+  N_Vector r_star;
+  N_Vector q;
+  N_Vector d;
+  N_Vector v;
+  N_Vector p;
+  N_Vector *r;
+  N_Vector u;
+  N_Vector vtemp1;
+  N_Vector vtemp2;
+  N_Vector vtemp3;
+
+} SptfqmrMemRec, *SptfqmrMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SptfqmrMalloc
+ * -----------------------------------------------------------------
+ * SptfqmrMalloc allocates additional memory needed by the SPTFQMR
+ * linear solver module.
+ *
+ *  l_max  maximum Krylov subspace dimension that SptfqmrSolve will
+ *         be permitted to use
+ *
+ *  vec_tmpl  implementation-specific template vector (type N_Vector)
+ *            (created using either N_VNew_Serial or N_VNew_Parallel)
+ *
+ * If successful, SptfqmrMalloc returns a non-NULL memory pointer. If
+ * an error occurs, then a NULL pointer is returned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SptfqmrMem SptfqmrMalloc(int l_max, N_Vector vec_tmpl);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SptfqmrSolve
+ * -----------------------------------------------------------------
+ * SptfqmrSolve solves the linear system Ax = b by means of a scaled
+ * preconditioned Transpose-Free Quasi-Minimal Residual (SPTFQMR)
+ * method.
+ *
+ *  mem  pointer to an internal memory block allocated during a
+ *       prior call to SptfqmrMalloc
+ *
+ *  A_data  pointer to a data structure containing information
+ *          about the coefficient matrix A (passed to user-supplied
+ *          function referenced by atimes (function pointer))
+ *
+ *  x  vector (type N_Vector) containing initial guess x_0 upon
+ *     entry, but which upon return contains an approximate solution
+ *     of the linear system Ax = b (solution only valid if return
+ *     value is either SPTFQMR_SUCCESS or SPTFQMR_RES_REDUCED)
+ *
+ *  b  vector (type N_Vector) set to the right-hand side vector b
+ *     of the linear system (undisturbed by function)
+ *
+ *  pretype  variable (type int) indicating the type of
+ *           preconditioning to be used (see sundials_iterative.h)
+ *
+ *  delta  tolerance on the L2 norm of the scaled, preconditioned
+ *         residual (if return value == SPTFQMR_SUCCESS, then
+ *         ||sb*P1_inv*(b-Ax)||_L2 <= delta)
+ *
+ *  P_data  pointer to a data structure containing preconditioner
+ *          information (passed to user-supplied function referenced
+ *          by psolve (function pointer))
+ *
+ *  sx  vector (type N_Vector) containing positive scaling factors
+ *      for x (pass sx == NULL if scaling NOT required)
+ *
+ *  sb  vector (type N_Vector) containing positive scaling factors
+ *      for b (pass sb == NULL if scaling NOT required)
+ *
+ *  atimes  user-supplied routine responsible for computing the
+ *          matrix-vector product Ax (see sundials_iterative.h)
+ *
+ *  psolve  user-supplied routine responsible for solving the
+ *          preconditioned linear system Pz = r (ignored if
+ *          pretype == PREC_NONE) (see sundials_iterative.h)
+ *
+ *  res_norm  pointer (type realtype*) to the L2 norm of the
+ *            scaled, preconditioned residual (if return value
+ *            is either SPTFQMR_SUCCESS or SPTFQMR_RES_REDUCED, then
+ *            *res_norm = ||sb*P1_inv*(b-Ax)||_L2, where x is
+ *            the computed approximate solution, sb is the diagonal
+ *            scaling matrix for the right-hand side b, and P1_inv
+ *            is the inverse of the left-preconditioner matrix)
+ *
+ *  nli  pointer (type int*) to the total number of linear
+ *       iterations performed
+ *
+ *  nps  pointer (type int*) to the total number of calls made
+ *       to the psolve routine
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SptfqmrSolve(SptfqmrMem mem, void *A_data, N_Vector x, N_Vector b,
+				 int pretype, realtype delta, void *P_data, N_Vector sx,
+				 N_Vector sb, ATimesFn atimes, PSolveFn psolve,
+				 realtype *res_norm, int *nli, int *nps);
+
+/* Return values for SptfqmrSolve */
+
+#define SPTFQMR_SUCCESS            0  /* SPTFQMR algorithm converged          */
+#define SPTFQMR_RES_REDUCED        1  /* SPTFQMR did NOT converge, but the
+				         residual was reduced                 */
+#define SPTFQMR_CONV_FAIL          2  /* SPTFQMR algorithm failed to converge */
+#define SPTFQMR_PSOLVE_FAIL_REC    3  /* psolve failed recoverably            */
+#define SPTFQMR_ATIMES_FAIL_REC    4  /* atimes failed recoverably            */
+#define SPTFQMR_PSET_FAIL_REC      5  /* pset faild recoverably               */
+
+#define SPTFQMR_MEM_NULL          -1  /* mem argument is NULL                 */
+#define SPTFQMR_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag         */
+#define SPTFQMR_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably          */
+#define SPTFQMR_PSET_FAIL_UNREC   -4  /* pset failed unrecoverably            */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SptfqmrFree
+ * -----------------------------------------------------------------
+ * SptfqmrFree frees the memory allocated by a call to SptfqmrMalloc.
+ * It is illegal to use the pointer mem after a call to SptfqmrFree.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SptfqmrFree(SptfqmrMem mem);
+
+/*
+ * -----------------------------------------------------------------
+ * Macro : SPTFQMR_VTEMP
+ * -----------------------------------------------------------------
+ * This macro provides access to the work vector vtemp1 in the
+ * memory block of the SPTFQMR module. The argument mem is the
+ * memory pointer returned by SptfqmrMalloc, of type SptfqmrMem,
+ * and the macro value is of type N_Vector.
+ *
+ * Note: Only used by IDA (vtemp1 contains P_inverse F if
+ *       nli_inc == 0).
+ * -----------------------------------------------------------------
+ */
+
+#define SPTFQMR_VTEMP(mem) (mem->vtemp1)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_types.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_types.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_types.h	(revision 16222)
@@ -0,0 +1,147 @@
+/* -----------------------------------------------------------------
+ * Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban,
+ *                Aaron Collier, and Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This header file exports three types: realtype, sunindextype and 
+ * booleantype, as well as the constants SUNTRUE and SUNFALSE.
+ *
+ * Users should include the header file sundials_types.h in every
+ * program file and use the exported name realtype instead of
+ * float, double or long double.
+ *
+ * The constants SUNDIALS_SINGLE_PRECISION, SUNDIALS_DOUBLE_PRECISION
+ * and SUNDIALS_LONG_DOUBLE_PRECISION indicate the underlying data
+ * type of realtype. 
+ * 
+ * The legal types for realtype are float, double and long double.
+ *
+ * The constants SUNDIALS_INT64_T and SUNDIALS_INT32_T indicate 
+ * the underlying data type of sunindextype -- the integer data type
+ * used for vector and matrix indices. 
+ * 
+ * Data types are set at the configuration stage.
+ *
+ * The macro RCONST gives the user a convenient way to define
+ * real-valued literal constants. To use the constant 1.0, for example,
+ * the user should write the following:
+ *
+ *   #define ONE RCONST(1.0)
+ *
+ * If realtype is defined as a double, then RCONST(1.0) expands
+ * to 1.0. If realtype is defined as a float, then RCONST(1.0)
+ * expands to 1.0F. If realtype is defined as a long double,
+ * then RCONST(1.0) expands to 1.0L. There is never a need to
+ * explicitly cast 1.0 to (realtype). The macro can be used for 
+ * literal constants only. It cannot be used for expressions. 
+ * -----------------------------------------------------------------*/
+  
+#ifndef _SUNDIALSTYPES_H
+#define _SUNDIALSTYPES_H
+
+#ifndef _SUNDIALS_CONFIG_H
+#define _SUNDIALS_CONFIG_H
+#include <sundials/sundials_config.h>
+#endif
+
+#include <float.h>
+#include <stdint.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ *------------------------------------------------------------------
+ * Type realtype
+ * Macro RCONST
+ * Constants BIG_REAL, SMALL_REAL, and UNIT_ROUNDOFF
+ *------------------------------------------------------------------
+ */
+
+#if defined(SUNDIALS_SINGLE_PRECISION)
+
+typedef float realtype;
+# define RCONST(x) x##F
+# define BIG_REAL FLT_MAX
+# define SMALL_REAL FLT_MIN
+# define UNIT_ROUNDOFF FLT_EPSILON
+
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+
+typedef double realtype;
+# define RCONST(x) x
+# define BIG_REAL DBL_MAX
+# define SMALL_REAL DBL_MIN
+# define UNIT_ROUNDOFF DBL_EPSILON
+
+#elif defined(SUNDIALS_EXTENDED_PRECISION)
+
+typedef long double realtype;
+# define RCONST(x) x##L
+# define BIG_REAL LDBL_MAX
+# define SMALL_REAL LDBL_MIN
+# define UNIT_ROUNDOFF LDBL_EPSILON
+
+#endif
+
+
+/*
+ *------------------------------------------------------------------
+ * Type : sunindextype
+ *------------------------------------------------------------------
+ * Defines integer type to be used for vector and matrix indices.
+ * User can build sundials to use 32- or 64-bit signed integers.
+ * If compiler does not support portable data types, the SUNDIALS
+ * CMake build system tries to find a type of the desired size. 
+ *------------------------------------------------------------------
+ */
+
+typedef SUNDIALS_INDEX_TYPE sunindextype;
+
+/*
+ *------------------------------------------------------------------
+ * Type : booleantype
+ *------------------------------------------------------------------
+ * Constants : SUNFALSE and SUNTRUE
+ *------------------------------------------------------------------
+ * ANSI C does not have a built-in boolean data type. Below is the
+ * definition for a new type called booleantype. The advantage of
+ * using the name booleantype (instead of int) is an increase in
+ * code readability. It also allows the programmer to make a
+ * distinction between int and boolean data. Variables of type
+ * booleantype are intended to have only the two values SUNFALSE and
+ * SUNTRUE which are defined below to be equal to 0 and 1,
+ * respectively.
+ *------------------------------------------------------------------
+ */
+
+#ifndef booleantype
+#define booleantype int
+#endif
+
+#ifndef SUNFALSE
+#define SUNFALSE 0
+#endif
+
+#ifndef SUNTRUE
+#define SUNTRUE 1
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* _SUNDIALSTYPES_H */
+
+
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_version.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_version.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sundials/sundials_version.h	(revision 16222)
@@ -0,0 +1,66 @@
+/* -----------------------------------------------------------------
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This header file is for routines to get SUNDIALS version info
+ * -----------------------------------------------------------------*/
+
+#ifndef _SUNDIALS_VERSION_H
+#define _SUNDIALS_VERSION_H
+
+#include <sundials/sundials_config.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------
+ * Function: SUNDIALSGetVersion
+ * -----------------------------------------------------------------
+ * SUNDIALSGetVersion fills a string with SUNDIALS version
+ * information using the format major.minor.patch-label
+ * 
+ * Inputs:
+ *   version = string to fill with version information
+ *   len     = length of the input string version
+ *
+ * SUNDIALSGetVersion returns 0 if successful and -1 if the input
+ * string is too short to store the SUNDIALS version.
+ * -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int SUNDIALSGetVersion(char *version, int len);
+
+
+/* -----------------------------------------------------------------
+ * Function: SUNDIALSGetVersionNumber
+ * -----------------------------------------------------------------
+ * SUNDIALSGetVersionNumber fills separate integers with the 
+ * SUNDIALS major, minor, and patch release version numbers and a
+ * fills a string with the release label.
+ * 
+ * Inputs:
+ *   major = integer for major version number
+ *   minor = integer for minor version number
+ *   patch = integer for patch version number
+ *   label = string for version label
+ *   len   = length of the input string label
+ *
+ * SUNDIALSGetVersionNumber returns 0 if successful and -1 if the
+ * input string is too short to store the SUNDIALS version.
+ * -----------------------------------------------------------------*/
+SUNDIALS_EXPORT int SUNDIALSGetVersionNumber(int *major, int *minor, int *patch, 
+                                             char *label, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_band.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_band.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_band.h	(revision 16222)
@@ -0,0 +1,105 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the band implementation of the 
+ * SUNLINSOL module.
+ * 
+ * Part I contains declarations specific to the band implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor 
+ * SUNBandLinearSolver as well as implementation-specific prototypes 
+ * for various useful solver operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_BAND_H
+#define _SUNLINSOL_BAND_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_band.h>
+#include <sunmatrix/sunmatrix_band.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: Band implementation of SUNLinearSolver
+ *
+ * The band implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *     N -- size of the linear system
+ *     pivots -- index array for partial pivoting in LU factorization
+ *     last_flag -- last error return flag from internal setup/solve
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNLinearSolverContent_Band {
+  sunindextype  N;
+  sunindextype *pivots;
+  long int last_flag;
+};
+
+typedef struct _SUNLinearSolverContent_Band *SUNLinearSolverContent_Band;
+
+  
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by sunlinsol_band
+ * 
+ * CONSTRUCTOR:
+ *    SUNBandLinearSolver creates and allocates memory for a banded
+ *    matrix solver
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNBandLinearSolver(N_Vector y,
+                                                    SUNMatrix A);
+
+/*
+ * -----------------------------------------------------------------
+ * band implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_Band(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_Band(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetup_Band(SUNLinearSolver S, SUNMatrix A);
+SUNDIALS_EXPORT int SUNLinSolSolve_Band(SUNLinearSolver S, SUNMatrix A,
+                                        N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_Band(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_Band(SUNLinearSolver S,
+                                        long int *lenrwLS,
+                                        long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_Band(SUNLinearSolver S);
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_dense.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_dense.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_dense.h	(revision 16222)
@@ -0,0 +1,111 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the dense implementation of the 
+ * SUNLINSOL module.
+ * 
+ * Part I contains declarations specific to the dense implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor 
+ * SUNDenseLinearSolver as well as implementation-specific 
+ * prototypes for various useful matrix operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype' and 'indextype'.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_DENSE_H
+#define _SUNLINSOL_DENSE_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_dense.h>
+#include <sunmatrix/sunmatrix_dense.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: Dense implementation of SUNLinearSolver
+ *
+ * The dense implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *       N -- size of the linear system
+ *	 pivots -- index array for partial pivoting in LU factorization
+ *       last_flag -- last error return flag from internal setup/solve
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNLinearSolverContent_Dense {
+  sunindextype N;
+  sunindextype *pivots;
+  long int last_flag;
+};
+
+typedef struct _SUNLinearSolverContent_Dense *SUNLinearSolverContent_Dense;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by sunlinsol_dense
+ * 
+ * CONSTRUCTORS:
+ *    SUNDenseLinearSolver creates and allocates memory for a 
+ * 	 dense matrix solver
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNDenseLinearSolver(N_Vector y,
+                                                     SUNMatrix A);
+
+/*
+ * -----------------------------------------------------------------
+ * dense implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_Dense(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_Dense(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetup_Dense(SUNLinearSolver S, SUNMatrix A);
+SUNDIALS_EXPORT int SUNLinSolSolve_Dense(SUNLinearSolver S, SUNMatrix A,
+                                         N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_Dense(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_Dense(SUNLinearSolver S,
+                                         long int *lenrwLS,
+                                         long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_Dense(SUNLinearSolver S);
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_pcg.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_pcg.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_pcg.h	(revision 16222)
@@ -0,0 +1,218 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the PCG implementation of the 
+ * SUNLINSOL module.  The PCG algorithm is based on the
+ * Preconditioned Conjugate Gradient.
+ *
+ * The PCG algorithm solves a linear system A x = b where 
+ * A is a symmetric, real-valued matrix, i.e. A = A' (Matlab 
+ * notation for the transpose of A).  Preconditioning is allowed, 
+ * and is applied in a symmetric fashion on both the right and left.  
+ * Scaling is also allowed and is applied symmetrically.  We denote
+ * the preconditioner and scaling matrices as follows:
+ *   P = preconditioner (assumed symmetric)
+ *   S = diagonal matrix of scale factors 
+ * The matrices A and P are not required explicitly; only routines 
+ * that provide A and P-inverse as operators are required.  The 
+ * diagonal of the matrix S is held in a single N_Vector, supplied
+ * by the user of this module.
+ *
+ * In this notation, PCG applies the underlying algorithm to
+ * the equivalent transformed system
+ *   Abar xbar = bbar , where
+ *   Abar = S (P-inverse) A (P-inverse) S ,
+ *   bbar = S (P-inverse) b , and   xbar = (S-inverse) P x .
+ *
+ * The scaling matrix must be chosen so that the vectors
+ * (S P-inverse b) and (S-inverse P x) have dimensionless 
+ * components.
+ *
+ * The stopping test for the PCG iterations is on the L2 norm of
+ * the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  delta
+ *  <=>
+ *      || S (P-inverse) b - S (P-inverse) A x ||_2  <  delta
+ *  <=>
+ *      || P-inverse b - (P-inverse) A x ||_S  <  delta
+ * where || v ||_S =  sqrt(v' S' S v) with an input test constant 
+ * delta.
+ *
+ * The usage of this PCG solver involves supplying up to three
+ * routines and making a variety of calls.  The user-supplied 
+ * routines are
+ *    atimes (A_data, x, y) to compute y = A x, given x,
+ *    psolve (P_data, y, x, lr) to solve P1 x = y or P2 x = y for 
+ *           x, given y,
+ *    psetup (P_data) to perform any 'setup' operations in 
+ *           preparation for calling psolve.
+ * The user calls are:
+ *    SUNLinearSolver LS = SUNPCG(y, pretype, maxl);
+ *           to create the linear solver structure,
+ *    flag = SUNLinSolSetATimes(LS, A_data, atimes);
+ *           to set the matrix-vector product setup/apply routines,
+ *    flag = SUNLinSolSetPreconditioner(LS, P_data, psetup, psolve);
+ *           to *optionally* set the preconditioner setup/apply routines,
+ *    flag = SUNLinSolSetScalingVectors(LS, s, NULL);
+ *           to *optionally* set the diagonal of the scaling matrix 
+ *           (for PCG, only the first of the two scaling vectors is used)
+ *    flag = SUNLinSolInitialize(LS);
+ *           to perform internal solver memory allocations,
+ *    flag = SUNLinSolSetup(LS, NULL);
+ *           to call the psetup routine (if non-NULL);
+ *    flag = SUNLinSolSolve(LS, NULL, x, b, w, tol);
+ *           to solve the linear system to the tolerance 'tol'
+ *    long int nli = SUNLinSolNumIters(LS);
+ *           to *optionally* retrieve the number of linear iterations 
+ *           performed by the solver,
+ *    long int lastflag = SUNLinSolLastFlag(LS);
+ *           to *optionally* retrieve the last internal solver error flag,
+ *    realtype resnorm = SUNLinSolResNorm(LS);
+ *           to *optionally* retrieve the final linear residual norm,
+ *    flag = SUNLinSolFree(LS);
+ *           to free the solver memory.
+ * Complete details for specifying atimes, psetup and psolve 
+ * and for the usage calls are given below.
+ *
+ * -----------------------------------------------------------------
+ * 
+ * Part I contains declarations specific to the PCG implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor SUNPCG as well
+ * as implementation-specific prototypes for various useful solver
+ * operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_PCG_H
+#define _SUNLINSOL_PCG_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_pcg.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Default PCG solver parameters */
+#define SUNPCG_MAXL_DEFAULT    5
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: PCG implementation of SUNLinearSolver
+ *
+ * The PCG implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *     maxl -- number of PCG iterations to use
+ *     pretype -- flag for use of preconditioning
+ *     numiters -- number of iterations from most-recent solve
+ *     resnorm -- final linear residual norm from most-recent solve
+ *     last_flag -- last error return flag from internal setup/solve
+ *     ATimes -- function pointer to ATimes routine
+ *     ATData -- pointer to structure for ATimes
+ *     Psetup -- function pointer to preconditioner setup routine
+ *     Psolve -- function pointer to preconditioner solve routine
+ *     PData -- pointer to structure for Psetup/Psolve
+ *     s -- vector (type N_Vector) which holds the diagonal of the 
+ *         scaling matrix S
+ *     r -- vector (type N_Vector) which holds the preconditioned 
+ *         linear system residual
+ *     p, z and Ap -- vectors (type N_Vector) used for workspace by
+ *         the PCG algorithm
+ * -----------------------------------------------------------------
+ */
+ 
+struct _SUNLinearSolverContent_PCG {
+  int maxl;
+  int pretype;
+  int numiters;
+  realtype resnorm;
+  long int last_flag;
+
+  ATimesFn ATimes;
+  void* ATData;
+  PSetupFn Psetup;
+  PSolveFn Psolve;
+  void* PData;
+
+  N_Vector s;
+  N_Vector r;
+  N_Vector p;
+  N_Vector z;
+  N_Vector Ap;
+};
+
+typedef struct _SUNLinearSolverContent_PCG *SUNLinearSolverContent_PCG;
+
+  
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by sunlinsol_pcg
+ * 
+ * CONSTRUCTOR:
+ *    SUNPCG creates and allocates memory for a PCG solver
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNPCG(N_Vector y, int pretype, int maxl);
+SUNDIALS_EXPORT int SUNPCGSetPrecType(SUNLinearSolver S, int pretype);
+SUNDIALS_EXPORT int SUNPCGSetMaxl(SUNLinearSolver S, int maxl);
+
+/*
+ * -----------------------------------------------------------------
+ * PCG implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_PCG(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_PCG(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetATimes_PCG(SUNLinearSolver S, void* A_data,
+                                           ATimesFn ATimes);
+SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_PCG(SUNLinearSolver S,
+                                                   void* P_data,
+                                                   PSetupFn Pset,
+                                                   PSolveFn Psol);
+SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_PCG(SUNLinearSolver S,
+                                                   N_Vector s,
+                                                   N_Vector nul);
+SUNDIALS_EXPORT int SUNLinSolSetup_PCG(SUNLinearSolver S, SUNMatrix nul);
+SUNDIALS_EXPORT int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNMatrix nul,
+                                       N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT int SUNLinSolNumIters_PCG(SUNLinearSolver S);
+SUNDIALS_EXPORT realtype SUNLinSolResNorm_PCG(SUNLinearSolver S);
+SUNDIALS_EXPORT N_Vector SUNLinSolResid_PCG(SUNLinearSolver S);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_PCG(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_PCG(SUNLinearSolver S, 
+                                       long int *lenrwLS, 
+                                       long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_PCG(SUNLinearSolver S);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spbcgs.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spbcgs.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spbcgs.h	(revision 16222)
@@ -0,0 +1,234 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ * Based on code sundials_spbcgs.h by: Peter Brown and 
+ *     Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the SPBCGS implementation of the 
+ * SUNLINSOL module.  The SPBCGS algorithm is based on the
+ * Scaled Preconditioned Bi-CG-Stabilized method.
+ *
+ * The SPBCGS algorithm solves a linear system A x = b.
+ * Preconditioning is allowed on the left, right, or both.
+ * Scaling is allowed on both sides.  We denote the preconditioner 
+ * and scaling matrices as follows:
+ *   P1 = left preconditioner
+ *   P2 = right preconditioner
+ *   S1 = diagonal matrix of scale factors for P1-inverse b
+ *   S2 = diagonal matrix of scale factors for P2 x
+ * The matrices A, P1, and P2 are not required explicitly; only
+ * routines that provide A, P1-inverse, and P2-inverse as
+ * operators are required.
+ *
+ * In this notation, SPBCGS applies the underlying GMRES method to
+ * the equivalent transformed system
+ *   Abar xbar = bbar , where
+ *   Abar = S1 (P1-inverse) A (P2-inverse) (S2-inverse) ,
+ *   bbar = S1 (P1-inverse) b , and   xbar = S2 P2 x .
+ *
+ * The scaling matrices must be chosen so that vectors S1
+ * P1-inverse b and S2 P2 x have dimensionless components.
+ * If preconditioning is done on the left only (P2 = I), by a
+ * matrix P, then S2 must be a scaling for x, while S1 is a
+ * scaling for P-inverse b, and so may also be taken as a scaling
+ * for x.  Similarly, if preconditioning is done on the right only
+ * (P1 = I, P2 = P), then S1 must be a scaling for b, while S2 is
+ * a scaling for P x, and may also be taken as a scaling for b.
+ *
+ * The stopping test for the SPBCGS iterations is on the L2 norm of
+ * the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  delta
+ * with an input test constant delta.
+ *
+ * The usage of this SPBCGS solver involves supplying up to three
+ * routines and making a variety of calls.  The user-supplied 
+ * routines are
+ *    atimes (A_data, x, y) to compute y = A x, given x,
+ *    psolve (P_data, y, x, lr) to solve P1 x = y or P2 x = y for 
+ *           x, given y,
+ *    psetup (P_data) to perform any 'setup' operations in 
+ *           preparation for calling psolve.
+ * The user calls are:
+ *    SUNLinearSolver LS = SUNSPBCGS(y, pretype, maxl);
+ *           to create the linear solver structure,
+ *    flag = SUNLinSolSetATimes(LS, A_data, atimes);
+ *           to set the matrix-vector product setup/apply routines,
+ *    flag = SUNLinSolSetPreconditioner(LS, P_data, psetup, psolve);
+ *           to *optionally* set the preconditioner setup/apply routines,
+ *    flag = SUNLinSolSetScalingVectors(LS, s1, s2);
+ *           to *optionally* set the diagonals of the scaling matrices.
+ *    flag = SUNLinSolInitialize(LS);
+ *           to perform internal solver memory allocations,
+ *    flag = SUNLinSolSetup(LS, NULL);
+ *           to call the psetup routine (if non-NULL);
+ *    flag = SUNLinSolSolve(LS, NULL, x, b, w, tol);
+ *           to solve the linear system to the tolerance 'tol'
+ *    long int nli = SUNLinSolNumIters(LS);
+ *           to *optionally* retrieve the number of linear iterations 
+ *           performed by the solver,
+ *    long int lastflag = SUNLinSolLastFlag(LS);
+ *           to *optionally* retrieve the last internal solver error flag,
+ *    realtype resnorm = SUNLinSolResNorm(LS);
+ *           to *optionally* retrieve the final linear residual norm,
+ *    flag = SUNLinSolFree(LS);
+ *           to free the solver memory.
+ * Complete details for specifying atimes, psetup and psolve 
+ * and for the usage calls are given below.
+ *
+ * -----------------------------------------------------------------
+ * 
+ * Part I contains declarations specific to the SPBCGS implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor 
+ * SUNSPBCGS as well as implementation-specific prototypes 
+ * for various useful solver operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_SPBCGS_H
+#define _SUNLINSOL_SPBCGS_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_spbcgs.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Default SPBCGS solver parameters */
+#define SUNSPBCGS_MAXL_DEFAULT 5
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: SPBCGS implementation of SUNLinearSolver
+ *
+ * The SPBCGS implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *     maxl -- number of BiCGStab iterations to allow
+ *     pretype -- flag for type of preconditioning to employ
+ *     numiters -- number of iterations from most-recent solve
+ *     resnorm -- final linear residual norm from most-recent solve
+ *     last_flag -- last error return flag from internal setup/solve
+ *     ATimes -- function pointer to ATimes routine
+ *     ATData -- pointer to structure for ATimes
+ *     Psetup -- function pointer to preconditioner setup routine
+ *     Psolve -- function pointer to preconditioner solve routine
+ *     PData -- pointer to structure for Psetup/Psolve
+ *     s1,s2 -- vectors (type N_Vector) which holds the diagonals
+ *         of the scaling matrices S1 and S2, respectively
+ *     r -- a vector (type N_Vector) which holds the scaled,
+ *         preconditioned linear system residual
+ *     r_star -- a vector (type N_Vector) which holds the initial 
+ *         scaled, preconditioned linear system residual
+ *     p, q, u and Ap -- vectors (type N_Vector) used for workspace
+ *         by the SPBCG algorithm.
+ *     vtemp -- a vector (type N_Vector) used as temporary vector
+ *         storage during calculations.
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNLinearSolverContent_SPBCGS {
+  int maxl;
+  int pretype;
+  int numiters;
+  realtype resnorm;
+  long int last_flag;
+
+  ATimesFn ATimes;
+  void* ATData;
+  PSetupFn Psetup;
+  PSolveFn Psolve;
+  void* PData;
+
+  N_Vector s1;
+  N_Vector s2;
+  N_Vector r;
+  N_Vector r_star;
+  N_Vector p;
+  N_Vector q;
+  N_Vector u;
+  N_Vector Ap;
+  N_Vector vtemp;
+};
+
+typedef struct _SUNLinearSolverContent_SPBCGS *SUNLinearSolverContent_SPBCGS;
+
+  
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by sunlinsol_spbcgs
+ * 
+ * CONSTRUCTOR:
+ *    SUNSPBCGS creates and allocates memory for a SPBCGS solver
+ *
+ * "SET" ROUTINES:
+ *    SUNSPBCGSSetPrecType updates the type of preconditioning to 
+ *       use.  Supported values are PREC_NONE, PREC_LEFT, PREC_RIGHT 
+ *       and PREC_BOTH.
+ *    SUNSPBCGSSetMaxl updates the maximum number of iterations to 
+ *       allow in the solver.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNSPBCGS(N_Vector y, int pretype, int maxl);
+SUNDIALS_EXPORT int SUNSPBCGSSetPrecType(SUNLinearSolver S, int pretype);
+SUNDIALS_EXPORT int SUNSPBCGSSetMaxl(SUNLinearSolver S, int maxl);
+
+/*
+ * -----------------------------------------------------------------
+ * SPBCGS implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPBCGS(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_SPBCGS(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetATimes_SPBCGS(SUNLinearSolver S, void* A_data,
+                                              ATimesFn ATimes);
+SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPBCGS(SUNLinearSolver S,
+                                                      void* P_data,
+                                                      PSetupFn Pset,
+                                                      PSolveFn Psol);
+SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPBCGS(SUNLinearSolver S,
+                                                      N_Vector s1,
+                                                      N_Vector s2);
+SUNDIALS_EXPORT int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNMatrix A);
+SUNDIALS_EXPORT int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNMatrix A,
+                                          N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT int SUNLinSolNumIters_SPBCGS(SUNLinearSolver S);
+SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPBCGS(SUNLinearSolver S);
+SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPBCGS(SUNLinearSolver S);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_SPBCGS(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_SPBCGS(SUNLinearSolver S, 
+                                          long int *lenrwLS, 
+                                          long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_SPBCGS(SUNLinearSolver S);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spfgmr.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spfgmr.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spfgmr.h	(revision 16222)
@@ -0,0 +1,253 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ * Based on code sundials_spfgmr.h by: Daniel R. Reynolds and 
+ *    Hilari C. Tiedeman @ SMU
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the SPFGMR implementation of the 
+ * SUNLINSOL module.  The SPFGMR algorithm is based on the
+ * Scaled Preconditioned FGMRES (Flexible Generalized Minimal 
+ * Residual) method [Y. Saad, SIAM J. Sci. Comput., 1993].
+ *
+ * The SPFGMR algorithm solves a linear system A x = b.
+ * Preconditioning is only allowed on the right.  Scaling is allowed 
+ * on both sides, and restarts are also allowed. We denote the
+ * preconditioner and scaling matrices as follows:
+ *   P = right preconditioner
+ *   S1 = diagonal matrix of scale factors for P-inverse b
+ *   S2 = diagonal matrix of scale factors for x
+ * The matrices A and P are not required explicitly; only routines 
+ * that provide A and P-inverse as operators are required.
+ *
+ * In this notation, SPFGMR applies the underlying GMRES method to
+ * the equivalent transformed system
+ *   Abar xbar = bbar , where
+ *   Abar = S1 A (P-inverse) (S2-inverse) ,
+ *   bbar = S1 b , and   xbar = S2 P x .
+ *
+ * The scaling matrices must be chosen so that vectors S1 b and 
+ * S2 P x have dimensionless components. If preconditioning is not 
+ * performed (P = I), then S2 must be a scaling for x, while S1 is a
+ * scaling for b.  Similarly, if preconditioning is performed, then
+ * S1 must be a scaling for b, while S2 is a scaling for P x, and may
+ * also be taken as a scaling for b.
+ *
+ * The stopping test for the SPFGMR iterations is on the L2 norm of
+ * the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  delta
+ * with an input test constant delta.
+ *
+ * The usage of this SPFGMR solver involves supplying up to three 
+ * routines and making a variety of calls.  The user-supplied routines are
+ *    atimes (A_data, x, y) to compute y = A x, given x,
+ *    psolve (P_data, y, x, lr) to solve P1 x = y or P2 x = y for 
+ *           x, given y,
+ *    psetup (P_data) to perform any 'setup' operations in 
+ *           preparation for calling psolve.
+ * The three user calls are:
+ *    SUNLinearSolver LS = SUNSPFGMR(y, pretype, maxl);
+ *           to create the linear solver structure,
+ *    flag = SUNLinSolSetATimes(LS, A_data, atimes);
+ *           to set the matrix-vector product setup/apply routines,
+ *    flag = SUNLinSolSetPreconditioner(LS, P_data, psetup, psolve);
+ *           to *optionally* set the preconditioner setup/apply routines,
+ *    flag = SUNLinSolInitialize(LS);
+ *           to perform internal solver memory allocations,
+ *    flag = SUNLinSolSetup(LS, NULL);
+ *           to call the psetup routine (if non-NULL);
+ *    flag = SUNLinSolSolve(LS, NULL, x, b, w, tol);
+ *           to solve the linear system to the tolerance 'tol'
+ *    long int nli = SUNLinSolNumIters(LS);
+ *           to *optionally* retrieve the number of linear iterations 
+ *           performed by the solver,
+ *    long int lastflag = SUNLinSolLastFlag(LS);
+ *           to *optionally* retrieve the last internal solver error flag,
+ *    flag = SUNLinSolFree(LS);
+ *           to free the solver memory.
+ * Complete details for specifying atimes, psetup and psolve 
+ * and for the usage calls are given below.
+ *
+ * -----------------------------------------------------------------
+ * 
+ * Part I contains declarations specific to the SPFGMR implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor 
+ * SUNSPFGMR as well as implementation-specific prototypes 
+ * for various useful solver operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_SPFGMR_H
+#define _SUNLINSOL_SPFGMR_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_spfgmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Default SPFGMR solver parameters */
+#define SUNSPFGMR_MAXL_DEFAULT    5
+#define SUNSPFGMR_MAXRS_DEFAULT   0
+#define SUNSPFGMR_GSTYPE_DEFAULT  MODIFIED_GS
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: SPFGMR implementation of SUNLinearSolver
+ *
+ * The SPFGMR implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *     maxl -- number of GMRES basis vectors to use
+ *     pretype -- flag for type of preconditioning to employ
+ *     gstype -- flag for type of Gram-Schmidt orthogonalization
+ *     max_restarts -- number of GMRES restarts to allow
+ *     last_flag -- last error return flag from internal setup/solve
+ *     ATimes -- function pointer to ATimes routine
+ *     ATData -- pointer to structure for ATimes
+ *     Psetup -- function pointer to preconditioner setup routine
+ *     Psolve -- function pointer to preconditioner solve routine
+ *     PData -- pointer to structure for Psetup/Psolve
+ *     V -- the array of Krylov basis vectors v_1, ..., v_(maxl+1),
+ *         stored in V[0], ..., V[l_max]. Each v_i is a vector of 
+ *         type N_Vector.
+ *     Z -- the array of preconditioned basis vectors z_1, ..., 
+ *         z_(maxl+1), stored in Z[0], ..., Z[l_max]. Each z_i 
+ *         is a vector of type N_Vector.
+ *     Hes -- the (maxl+1) x maxl Hessenberg matrix. It is stored
+ *         row-wise so that the (i,j)th element is given by Hes[i][j].
+ *     givens -- a length 2*max array which represents the Givens 
+ *         rotation matrices that arise in the algorithm. The Givens 
+ *         rotation matrices F_0, F_1, ..., F_j, where F_i is
+ *
+ *             1
+ *               1
+ *                 c_i  -s_i      <--- row i
+ *                 s_i   c_i
+ *                           1
+ *                             1
+ *
+ *         are represented in the givens vector as
+ *         givens[0]=c_0, givens[1]=s_0, givens[2]=c_1, givens[3]=s_1,
+ *         ..., givens[2j]=c_j, givens[2j+1]=s_j.
+ *     xcor -- a vector (type N_Vector) which holds the scaled,
+ *         preconditioned correction to the initial guess
+ *     yg -- a length (maxl+1) array of realtype used to hold "short"
+ *         vectors (e.g. y and g).
+ *     vtemp -- a vector (type N_Vector) used as temporary vector
+ *         storage during calculations.
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNLinearSolverContent_SPFGMR {
+  int maxl;
+  int pretype;
+  int gstype;
+  int max_restarts;
+  int numiters;
+  realtype resnorm;
+  long int last_flag;
+
+  ATimesFn ATimes;
+  void* ATData;
+  PSetupFn Psetup;
+  PSolveFn Psolve;
+  void* PData;
+
+  N_Vector s1;
+  N_Vector s2;
+  N_Vector *V;
+  N_Vector *Z;
+  realtype **Hes;
+  realtype *givens;
+  N_Vector xcor;
+  realtype *yg;
+  N_Vector vtemp;
+};
+
+typedef struct _SUNLinearSolverContent_SPFGMR *SUNLinearSolverContent_SPFGMR;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by sunlinsol_spfgmr
+ * 
+ * CONSTRUCTOR:
+ *    SUNSPFGMR creates and allocates memory for a SPFGMR solver
+ *
+ * "SET" ROUTINES:
+ *    SUNSPFGMRSetPrecType updates whether to use preconditioning.  
+ *       Since only right preconditioning is supported, the inputs 
+ *       PREC_LEFT, PREC_RIGHT and PREC_BOTH all result in 
+ *       PREC_RIGHT.  All other input values default to PREC_NONE.
+ *    SUNSPFGMRSetGSType sets the type of Gram-Schmidt 
+ *       orthogonalization to use.  Supported values are MODIFIED_GS 
+ *       and CLASSICAL_GS.
+ *    SUNSPFGMRSetMaxRestarts sets the number of FGMRES restarts to 
+ *       allow.  A negative input will result in the default of 0.
+ *
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNSPFGMR(N_Vector y, int pretype, int maxl);
+SUNDIALS_EXPORT int SUNSPFGMRSetPrecType(SUNLinearSolver S, int pretype);
+SUNDIALS_EXPORT int SUNSPFGMRSetGSType(SUNLinearSolver S, int gstype);
+SUNDIALS_EXPORT int SUNSPFGMRSetMaxRestarts(SUNLinearSolver S, int maxrs);
+
+/*
+ * -----------------------------------------------------------------
+ * SPFGMR implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPFGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_SPFGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetATimes_SPFGMR(SUNLinearSolver S, void* A_data,
+                                              ATimesFn ATimes);
+SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPFGMR(SUNLinearSolver S,
+                                                      void* P_data,
+                                                      PSetupFn Pset,
+                                                      PSolveFn Psol);
+SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver S,
+                                                      N_Vector s1,
+                                                      N_Vector s2);
+SUNDIALS_EXPORT int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNMatrix A);
+SUNDIALS_EXPORT int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNMatrix A,
+                                          N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT int SUNLinSolNumIters_SPFGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPFGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPFGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_SPFGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_SPFGMR(SUNLinearSolver S, 
+                                          long int *lenrwLS, 
+                                          long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_SPFGMR(SUNLinearSolver S);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spgmr.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spgmr.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_spgmr.h	(revision 16222)
@@ -0,0 +1,254 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ * Based on code sundials_spgmr.h by: Scott D. Cohen, 
+ *      Alan C. Hindmarsh and Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the SPGMR implementation of the 
+ * SUNLINSOL module.  The SPGMR algorithm is based on the
+ * Scaled Preconditioned GMRES (Generalized Minimal Residual)
+ * method.
+ *
+ * The SPGMR algorithm solves a linear system A x = b.
+ * Preconditioning is allowed on the left, right, or both.
+ * Scaling is allowed on both sides, and restarts are also allowed.
+ * We denote the preconditioner and scaling matrices as follows:
+ *   P1 = left preconditioner
+ *   P2 = right preconditioner
+ *   S1 = diagonal matrix of scale factors for P1-inverse b
+ *   S2 = diagonal matrix of scale factors for P2 x
+ * The matrices A, P1, and P2 are not required explicitly; only
+ * routines that provide A, P1-inverse, and P2-inverse as
+ * operators are required.
+ *
+ * In this notation, SPGMR applies the underlying GMRES method to
+ * the equivalent transformed system
+ *   Abar xbar = bbar , where
+ *   Abar = S1 (P1-inverse) A (P2-inverse) (S2-inverse) ,
+ *   bbar = S1 (P1-inverse) b , and   xbar = S2 P2 x .
+ *
+ * The scaling matrices must be chosen so that vectors S1
+ * P1-inverse b and S2 P2 x have dimensionless components.
+ * If preconditioning is done on the left only (P2 = I), by a
+ * matrix P, then S2 must be a scaling for x, while S1 is a
+ * scaling for P-inverse b, and so may also be taken as a scaling
+ * for x.  Similarly, if preconditioning is done on the right only
+ * (P1 = I, P2 = P), then S1 must be a scaling for b, while S2 is
+ * a scaling for P x, and may also be taken as a scaling for b.
+ *
+ * The stopping test for the SPGMR iterations is on the L2 norm of
+ * the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  delta
+ * with an input test constant delta.
+ *
+ * The usage of this SPGMR solver involves supplying three routines
+ * and making a variety of calls.  The user-supplied routines are
+ *    atimes (A_data, x, y) to compute y = A x, given x,
+ *    psolve (P_data, y, x, lr) to solve P1 x = y or P2 x = y for 
+ *           x, given y,
+ *    psetup (P_data) to perform any 'setup' operations in 
+ *           preparation for calling psolve.
+ * The user calls are:
+ *    SUNLinearSolver LS = SUNSPGMR(y, pretype, maxl);
+ *           to create the linear solver structure,
+ *    flag = SUNLinSolSetATimes(LS, A_data, atimes);
+ *           to set the matrix-vector product setup/apply routines,
+ *    flag = SUNLinSolSetPreconditioner(LS, P_data, psetup, psolve);
+ *           to *optionally* set the preconditioner setup/apply routines,
+ *    flag = SUNLinSolInitialize(LS);
+ *           to perform internal solver memory allocations,
+ *    flag = SUNLinSolSetup(LS, NULL);
+ *           to call the psetup routine (if non-NULL);
+ *    flag = SUNLinSolSolve(LS, NULL, x, b, w, tol);
+ *           to solve the linear system to the tolerance 'tol'
+ *    long int nli = SUNLinSolNumIters(LS);
+ *           to *optionally* retrieve the number of linear iterations 
+ *           performed by the solver,
+ *    long int lastflag = SUNLinSolLastFlag(LS);
+ *           to *optionally* retrieve the last internal solver error flag,
+ *    flag = SUNLinSolFree(LS);
+ *           to free the solver memory.
+ * Complete details for specifying atimes, psetup and psolve 
+ * and for the usage calls are given below.
+ *
+ * -----------------------------------------------------------------
+ * 
+ * Part I contains declarations specific to the SPGMR implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor 
+ * SUNSPGMR as well as implementation-specific prototypes 
+ * for various useful solver operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_SPGMR_H
+#define _SUNLINSOL_SPGMR_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_spgmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Default SPGMR solver parameters */
+#define SUNSPGMR_MAXL_DEFAULT    5
+#define SUNSPGMR_MAXRS_DEFAULT   0
+#define SUNSPGMR_GSTYPE_DEFAULT  MODIFIED_GS
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: SPGMR implementation of SUNLinearSolver
+ *
+ * The SPGMR implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *     maxl -- number of GMRES basis vectors to use
+ *     pretype -- flag for type of preconditioning to employ
+ *     gstype -- flag for type of Gram-Schmidt orthogonalization
+ *     max_restarts -- number of GMRES restarts to allow
+ *     numiters -- number of iterations from most-recent solve
+ *     resnorm -- final linear residual norm from most-recent solve
+ *     last_flag -- last error return flag from internal setup/solve
+ *     ATimes -- function pointer to ATimes routine
+ *     ATData -- pointer to structure for ATimes
+ *     Psetup -- function pointer to preconditioner setup routine
+ *     Psolve -- function pointer to preconditioner solve routine
+ *     PData -- pointer to structure for Psetup/Psolve
+ *     s1, s2 -- vector pointers for supplied scaling matrices
+ *     V -- the array of Krylov basis vectors v_1, ..., v_(maxl+1),
+ *         stored in V[0], ..., V[maxl]. Each v_i is a vector of 
+ *         type N_Vector.
+ *     Hes -- the (maxl+1) x maxl Hessenberg matrix. It is stored
+ *         row-wise so that the (i,j)th element is given by Hes[i][j].
+ *     givens -- a length 2*max array which represents the Givens 
+ *         rotation matrices that arise in the algorithm. The Givens 
+ *         rotation matrices F_0, F_1, ..., F_j, where F_i is
+ *
+ *             1
+ *               1
+ *                 c_i  -s_i      <--- row i
+ *                 s_i   c_i
+ *                           1
+ *                             1
+ *
+ *         are represented in the givens vector as
+ *         givens[0]=c_0, givens[1]=s_0, givens[2]=c_1, givens[3]=s_1,
+ *         ..., givens[2j]=c_j, givens[2j+1]=s_j.
+ *     xcor -- a vector (type N_Vector) which holds the scaled,
+ *         preconditioned correction to the initial guess
+ *     yg -- a length (maxl+1) array of realtype used to hold "short"
+ *         vectors (e.g. y and g).
+ *     vtemp -- a vector used as temporary vector storage
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNLinearSolverContent_SPGMR {
+  int maxl;
+  int pretype;
+  int gstype;
+  int max_restarts;
+  int numiters;
+  realtype resnorm;
+  long int last_flag;
+
+  ATimesFn ATimes;
+  void* ATData;
+  PSetupFn Psetup;
+  PSolveFn Psolve;
+  void* PData;
+
+  N_Vector s1;
+  N_Vector s2;
+  N_Vector *V;
+  realtype **Hes;
+  realtype *givens;
+  N_Vector xcor;
+  realtype *yg;
+  N_Vector vtemp;
+};
+
+typedef struct _SUNLinearSolverContent_SPGMR *SUNLinearSolverContent_SPGMR;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by sunlinsol_spgmr
+ * 
+ * CONSTRUCTOR:
+ *    SUNSPGMR creates and allocates memory for a SPGMR solver
+ *
+ * "SET" ROUTINES:
+ *    SUNSPGMRSetPrecType updates the type of preconditioning to 
+ *       use.  Supported values are PREC_NONE, PREC_LEFT, PREC_RIGHT 
+ *       and PREC_BOTH.
+ *    SUNSPGMRSetGSType sets the type of Gram-Schmidt 
+ *       orthogonalization to use.  Supported values are MODIFIED_GS 
+ *       and CLASSICAL_GS.
+ *    SUNSPGMRSetMaxRestarts sets the number of GMRES restarts to 
+ *       allow.  A negative input will result in the default of 0.
+ * 
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNSPGMR(N_Vector y, int pretype, int maxl);
+SUNDIALS_EXPORT int SUNSPGMRSetPrecType(SUNLinearSolver S, int pretype);
+SUNDIALS_EXPORT int SUNSPGMRSetGSType(SUNLinearSolver S, int gstype);
+SUNDIALS_EXPORT int SUNSPGMRSetMaxRestarts(SUNLinearSolver S, int maxrs);
+
+/*
+ * -----------------------------------------------------------------
+ * SPGMR implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_SPGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetATimes_SPGMR(SUNLinearSolver S, void* A_data,
+                                             ATimesFn ATimes);
+SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPGMR(SUNLinearSolver S,
+                                                     void* P_data,
+                                                     PSetupFn Pset,
+                                                     PSolveFn Psol);
+SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPGMR(SUNLinearSolver S,
+                                                     N_Vector s1,
+                                                     N_Vector s2);
+SUNDIALS_EXPORT int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNMatrix A);
+SUNDIALS_EXPORT int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNMatrix A,
+                                         N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT int SUNLinSolNumIters_SPGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_SPGMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_SPGMR(SUNLinearSolver S, 
+                                         long int *lenrwLS, 
+                                         long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_SPGMR(SUNLinearSolver S);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_sptfqmr.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_sptfqmr.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunlinsol/sunlinsol_sptfqmr.h	(revision 16222)
@@ -0,0 +1,229 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ * Based on code sundials_sptfqmr.h by: Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the SPTFQMR implementation of the 
+ * SUNLINSOL module.  The SPTFQMR algorithm is based on the
+ * Scaled Preconditioned Transpose-free Quasi-Minimum Residual method.
+ *
+ * The SPTFQMR algorithm solves a linear system A x = b.
+ * Preconditioning is allowed on the left, right, or both.
+ * Scaling is allowed on both sides.
+ * We denote the preconditioner and scaling matrices as follows:
+ *   P1 = left preconditioner
+ *   P2 = right preconditioner
+ *   S1 = diagonal matrix of scale factors for P1-inverse b
+ *   S2 = diagonal matrix of scale factors for P2 x
+ * The matrices A, P1, and P2 are not required explicitly; only
+ * routines that provide A, P1-inverse, and P2-inverse as
+ * operators are required.
+ *
+ * In this notation, SPTFQMR applies the underlying TFQMR method to
+ * the equivalent transformed system
+ *   Abar xbar = bbar , where
+ *   Abar = S1 (P1-inverse) A (P2-inverse) (S2-inverse) ,
+ *   bbar = S1 (P1-inverse) b , and   xbar = S2 P2 x .
+ *
+ * The scaling matrices must be chosen so that vectors S1
+ * P1-inverse b and S2 P2 x have dimensionless components.
+ * If preconditioning is done on the left only (P2 = I), by a
+ * matrix P, then S2 must be a scaling for x, while S1 is a
+ * scaling for P-inverse b, and so may also be taken as a scaling
+ * for x.  Similarly, if preconditioning is done on the right only
+ * (P1 = I, P2 = P), then S1 must be a scaling for b, while S2 is
+ * a scaling for P x, and may also be taken as a scaling for b.
+ *
+ * The stopping test for the SPTFQMR iterations is on the L2 norm of
+ * the scaled preconditioned residual:
+ *      || bbar - Abar xbar ||_2  <  delta
+ * with an input test constant delta.
+ *
+ * The usage of this SPTFQMR solver involves supplying up to three 
+ * routines and making a variety of calls.  The user-supplied routines are
+ *    atimes (A_data, x, y) to compute y = A x, given x,
+ *    psolve (P_data, y, x, lr) to solve P1 x = y or P2 x = y for 
+ *           x, given y,
+ *    psetup (P_data) to perform any 'setup' operations in 
+ *           preparation for calling psolve.
+ * The three user calls are:
+ *    SUNLinearSolver LS = SUNSPTFQMR(y, pretype, maxl);
+ *           to create the linear solver structure,
+ *    flag = SUNLinSolSetATimes(LS, A_data, atimes);
+ *           to set the matrix-vector product setup/apply routines,
+ *    flag = SUNLinSolSetPreconditioner(LS, P_data, psetup, psolve);
+ *           to *optionally* set the preconditioner setup/apply routines,
+ *    flag = SUNLinSolInitialize(LS);
+ *           to perform internal solver memory allocations,
+ *    flag = SUNLinSolSetup(LS, NULL);
+ *           to call the psetup routine (if non-NULL);
+ *    flag = SUNLinSolSolve(LS, NULL, x, b, w, tol);
+ *           to solve the linear system to the tolerance 'tol'
+ *    long int nli = SUNLinSolNumIters(LS);
+ *           to *optionally* retrieve the number of linear iterations 
+ *           performed by the solver,
+ *    long int lastflag = SUNLinSolLastFlag(LS);
+ *           to *optionally* retrieve the last internal solver error flag,
+ *    flag = SUNLinSolFree(LS);
+ *           to free the solver memory.
+ * Complete details for specifying atimes, psetup and psolve 
+ * and for the usage calls are given below.
+ *
+ * -----------------------------------------------------------------
+ * 
+ * Part I contains declarations specific to the SPTFQMR implementation
+ * of the supplied SUNLINSOL module.
+ * 
+ * Part II contains the prototype for the constructor 
+ * SUNSPTFQMR as well as implementation-specific prototypes 
+ * for various useful solver operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNLinearSolver structure can 
+ *     be found in the header file sundials_linearsolver.h.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNLINSOL_SPTFQMR_H
+#define _SUNLINSOL_SPTFQMR_H
+
+#include <sundials/sundials_linearsolver.h>
+#include <sundials/sundials_matrix.h>
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_sptfqmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Default SPTFQMR solver parameters */
+#define SUNSPTFQMR_MAXL_DEFAULT    5
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: SPTFQMR implementation of SUNLinearSolver
+ *
+ * The SPTFQMR implementation of the SUNLinearSolver 'content' 
+ * structure contains:
+ *     maxl -- number of BiCGStab iterations to allow
+ *     pretype -- flag for type of preconditioning to employ
+ *     numiters -- number of iterations from most-recent solve
+ *     resnorm -- final linear residual norm from most-recent solve
+ *     last_flag -- last error return flag from internal setup/solve
+ *     ATimes -- function pointer to ATimes routine
+ *     ATData -- pointer to structure for ATimes
+ *     Psetup -- function pointer to preconditioner setup routine
+ *     Psolve -- function pointer to preconditioner solve routine
+ *     PData -- pointer to structure for Psetup/Psolve
+ *     s1, s2 -- vector pointers for supplied scaling matrices
+ *     r_star -- a vector (type N_Vector) which holds the initial 
+ *         scaled, preconditioned linear system residual
+ *     q, d, v, p and u -- vectors (type N_Vector) used for 
+ *         workspace by the SPTFQMR algorithm
+ *     r -- array of vectors (type N_Vector) used for workspace 
+ *         within the SPTFQMR algorithm
+ *     vtemp1/vtemp2/vtemp3 -- scratch vectors (type N_Vector) used
+ *         as temporary vector storage during calculations.
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNLinearSolverContent_SPTFQMR {
+  int maxl;
+  int pretype;
+  int numiters;
+  realtype resnorm;
+  long int last_flag;
+
+  ATimesFn ATimes;
+  void* ATData;
+  PSetupFn Psetup;
+  PSolveFn Psolve;
+  void* PData;
+
+  N_Vector s1;
+  N_Vector s2;
+  N_Vector r_star;
+  N_Vector q;
+  N_Vector d;
+  N_Vector v;
+  N_Vector p;
+  N_Vector *r;
+  N_Vector u;
+  N_Vector vtemp1;
+  N_Vector vtemp2;
+  N_Vector vtemp3;
+};
+
+typedef struct _SUNLinearSolverContent_SPTFQMR *SUNLinearSolverContent_SPTFQMR;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by sunlinsol_sptfqmr
+ * 
+ * CONSTRUCTOR:
+ *    SUNSPTFQMR creates and allocates memory for a SPTFQMR solver
+ *
+ * "SET" ROUTINES:
+ *    SUNSPTFQMRSSetPrecType updates the type of preconditioning to 
+ *       use.  Supported values are PREC_NONE, PREC_LEFT, PREC_RIGHT 
+ *       and PREC_BOTH.
+ *    SUNSPTFQMRSetMaxl updates the maximum number of iterations to 
+ *       allow in the solver.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver SUNSPTFQMR(N_Vector y, int pretype, int maxl);
+SUNDIALS_EXPORT int SUNSPTFQMRSetPrecType(SUNLinearSolver S, int pretype);
+SUNDIALS_EXPORT int SUNSPTFQMRSetMaxl(SUNLinearSolver S, int maxl);
+
+/*
+ * -----------------------------------------------------------------
+ * SPTFQMR implementations of various useful linear solver operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPTFQMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolInitialize_SPTFQMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSetATimes_SPTFQMR(SUNLinearSolver S, void* A_data,
+                                               ATimesFn ATimes);
+SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPTFQMR(SUNLinearSolver S,
+                                                       void* P_data,
+                                                       PSetupFn Pset,
+                                                       PSolveFn Psol);
+SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPTFQMR(SUNLinearSolver S,
+                                                       N_Vector s1,
+                                                       N_Vector s2);
+SUNDIALS_EXPORT int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNMatrix A);
+SUNDIALS_EXPORT int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNMatrix A,
+                                           N_Vector x, N_Vector b, realtype tol);
+SUNDIALS_EXPORT int SUNLinSolNumIters_SPTFQMR(SUNLinearSolver S);
+SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPTFQMR(SUNLinearSolver S);
+SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPTFQMR(SUNLinearSolver S);
+SUNDIALS_EXPORT long int SUNLinSolLastFlag_SPTFQMR(SUNLinearSolver S);
+SUNDIALS_EXPORT int SUNLinSolSpace_SPTFQMR(SUNLinearSolver S, 
+                                           long int *lenrwLS, 
+                                           long int *leniwLS);
+SUNDIALS_EXPORT int SUNLinSolFree_SPTFQMR(SUNLinearSolver S);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_band.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_band.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_band.h	(revision 16222)
@@ -0,0 +1,335 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ *                David Gardner @ LLNL
+ * Based on code sundials_direct.h by: Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the band implementation of the 
+ * SUNMATRIX module.
+ * 
+ * Part I contains declarations specific to the band implementation
+ * of the supplied SUNMATRIX module.
+ * 
+ * Part II defines accessor macros that allow the user to 
+ * efficiently use this SUNMatrix type without making explicit
+ * references to the underlying data structure.
+ *
+ * Part III contains the prototype for the constructor 
+ * SUNBandMatrix as well as implementation-specific prototypes 
+ * for various useful matrix operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNMatrix structure can be found
+ *     in the header file sundials_matrix.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype' and 'indextype'.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNMATRIX_BAND_H
+#define _SUNMATRIX_BAND_H
+
+#include <stdio.h>
+#include <sundials/sundials_matrix.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: Band implementation of SUNMatrix
+ *
+ * The band implementation of the SUNMatrix 'content' structure
+ * contains:
+ *   M     - number of rows
+ *   N     - number of columns
+ *   mu    - upper bandwidth, 0 <= mu <= min(M,N)
+ *   ml    - lower bandwidth, 0 <= ml <= min(M,N)
+ *   s_mu  - storage upper bandwidth, mu <= s_mu <= N-1.
+ *           The dgbtrf routine writes the LU factors into the storage 
+ *           for A. The upper triangular factor U, however, may have 
+ *           an upper bandwidth as big as MIN(N-1,mu+ml) because of 
+ *           partial pivoting. The s_mu field holds the upper 
+ *           bandwidth allocated for A.
+ *   ldim  - leading dimension (ldim >= s_mu)
+ *   data  - pointer to a contiguous block of realtype variables
+ *   ldata - length of the data array = ldim*(s_mu+ml+1)
+ *   cols  - array of pointers. cols[j] points to the first element 
+ *           of the j-th column of the matrix in the array data.
+ * The elements of a band matrix are stored columnwise (i.e. columns 
+ * are stored one on top of the other in memory); i.e. if A is a 
+ * SUNMatrix_Band object, then the (i,j)th element of A (with 
+ * 0 <= i < M and 0 <= j < N) is given by ???
+ *
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNMatrixContent_Band {
+  sunindextype M;
+  sunindextype N;
+  sunindextype ldim;
+  sunindextype mu;
+  sunindextype ml;
+  sunindextype s_mu;
+  realtype *data;
+  sunindextype ldata;
+  realtype **cols;
+};
+
+typedef struct _SUNMatrixContent_Band *SUNMatrixContent_Band;
+
+  
+/*
+ * -----------------------------------------------------------------
+ * PART II: macros SM_CONTENT_B, SM_DATA_B, SM_ROWS_B, SM_COLUMNS_B, 
+ *          SM_UBAND_B, SM_LBAND_B, SM_SUBAND_B, SM_LDIM_B, SM_COLS_B, 
+ *          SM_COLUMN_B, SM_COLUMN_ELEMENT_B, and SM_ELEMENT_B
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * SUNMatrix A;
+ * SUNMatrixContent_Band A_cont;
+ * realtype *A_col_j, *A_data, **A_cols, A_ij;
+ * sunindextype i, j, A_rows, A_columns, A_ldata, A_ldim;
+ *
+ * (1) SM_CONTENT_B
+ *
+ *     This macro gives access to the contents of the band
+ *     SUNMatrix
+ *
+ *     The assignment A_cont = SM_CONTENT_B(A) sets A_cont to be
+ *     a pointer to the band SUNMatrix content structure.
+ *
+ * (2) SM_DATA_B, SM_ROWS_B, SM_COLUMNS_B, SM_LDATA_B, SM_LDIM_B, 
+ *     SM_UBAND_B, SM_LBAND_B and SM_SUBAND_B
+ *
+ *     These macros give access to the individual parts of
+ *     the content structure of a band SUNMatrix.
+ *
+ *     The assignment A_data = SM_DATA_B(A) sets A_data to be
+ *     a pointer to the first component of A. 
+ *
+ *     The assignment A_cols = SM_COLS_B(A) sets A_cols to be
+ *     a pointer to the content's 'cols' entry.
+ *
+ *     The assignment A_rows = SM_ROWS_B(A) sets A_rows to be
+ *     the number of rows in A.
+ *
+ *     The assignment A_columns = SM_COLUMNS_B(A) sets A_columns 
+ *     to be the number of columns in A.
+ *
+ *     The assignment A_ldata = SM_LDATA_B(A) sets A_ldata to be
+ *     the length of the data array for A.
+ *
+ *     The assignment A_mu = SM_UBAND_B(A) sets A_mu to be
+ *     the upper bandwidth of A.
+ *
+ *     The assignment A_ml = SM_LBAND_B(A) sets A_lu to be
+ *     the lower bandwidth of A.
+ *
+ *     The assignment A_smu = SM_SUBAND_B(A) sets A_smu to be
+ *     the storage upper bandwidth of A.
+ *
+ *     The assignment A_ldim = SM_LDIM_B(A) sets A_ldim to be
+ *     the length of the leading dimension of A.
+ *
+ * (3) SM_COLUMN_B, SM_COLUMN_ELEMENT_B and SM_ELEMENT_B
+ *
+ *     These macros give access to the individual columns and 
+ *     elements of a band SUNMatrix, respectively.  In the 
+ *     following, the entries of a SUNMatrix are indexed (i,j) 
+ *     where i=0,...,M-1 and j=0,...,N-1.
+ *     
+ *     The assignment A_col_j = SM_COLUMN_B(A,j) sets A_col_j to 
+ *     be a pointer to the jth column of the M-by-N band
+ *     matrix A, 0 <= j < N.  After the assignment, A_col_j may 
+ *     be treated as an array indexed from -mu to ml.
+ *     The (i,j)-th element of A is thus referenced by col_j[i-j].
+ *
+ *     The assignment A_ij = SM_COLUMN_ELEMENT_B(SM_COLUMN_B(A),i,j) 
+ *     sets A_ij to the value of the (i,j)th element of the band 
+ *     M-by-N matrix A, when used in conjunction with SM_COLUMN_B.  
+ *     The index (i,j) should satisfy j-mu <= i <= j+ml, with 
+ *     0 <= i < M and 0 <= j < N.  Similarly, the assignment  
+ *     SM_COLUMN_ELEMENT_B(SM_COLUMN_B(A),i,j) = A_ij sets the value 
+ *     of A_ij into the (i,j) location of the matrix A.
+ *
+ *     The assignment A_ij = SM_ELEMENT_B(A,i,j) sets A_ij to 
+ *     the value of the (i,j)th element of the band M-by-N matrix
+ *     A.  The location (i,j) should satisfy j-mu <= i <= j+ml, 
+ *     with 0 <= i < M ; 0 <= j < N.  Similarly, the assignment 
+ *     SM_ELEMENT_B(A,i,j) = A_ij sets the value of A_ij into the 
+ *     (i,j) location of the matrix A.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#define SM_CONTENT_B(A)     ( (SUNMatrixContent_Band)(A->content) )
+
+#define SM_ROWS_B(A)        ( SM_CONTENT_B(A)->M )
+
+#define SM_COLUMNS_B(A)     ( SM_CONTENT_B(A)->N )
+
+#define SM_LDATA_B(A)       ( SM_CONTENT_B(A)->ldata )
+
+#define SM_UBAND_B(A)       ( SM_CONTENT_B(A)->mu )
+
+#define SM_LBAND_B(A)       ( SM_CONTENT_B(A)->ml )
+
+#define SM_SUBAND_B(A)      ( SM_CONTENT_B(A)->s_mu )
+
+#define SM_LDIM_B(A)        ( SM_CONTENT_B(A)->ldim )
+
+#define SM_DATA_B(A)        ( SM_CONTENT_B(A)->data )
+
+#define SM_COLS_B(A)        ( SM_CONTENT_B(A)->cols )
+
+#define SM_COLUMN_B(A,j)    ( ((SM_CONTENT_B(A)->cols)[j])+SM_SUBAND_B(A) )
+
+#define SM_COLUMN_ELEMENT_B(col_j,i,j) (col_j[(i)-(j)])
+
+#define SM_ELEMENT_B(A,i,j) ( (SM_CONTENT_B(A)->cols)[j][(i)-(j)+SM_SUBAND_B(A)] )
+
+
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by sunmatrix_band
+ * 
+ * CONSTRUCTORS:
+ *    SUNBandMatrix
+ * OTHER:
+ *    SUNBandMatrix_Print
+ *    SUNBandMatrix_Rows
+ *    SUNBandMatrix_Columns
+ *    SUNBandMatrix_LowerBandwidth
+ *    SUNBandMatrix_UpperBandwidth
+ *    SUNBandMatrix_StoredUpperBandwidth
+ *    SUNBandMatrix_LDim
+ *    SUNBandMatrix_Data
+ *    SUNBandMatrix_Cols
+ *    SUNBandMatrix_Column
+ * -----------------------------------------------------------------
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SUNBandMatrix
+ * -----------------------------------------------------------------
+ * SUNBandMatrix creates and allocates memory for an M-by-N 
+ * band matrix with upper bandwidth mu, lower bandwidth ml, and 
+ * storage upper bandwidth smu. Pass smu as follows depending on 
+ * whether A will be LU factored:
+ *
+ * (1) Pass smu = mu if A will not be factored.
+ *
+ * (2) Pass smu = MIN(N-1,mu+ml) if A will be factored.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix SUNBandMatrix(sunindextype N, sunindextype mu,
+                                        sunindextype ml, sunindextype smu);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SUNBandMatrix_Print
+ * -----------------------------------------------------------------
+ * This function prints the content of a M-by-N band matrix A to
+ * a file pointer as it would normally appear on paper.
+ * It is intended as debugging tools with small values of M and N.
+ * The elements are printed using the %g/%lg/%Lg option. 
+ * A blank line is printed before and after the matrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SUNBandMatrix_Print(SUNMatrix A, FILE* outfile);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Accessor Functions: 
+ *
+ * SUNBandMatrix_Rows
+ *    Returns the number of rows in the banded matrix
+ *
+ * SUNBandMatrix_Columns
+ *    Returns the number of columns in the banded matrix
+ *
+ * SUNBandMatrix_LowerBandwidth
+ *    Returns the number of lower bands in the banded matrix
+ *
+ * SUNBandMatrix_UpperBandwidth
+ *    Returns the number of upper bands in the banded matrix
+ *
+ * SUNBandMatrix_StoredUpperBandwidth
+ *    Returns the number of stored upper bands in the banded matrix
+ *
+ * SUNBandMatrix_LDim
+ *    Returns the length of the leading dimension of A.
+ *
+ * SUNBandMatrix_Data
+ *    Returns a pointer to the data array for the banded matrix
+ *
+ * SUNBandMatrix_Cols
+ *    Returns a pointer to the cols array for the banded matrix
+ *
+ * SUNBandMatrix_Column
+ *    Returns a pointer to the diagonal entry of jth column of the
+ *    banded matrix.  The resulting pointer should be indexed over 
+ *    the range -mu to ml.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype SUNBandMatrix_Rows(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNBandMatrix_Columns(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNBandMatrix_LowerBandwidth(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNBandMatrix_UpperBandwidth(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNBandMatrix_StoredUpperBandwidth(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNBandMatrix_LDim(SUNMatrix A);
+SUNDIALS_EXPORT realtype* SUNBandMatrix_Data(SUNMatrix A);
+SUNDIALS_EXPORT realtype** SUNBandMatrix_Cols(SUNMatrix A);
+SUNDIALS_EXPORT realtype* SUNBandMatrix_Column(SUNMatrix A, sunindextype j);
+
+/*
+ * -----------------------------------------------------------------
+ * band implementations of various useful matrix operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_Band(SUNMatrix A);
+SUNDIALS_EXPORT SUNMatrix SUNMatClone_Band(SUNMatrix A);
+SUNDIALS_EXPORT void SUNMatDestroy_Band(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatZero_Band(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatCopy_Band(SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAdd_Band(realtype c, SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAddI_Band(realtype c, SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatMatvec_Band(SUNMatrix A, N_Vector x, N_Vector y);
+SUNDIALS_EXPORT int SUNMatSpace_Band(SUNMatrix A, long int *lenrw, long int *leniw);
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_dense.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_dense.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_dense.h	(revision 16222)
@@ -0,0 +1,264 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ *                David Gardner @ LLNL
+ * Based on code sundials_direct.h by: Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the dense implementation of the 
+ * SUNMATRIX module.
+ * 
+ * Part I contains declarations specific to the dense implementation
+ * of the supplied SUNMATRIX module.
+ * 
+ * Part II defines accessor macros that allow the user to 
+ * efficiently use this SUNMatrix type without making explicit
+ * references to the underlying data structure.
+ *
+ * Part III contains the prototype for the constructor 
+ * SUNDenseMatrix as well as implementation-specific prototypes 
+ * for various useful matrix operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNMatrix structure can be found
+ *     in the header file sundials_matrix.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype' and 'indextype'.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNMATRIX_DENSE_H
+#define _SUNMATRIX_DENSE_H
+
+#include <stdio.h>
+#include <sundials/sundials_matrix.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: Dense implementation of SUNMatrix
+ *
+ * The dense implementation of the SUNMatrix 'content' structure
+ * contains:
+ *   M     - number of rows
+ *   N     - number of columns
+ *   data  - pointer to a contiguous block of realtype variables
+ *   ldata - length of the data array = M*N
+ *   cols  - array of pointers. cols[j] points to the first element 
+ *           of the j-th column of the matrix in the array data.
+ * The elements of a dense matrix are stored columnwise (i.e. columns 
+ * are stored one on top of the other in memory); i.e. if A is a 
+ * SUNMatrix_Dense object, then the (i,j)th element of A (with 
+ * 0 <= i < M and 0 <= j < N) is given by (A->data)[j*M+i].
+ *
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNMatrixContent_Dense {
+  sunindextype M;
+  sunindextype N;
+  realtype *data;
+  sunindextype ldata;
+  realtype **cols;
+};
+
+typedef struct _SUNMatrixContent_Dense *SUNMatrixContent_Dense;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: macros SM_CONTENT_D, SM_DATA_D, SM_ROWS_D, SM_COLUMNS_D, 
+ *          SM_COLUMN_D, and SM_ELEMENT_D
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * SUNMatrix A;
+ * SUNMatrixContent_Dense A_cont;
+ * realtype *A_col_j, *A_data, **A_cols, A_ij;
+ * sunindextype i, j, A_rows, A_columns, A_ldata;
+ *
+ * (1) SM_CONTENT_D
+ *
+ *     This macro gives access to the contents of the dense
+ *     SUNMatrix
+ *
+ *     The assignment A_cont = SM_CONTENT_D(A) sets A_cont to be
+ *     a pointer to the dense SUNMatrix content structure.
+ *
+ * (2) SM_DATA_D, SM_COLS_D, SM_LDATA_D, SM_ROWS_D, SM_COLUMNS_D
+ *
+ *     These macros give access to the individual parts of
+ *     the content structure of a dense SUNMatrix.
+ *
+ *     The assignment A_data = SM_DATA_D(A) sets A_data to be
+ *     a pointer to the first component of A. 
+ *
+ *     The assignment A_cols = SM_COLS_D(A) sets A_cols to be
+ *     a pointer to the content's 'cols' entry.
+ *
+ *     The assignment A_ldata = SM_LDATA_D(A) sets A_ldata to be
+ *     the length of the data array for A. 
+ *
+ *     The assignment A_rows = SM_ROWS_D(A) sets A_rows to be
+ *     the number of rows in A.
+ *
+ *     The assignment A_columns = SM_COLUMNS_D(A) sets A_columns 
+ *     to be the number of columns in A.
+ *
+ * (3) SM_COLUMN_D and SM_ELEMENT_D
+ *
+ *     These macros give access to the individual columns and 
+ *     elements of a dense SUNMatrix, respectively.  In the 
+ *     following, the entries of a SUNMatrix are indexed (i,j) 
+ *     where i=0,...,M-1 and j=0,...,N-1.
+ *     
+ *     The assignment A_col_j = SM_COLUMN_D(A,j) sets A_col_j to 
+ *     be a pointer to the jth column of the M-by-N dense
+ *     matrix A, 0 <= j < N.  After the assignment, A_col_j may 
+ *     be treated as an array indexed from 0 to M-1.
+ *     The (i,j)-th element of A is thus referenced by col_j[i].
+ *
+ *     The assignment A_ij = SM_ELEMENT_D(A,i,j) sets A_ij to 
+ *     the value of the (i,j)th element of the dense M-by-N matrix
+ *     A, 0 <= i < M ; 0 <= j < N.  Similarly, the assignment 
+ *     SM_ELEMENT_D(A,i,j) = A_ij sets the value of A_ij into the 
+ *     (i,j) location of the matrix A.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#define SM_CONTENT_D(A)     ( (SUNMatrixContent_Dense)(A->content) )
+
+#define SM_ROWS_D(A)        ( SM_CONTENT_D(A)->M )
+
+#define SM_COLUMNS_D(A)     ( SM_CONTENT_D(A)->N )
+
+#define SM_LDATA_D(A)       ( SM_CONTENT_D(A)->ldata )
+
+#define SM_DATA_D(A)        ( SM_CONTENT_D(A)->data )
+
+#define SM_COLS_D(A)        ( SM_CONTENT_D(A)->cols )
+
+#define SM_COLUMN_D(A,j)    ( (SM_CONTENT_D(A)->cols)[j] )
+
+#define SM_ELEMENT_D(A,i,j) ( (SM_CONTENT_D(A)->cols)[j][i] )
+
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by sunmatrix_dense
+ * 
+ * CONSTRUCTORS:
+ *    SUNDenseMatrix
+ * OTHER:
+ *    SUNDenseMatrix_Print
+ *    SUNDenseMatrix_Rows
+ *    SUNDenseMatrix_Columns
+ *    SUNDenseMatrix_LData
+ *    SUNDenseMatrix_Data 
+ *    SUNDenseMatrix_Cols
+ *    SUNDenseMatrix_Column
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SUNDenseMatrix
+ * -----------------------------------------------------------------
+ * Creates and allocates memory for an M-by-N dense SUNMatrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix SUNDenseMatrix(sunindextype M, sunindextype N);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SUNDenseMatrix_Print
+ * -----------------------------------------------------------------
+ * This function prints the content of a M-by-N dense matrix A to
+ * file pointer as it would normally appear on paper.
+ * It is intended as debugging tools with small values of M and N.
+ * The elements are printed using the %g/%lg/%Lg option. 
+ * A blank line is printed before and after the matrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SUNDenseMatrix_Print(SUNMatrix A, FILE* outfile);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Accessor Functions: 
+ *
+ * SUNDenseMatrix_Rows 
+ *    Returns the number of rows in the dense matrix
+ *
+ * SUNDenseMatrix_Columns
+ *    Returns the number of columns in the dense matrix
+ *
+ * SUNDenseMatrix_LData
+ *    Returns the total allocated data length for the dense matrix
+ *
+ * SUNDenseMatrix_Data
+ *    Returns a pointer to the data array for the dense matrix
+ *
+ * SUNDenseMatrix_Cols
+ *    Returns a pointer to the cols array for the dense matrix
+ *
+ * SUNDenseMatrix_Column
+ *    Returns a pointer to the jth column of the dense matrix
+ *
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype SUNDenseMatrix_Rows(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNDenseMatrix_Columns(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNDenseMatrix_LData(SUNMatrix A);
+SUNDIALS_EXPORT realtype* SUNDenseMatrix_Data(SUNMatrix A);
+SUNDIALS_EXPORT realtype** SUNDenseMatrix_Cols(SUNMatrix A);
+SUNDIALS_EXPORT realtype* SUNDenseMatrix_Column(SUNMatrix A, sunindextype j);
+
+/*
+ * -----------------------------------------------------------------
+ * dense implementations of various useful matrix operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_Dense(SUNMatrix A);
+SUNDIALS_EXPORT SUNMatrix SUNMatClone_Dense(SUNMatrix A);
+SUNDIALS_EXPORT void SUNMatDestroy_Dense(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatZero_Dense(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatCopy_Dense(SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAdd_Dense(realtype c, SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAddI_Dense(realtype c, SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatMatvec_Dense(SUNMatrix A, N_Vector x, N_Vector y);
+SUNDIALS_EXPORT int SUNMatSpace_Dense(SUNMatrix A, long int *lenrw,
+                                      long int *leniw);
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_sparse.h
===================================================================
--- /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_sparse.h	(revision 16222)
+++ /branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/sunmatrix/sunmatrix_sparse.h	(revision 16222)
@@ -0,0 +1,370 @@
+/*
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel Reynolds @ SMU
+ *                David Gardner @ LLNL
+ * Based on code sundials_sparse.h by: Carol Woodward and 
+ *     Slaven Peles @ LLNL, and Daniel R. Reynolds @ SMU
+ * -----------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2017, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the sparse implementation of the 
+ * SUNMATRIX module.
+ * 
+ * Part I contains declarations specific to the sparse implementation
+ * of the supplied SUNMATRIX module.
+ * 
+ * Part II defines accessor macros that allow the user to 
+ * efficiently use this SUNMatrix type without making explicit
+ * references to the underlying data structure.
+ *
+ * Part III contains the prototype for the constructor 
+ * SUNMatrixNew_Sparse as well as implementation-specific prototypes 
+ * for various useful matrix operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic SUNMatrix structure can be found
+ *     in the header file sundials_matrix.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype' and 'indextype'.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNMATRIX_SPARSE_H
+#define _SUNMATRIX_SPARSE_H
+
+#include <stdio.h>
+#include <sundials/sundials_matrix.h>
+#include <sunmatrix/sunmatrix_dense.h>
+#include <sunmatrix/sunmatrix_band.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * ==================================================================
+ * Type definitions
+ * ==================================================================
+ */
+
+#define CSC_MAT 0
+#define CSR_MAT 1
+
+  
+/*
+ * -----------------------------------------------------------------
+ * PART I: Sparse implementation of SUNMatrix
+ *
+ * The sparse implementation of the SUNMatrix 'content' structure
+ * contains:
+ *   M     - number of rows
+ *   N     - number of columns
+ *   NNZ   - the number of nonzero entries in the matrix
+ *   NP    - number of index pointers
+ *   data  - pointer to a contiguous block of realtype variables
+ *   sparsetype - type of sparse matrix: compressed sparse column or row
+ *   indexvals  - indices of each nonzero entry (columns or rows)
+ *   indexptrs  - starting index of the first entry in data for each slice
+ *   rowvals - pointer to row indices of each nonzero entry
+ *   colptrs - pointer to starting indices in data array for each column
+ *   colvals - pointer to column indices of each nonzero entry
+ *   rowptrs - pointer to starting indices in data array for each row
+ * -----------------------------------------------------------------
+ */
+  
+struct _SUNMatrixContent_Sparse {
+  sunindextype M;
+  sunindextype N;
+  sunindextype NNZ;
+  sunindextype NP;
+  realtype *data;
+  int sparsetype;
+  sunindextype *indexvals;
+  sunindextype *indexptrs;
+  /* CSC indices */
+  sunindextype **rowvals;
+  sunindextype **colptrs;
+  /* CSR indices */
+  sunindextype **colvals;
+  sunindextype **rowptrs;
+};
+
+typedef struct _SUNMatrixContent_Sparse *SUNMatrixContent_Sparse;
+
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: macros SM_CONTENT_S, SM_ROWS_S, SM_COLUMNS_S, SM_NNZ_S, 
+ *          SM_NP_S, SM_SPARSETYPE_S, SM_DATA_S, SM_INDEXVALS_S, and
+ *          SM_INDEXPTRS_S
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * SUNMatrix A;
+ * SUNMatrixContent_Sparse A_cont;
+ * realtype *A_data;
+ * int A_type;
+ * sunindextype A_nnz, A_np, *A_ivals, *A_iptrs;
+ *
+ * (1) SM_CONTENT_S
+ *
+ *     This macro gives access to the contents of the sparse
+ *     SUNMatrix
+ *
+ *     The assignment A_cont = SM_CONTENT_S(A) sets A_cont to be
+ *     a pointer to the sparse SUNMatrix content structure.
+ *
+ * (2) SM_ROWS_D, SM_COLUMNS_D, SM_NNZ_S, SM_NP_S, SM_SPARSETYPE_S, 
+ *     SM_DATA_S, SM_INDEXVALS_S and SM_INDEXPTRS_S
+ *
+ *     These macros give access to the individual parts of
+ *     the content structure of a sparse SUNMatrix.
+ *
+ *     The assignment A_rows = SM_ROWS_S(A) sets A_rows to be
+ *     the number of rows in A.
+ *
+ *     The assignment A_cols = SM_COLUMNS_S(A) sets A_cols to be
+ *     the number of columns in A.
+ *
+ *     The assignment A_nnz = SM_NNZ_S(A) sets A_nnz to be
+ *     the number of nonzero entries in A.
+ *
+ *     The assignment A_np = SM_NP_S(A) sets A_np to be
+ *     the number of index pointers in A.
+ *
+ *     The assignment A_type = SM_SPARSETYPE_S(A) sets A_type to be
+ *     the type of sparse matrix that A is (CSC_MAT or CSR_MAT).
+ *
+ *     The assignment A_data = SM_DATA_S(A) sets A_data to be
+ *     a pointer to the first component of the data array for A. 
+ *
+ *     The assignment A_ivals = SM_INDEXVALS_S(A) sets A_ivals to be
+ *     a pointer to the array of index values of each nonzero entry in A. 
+ *
+ *     The assignment A_iptrs = SM_INDEXPTRS_S(A) sets A_iptrs to be
+ *     a pointer to the array of starting indices for the first entry
+ *     of each row/column in the data/indexvals arrays.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#define SM_CONTENT_S(A)     ( (SUNMatrixContent_Sparse)(A->content) )
+
+#define SM_ROWS_S(A)        ( SM_CONTENT_S(A)->M )
+
+#define SM_COLUMNS_S(A)     ( SM_CONTENT_S(A)->N )
+
+#define SM_NNZ_S(A)         ( SM_CONTENT_S(A)->NNZ )
+
+#define SM_NP_S(A)          ( SM_CONTENT_S(A)->NP )
+
+#define SM_SPARSETYPE_S(A)  ( SM_CONTENT_S(A)->sparsetype )
+
+#define SM_DATA_S(A)        ( SM_CONTENT_S(A)->data )
+
+#define SM_INDEXVALS_S(A)   ( SM_CONTENT_S(A)->indexvals )
+
+#define SM_INDEXPTRS_S(A)   ( SM_CONTENT_S(A)->indexptrs )
+
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by sunmatrix_sparse
+ * 
+ * CONSTRUCTORS:
+ *    SUNSparseMatrix
+ *    SUNSparseFromDenseMatrix
+ *    SUNSparseFromBandMatrix
+ * OTHER:
+ *    SUNSparseMatrix_Print
+ *    SUNSparseMatrix_Realloc
+ *    SUNSparseMatrix_Reallocate
+ *    SUNSparseMatrix_Rows
+ *    SUNSparseMatrix_Columns 
+ *    SUNSparseMatrix_NNZ
+ *    SUNSparseMatrix_NP
+ *    SUNSparseMatrix_SparseType
+ *    SUNSparseMatrix_Data 
+ *    SUNSparseMatrix_IndexValues
+ *    SUNSparseMatrix_IndexPointers
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SUNSparseMatrix
+ * -----------------------------------------------------------------
+ * Creates and allocates memory for an M-by-N sparse SUNMatrix of 
+ * type sparsetype.
+ * Requirements: M and N must be strictly positive; NNZ must be 
+ * non-negative; sparsetype must be either CSC_MAT or CSR_MAT;
+ * Returns NULL if any requirements are violated, or if the matrix 
+ * storage request cannot be satisfied.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix SUNSparseMatrix(sunindextype M, sunindextype N,
+                                          sunindextype NNZ, int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SUNSparseFromDenseMatrix
+ * -----------------------------------------------------------------
+ * Creates a new sparse matrix from an existing dense matrix 
+ * by copying all values with magnitude larger than droptol into 
+ * the sparse matrix structure.  
+ * Requirements: A must have type SUNMATRIX_DENSE; 
+ * droptol must be non-negative; sparsetype must be either 
+ * CSC_MAT or CSR_MAT.
+ * Returns NULL if any requirements are violated, or if the matrix
+ * storage request cannot be satisfied. 
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix SUNSparseFromDenseMatrix(SUNMatrix A,
+                                                   realtype droptol,
+                                                   int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SUNSparseFromBandMatrix
+ * -----------------------------------------------------------------
+ * Creates a new sparse matrix from an existing band matrix 
+ * by copying all values with magnitude larger than or equal to 
+ * droptol into the sparse matrix structure.  
+ * Requirements: A must have type SUNMATRIX_BAND; 
+ * droptol must be non-negative; sparsetype must be either 
+ * CSC_MAT or CSR_MAT.
+ * Returns NULL if any requirements are violated, or if the matrix
+ * storage request cannot be satisfied. 
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix SUNSparseFromBandMatrix(SUNMatrix A,
+                                                  realtype droptol,
+                                                  int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SUNSparseMatrix_Realloc
+ * -----------------------------------------------------------------
+ * This function reallocates internal arrays so that the resulting 
+ * sparse matrix holds colptrs[N] nonzeros.  Returns 0 on success and
+ * 1 on failure (e.g. if A does not have sparse type)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SUNSparseMatrix_Realloc(SUNMatrix A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SUNSparseMatrix_Reallocate
+ * -----------------------------------------------------------------
+ * This function reallocates internal arrays so that the resulting 
+ * sparse matrix has storage for a specified number of nonzeros.  
+ * Returns 0 on success and 1 on failure (e.g. if A does not have 
+ * sparse type, or if nnz is negative)
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SUNSparseMatrix_Reallocate(SUNMatrix A, sunindextype NNZ);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SUNSparseMatrix_Print
+ * -----------------------------------------------------------------
+ * This function prints the sparse matrix information to a file 
+ * pointer.  It is intended as a debugging tool with small values 
+ * of NNZ.  The elements are printed using the %g/%lg/%Lg option. 
+ * A blank line is printed before and after the matrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SUNSparseMatrix_Print(SUNMatrix A, FILE* outfile);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Accessor Functions: 
+ *
+ * SUNSparseMatrix_Rows 
+ *    Returns the number of rows in the sparse matrix
+ *
+ * SUNSparseMatrix_Columns
+ *    Returns the number of columns in the sparse matrix
+ *
+ * SUNSparseMatrix_NNZ
+ *    Returns the allocated number of nonzeros in the sparse matrix
+ *
+ * SUNSparseMatrix_NP
+ *    Returns the number of columns/rows depending on whether the 
+ *    matrix uses CSC/CSR format, respectively
+ *
+ * SUNSparseMatrix_SparseType
+ *    Returns the storage type for this matrix (CSR_MAT or CSC_MAT)
+ *
+ * SUNSparseMatrix_Data
+ *    Returns a pointer to the data array for the sparse matrix
+ *
+ * SUNSparseMatrix_IndexValues
+ *    Returns a ptr to the index value array for the sparse matrix:
+ *    for CSR this is the column index for each nonzero,
+ *    for CSC this is the row index for each nonzero.
+ *
+ * SUNSparseMatrix_IndexPointers
+ *    Returns a ptr to the index pointer array for the sparse matrix:
+ *    for CSR this is the location of the first entry of each row,
+ *    for CSC this is the location of the first entry of each column.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT sunindextype SUNSparseMatrix_Rows(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNSparseMatrix_Columns(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNSparseMatrix_NNZ(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype SUNSparseMatrix_NP(SUNMatrix A);
+SUNDIALS_EXPORT int SUNSparseMatrix_SparseType(SUNMatrix A);
+SUNDIALS_EXPORT realtype* SUNSparseMatrix_Data(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype* SUNSparseMatrix_IndexValues(SUNMatrix A);
+SUNDIALS_EXPORT sunindextype* SUNSparseMatrix_IndexPointers(SUNMatrix A);
+
+/*
+ * -----------------------------------------------------------------
+ * sparse implementations of various useful matrix operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_Sparse(SUNMatrix A);
+SUNDIALS_EXPORT SUNMatrix SUNMatClone_Sparse(SUNMatrix A);
+SUNDIALS_EXPORT void SUNMatDestroy_Sparse(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatZero_Sparse(SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatCopy_Sparse(SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAdd_Sparse(realtype c, SUNMatrix A, SUNMatrix B);
+SUNDIALS_EXPORT int SUNMatScaleAddI_Sparse(realtype c, SUNMatrix A);
+SUNDIALS_EXPORT int SUNMatMatvec_Sparse(SUNMatrix A, N_Vector x, N_Vector y);
+SUNDIALS_EXPORT int SUNMatSpace_Sparse(SUNMatrix A, long int *lenrw,
+                                       long int *leniw);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
