Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/CVODES.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/CVODES.cs	(revision 16254)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/CVODES.cs	(revision 16256)
@@ -174,39 +174,48 @@
     );
 
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeCreate", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
     // returns a void* to the cvodes memory block if successful otherwise NULL
-    public static extern IntPtr CVodeCreate(MultistepMethod lmm, NonlinearSolverIteration iter);
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeInit(
+    public static IntPtr CVodeCreate(MultistepMethod lmm, NonlinearSolverIteration iter) {
+      if (Environment.Is64BitProcess) return CVodeCreate_x64(lmm, iter);
+      else return CVodeCreate_x86(lmm, iter);
+    }
+
+    public static int CVodeInit(
       IntPtr cvode_mem, // pointer returned by CVodeCreate
       CVRhsFunc f,
       double t0, // realtype, the inital value of t
       IntPtr y0 // N_Vector the initial value of y
-    );
-
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeSStolerances(
+    ) {
+      if (Environment.Is64BitProcess) return CVodeInit_x64(cvode_mem, f, t0, y0);
+      else return CVodeInit_x86(cvode_mem, f, t0, y0);
+    }
+
+
+    public static int CVodeSStolerances(
       IntPtr cvode_mem,
       double reltol,
       double abstol
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetLinearSolver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVDlsSetLinearSolver(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeSStolerances_x64(cvode_mem, reltol, abstol);
+      else return CVodeSStolerances_x86(cvode_mem, reltol, abstol);
+    }
+
+    public static int CVDlsSetLinearSolver(
       IntPtr cvode_mem,
       IntPtr linearSolver, // SUNLinearSolver
       IntPtr j // SUNMatrix
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetJacFn", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVDlsSetJacFn(
+      ) {
+      if (Environment.Is64BitProcess) return CVDlsSetLinearSolver_x64(cvode_mem, linearSolver, j);
+      else return CVDlsSetLinearSolver_x86(cvode_mem, linearSolver, j);
+    }
+
+    public static int CVDlsSetJacFn(
       IntPtr cvode_mem,
       CVDlsJacFunc jacFunc
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSensInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeSensInit(
+      ) {
+      if (Environment.Is64BitProcess) return CVDlsSetJacFn_x64(cvode_mem, jacFunc);
+      else return CVDlsSetJacFn_x86(cvode_mem, jacFunc);
+    }
+
+    public static int CVodeSensInit(
       IntPtr cvode_mem,
       int Ns, // number of parameters
@@ -214,53 +223,67 @@
       CVSensRhsFn fS, // right hand side function which computes all sensitivity RHS at the same time
       IntPtr yS0 // N_Vector
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSensSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeSensSStolerances(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeSensInit_x64(cvode_mem, Ns, ism, fS, yS0);
+      else return CVodeSensInit_x86(cvode_mem, Ns, ism, fS, yS0);
+    }
+
+    public static int CVodeSensSStolerances(
       IntPtr cvode_mem,
       double reltol,
       double[] abstol
-    );
+    ) {
+      if (Environment.Is64BitProcess) return CVodeSensSStolerances_x64(cvode_mem, reltol, abstol);
+      else return CVodeSensSStolerances_x86(cvode_mem, reltol, abstol);
+    }
 
     /* Call CVodeSensEEtolerances to estimate tolerances for sensitivity 
    variables based on the rolerances supplied for states variables and 
    the scaling factor pbar */
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSensEEtolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeSensEEtolerances(
+    public static int CVodeSensEEtolerances(
       IntPtr cvode_mem
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetSens", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeGetSens(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeSensEEtolerances_x64(cvode_mem);
+      else return CVodeSensEEtolerances_x86(cvode_mem);
+    }
+
+    public static int CVodeGetSens(
       IntPtr cvode_mem,
       ref double tret,
       IntPtr yS //N_Vector*, one vector for each parameter
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeQuadInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeQuadInit(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeGetSens_x64(cvode_mem, ref tret, yS);
+      else return CVodeGetSens_x86(cvode_mem, ref tret, yS);
+    }
+
+    public static int CVodeQuadInit(
       IntPtr cvode_mem,
       CVQuadRhsFn qF,
       IntPtr yQ0 // N_Vector, initial value of yQ
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeQuadInitB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeQuadInitB(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeQuadInit_x64(cvode_mem, qF, yQ0);
+      else return CVodeQuadInit_x86(cvode_mem, qF, yQ0);
+    }
+
+    public static int CVodeQuadInitB(
       IntPtr cvode_mem,
       int indexB,
       CVQuadRhsFnB rhsQB,
       IntPtr yQB0 // N_Vector, initial value of yQB
-    );
-
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeAdjInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeAdjInit(
+    ) {
+      if (Environment.Is64BitProcess) return CVodeQuadInitB_x64(cvode_mem, indexB, rhsQB, yQB0);
+      else return CVodeQuadInitB_x86(cvode_mem, indexB, rhsQB, yQB0);
+    }
+
+
+    public static int CVodeAdjInit(
       IntPtr cvode_mem,
       int nd,  // integration steps between checkpoints
       int interpType // either CV_POLYNOMIAL or CV_HERMITE
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeF", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeF(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeAdjInit_x64(cvode_mem, nd, interpType);
+      else return CVodeAdjInit_x86(cvode_mem, nd, interpType);
+    }
+
+    public static int CVodeF(
         IntPtr cvode_mem,
         double t_out, // the next time at which a computed solution is desired
@@ -269,22 +292,28 @@
         int itask, // CV_NORMAL or CV_ONE_STEP
         ref int ncheck  // the number of internal checkpoints stored so far.
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetNumSteps", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeGetNumSteps(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeF_x64(cvode_mem, t_out, y, ref t_ret, itask, ref ncheck);
+      else return CVodeF_x86(cvode_mem, t_out, y, ref t_ret, itask, ref ncheck);
+    }
+
+    public static int CVodeGetNumSteps(
       IntPtr cvode_mem,
       ref long ncheck  // the number of steps taken
-    );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeCreateB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeCreateB(
+    ) {
+      if (Environment.Is64BitProcess) return CVodeGetNumSteps_x64(cvode_mem, ref ncheck);
+      else return CVodeGetNumSteps_x86(cvode_mem, ref ncheck);
+    }
+
+    public static int CVodeCreateB(
         IntPtr cvode_mem,
         MultistepMethod lmmB,
         NonlinearSolverIteration iterB,
         ref int which
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeInitB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeInitB(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeCreateB_x64(cvode_mem, lmmB, iterB, ref which);
+      else return CVodeCreateB_x86(cvode_mem, lmmB, iterB, ref which);
+    }
+
+    public static int CVodeInitB(
         IntPtr cvode_mem,
         int which,
@@ -292,8 +321,10 @@
         double tB0, // endpoint T where final conditions are provided (equal to endpoint of forward integration)
         IntPtr yB0 // N_Vector inital value at t=tb0 of backward solution
-      );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVode", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVode(
+      ) {
+      if (Environment.Is64BitProcess) return CVodeInitB_x64(cvode_mem, which, rightHandSide, tB0, yB0);
+      else return CVodeInitB_x86(cvode_mem, which, rightHandSide, tB0, yB0);
+    }
+
+    public static int CVode(
       IntPtr cvode_mem,
       double tout, // next time at which a solution is desired
@@ -301,39 +332,458 @@
       ref double tret, // the time reached by the solver (output)
       int itask // flag indicating the job of the solver for the next step. 
-      );
-
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSStolerancesB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeSStolerancesB(
+      ) {
+      if (Environment.Is64BitProcess) return CVode_x64(cvode_mem, tout, yout, ref tret, itask);
+      else return CVode_x86(cvode_mem, tout, yout, ref tret, itask);
+    }
+
+
+    public static int CVodeSStolerancesB(
       IntPtr cvode_mem,
       int which,
       double reltol,
       double abstol
-    );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetLinearSolverB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVDlsSetLinearSolverB(
+    ) {
+      if (Environment.Is64BitProcess) return CVodeSStolerancesB_x64(cvode_mem, which, reltol, abstol);
+      else return CVodeSStolerancesB_x86(cvode_mem, which, reltol, abstol);
+    }
+
+    public static int CVDlsSetLinearSolverB(
       IntPtr cvode_mem,
       int which,
       IntPtr linearSolver, // SUNLinearSolver
       IntPtr j // SUNMatrix
-    );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetJacFnB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVDlsSetJacFnB(
+    ) {
+      if (Environment.Is64BitProcess) return CVDlsSetLinearSolverB_x64(cvode_mem, which, linearSolver, j);
+      else return CVDlsSetLinearSolverB_x86(cvode_mem, which, linearSolver, j);
+    }
+
+    public static int CVDlsSetJacFnB(
       IntPtr cvode_mem,
       int which,
       CVDlsJacFuncB jacFunc
-    );
-
-    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeB(
+    ) {
+      if (Environment.Is64BitProcess) return CVDlsSetJacFnB_x64(cvode_mem, which, jacFunc);
+      else return CVDlsSetJacFnB_x86(cvode_mem, which, jacFunc);
+    }
+
+    public static int CVodeB(
       IntPtr cvode_mem,
       double tout, // next time at which a solution is desired
       int itask // flag indicating the job of the solver for the next step. 
+    ) {
+      if (Environment.Is64BitProcess) return CVodeB_x64(cvode_mem, tout, itask);
+      else return CVodeB_x86(cvode_mem, tout, itask);
+    }
+
+    public static int CVodeGetB(
+          IntPtr cvode_mem,
+          int which,
+          ref double tret,
+          IntPtr yB // the backward solution at time tret
+        ) {
+      if (Environment.Is64BitProcess) return CVodeGetB_x64(cvode_mem, which, ref tret, yB);
+      else return CVodeGetB_x86(cvode_mem, which, ref tret, yB);
+    }
+    public static int CVodeGetAdjY(
+          IntPtr cvode_mem,
+          double t,
+          IntPtr y // the forward solution y(t)
+        ) {
+      if (Environment.Is64BitProcess) return CVodeGetAdjY_x64(cvode_mem, t, y);
+      else return CVodeGetAdjY_x86(cvode_mem, t, y);
+    }
+
+    public static IntPtr CVodeGetAdjCVodeBmem(
+              IntPtr cvode_mem,
+              int which
+            ) {
+      if (Environment.Is64BitProcess) return CVodeGetAdjCVodeBmem_x64(cvode_mem, which);
+      else return CVodeGetAdjCVodeBmem_x86(cvode_mem, which);
+    }
+
+    public static int CVodeGetQuadB(
+        IntPtr cvode_mem,
+        int which,
+        ref double tret,
+        IntPtr yQB // N_Vector
+      ) {
+      if (Environment.Is64BitProcess) return CVodeGetQuadB_x64(cvode_mem, which, ref tret, yQB);
+      else return CVodeGetQuadB_x86(cvode_mem, which, ref tret, yQB);
+    }
+
+    public static int CVodeFree(ref IntPtr cvode_mem) {
+      if (Environment.Is64BitProcess) return CVodeFree_x64(ref cvode_mem);
+      else return CVodeFree_x86(ref cvode_mem);
+    }
+
+    #region matrix
+    public static IntPtr SUNDenseMatrix(long m, long n) {
+      if (Environment.Is64BitProcess) return SUNDenseMatrix_x64(m, n);
+      else return SUNDenseMatrix_x86(m, n);
+    }
+
+    public static void SUNMatDestroy(IntPtr A) {
+      if (Environment.Is64BitProcess) SUNMatDestroy_x64(A);
+      else SUNMatDestroy_x86(A);
+    }
+
+    public unsafe static double* SUNDenseMatrix_Data(IntPtr matrix) {
+      if (Environment.Is64BitProcess) return SUNDenseMatrix_Data_x64(matrix);
+      else return SUNDenseMatrix_Data_x86(matrix);
+    }
+
+    public static long SUNDenseMatrix_Cols(IntPtr matrix) {
+      if (Environment.Is64BitProcess) return SUNDenseMatrix_Cols_x64(matrix);
+      else return SUNDenseMatrix_Cols_x86(matrix);
+    }
+
+    public static long SUNDenseMatrix_Rows(IntPtr matrix) {
+      if (Environment.Is64BitProcess) return SUNDenseMatrix_Rows_x64(matrix);
+      else return SUNDenseMatrix_Rows_x86(matrix);
+    }
+
+    public unsafe static double SUNDenseMatrix_Get(IntPtr mat, long i, long j) {
+      if (Environment.Is64BitProcess) {
+        long M = SUNDenseMatrix_Rows_x64(mat);
+        // the(i, j)th element of A(with 0 <= i<M and 0 <= j<N) is given by(A->data)[j*M+i]
+        return SUNDenseMatrix_Data_x64(mat)[j * M + i];
+      } else {
+        long M = SUNDenseMatrix_Rows_x86(mat);
+        return SUNDenseMatrix_Data_x86(mat)[j * M + i];
+      }
+    }
+
+    public unsafe static void SUNDenseMatrix_Set(IntPtr mat, long i, long j, double val) {
+      if (Environment.Is64BitProcess) {
+        long M = SUNDenseMatrix_Rows_x64(mat);
+        // the(i, j)th element of A(with 0 <= i<M and 0 <= j<N) is given by(A->data)[j*M+i]
+        SUNDenseMatrix_Data_x64(mat)[j * M + i] = val;
+      } else {
+        long M = SUNDenseMatrix_Rows_x86(mat);
+        // the(i, j)th element of A(with 0 <= i<M and 0 <= j<N) is given by(A->data)[j*M+i]
+        SUNDenseMatrix_Data_x86(mat)[j * M + i] = val;
+      }
+    }
+
+    #endregion
+
+    #region linear solver
+    public static IntPtr SUNDenseLinearSolver(
+      IntPtr y, // N_Vector
+      IntPtr A // SUNMatrix
+      ) {
+      if (Environment.Is64BitProcess) return SUNDenseLinearSolver_x64(y, A);
+      else return SUNDenseLinearSolver_x86(y, A);
+    }
+
+    public static int SUNLinSolInitialize(IntPtr linearSolver) {
+      if (Environment.Is64BitProcess) return SUNLinSolInitialize_x64(linearSolver);
+      else return SUNLinSolInitialize_x86(linearSolver);
+    }
+
+    public static int SUNLinSolSetup(
+      IntPtr linearSolver,
+      IntPtr A // SUNMatrix
+      ) {
+      if (Environment.Is64BitProcess) return SUNLinSolSetup_x64(linearSolver, A);
+      else return SUNLinSolSetup_x86(linearSolver, A);
+    }
+
+    public static int SUNLinSolSolve(
+      IntPtr linearSolver,
+      IntPtr A, // SUNMatrix
+      IntPtr x, // N_Vector
+      IntPtr b, // N_Vector
+      double tol
+      ) {
+      if (Environment.Is64BitProcess) return SUNLinSolSolve_x64(linearSolver, A, x, b, tol);
+      else return SUNLinSolSolve_x86(linearSolver, A, x, b, tol);
+    }
+
+    public static int SUNLinSolFree(IntPtr linearSolver) {
+      if (Environment.Is64BitProcess) return SUNLinSolFree_x64(linearSolver);
+      else return SUNLinSolFree_x86(linearSolver);
+    }
+
+    #endregion
+
+    #region N_Vector
+    public static IntPtr N_VNew_Serial(long vec_length) {
+      if (Environment.Is64BitProcess) return N_VNew_Serial_x64(vec_length);
+      else return N_VNew_Serial_x86(vec_length);
+    }
+
+    public static void N_VDestroy_Serial(IntPtr vec) {
+      if (Environment.Is64BitProcess) N_VDestroy_Serial_x64(vec);
+      else N_VDestroy_Serial_x86(vec);
+    }
+
+    public static void N_VDestroyVectorArray_Serial(IntPtr vecArr, int count) {
+      if (Environment.Is64BitProcess) N_VDestroyVectorArray_Serial_x64(vecArr, count);
+      else N_VDestroyVectorArray_Serial_x86(vecArr, count);
+    }
+
+    public static void N_VPrint_Serial(IntPtr vec) {
+      if (Environment.Is64BitProcess) N_VPrint_Serial_x64(vec);
+      else N_VPrint_Serial_x86(vec);
+    }
+
+    public static void N_VConst_Serial(double c, IntPtr vec) {
+      if (Environment.Is64BitProcess) N_VConst_Serial_x64(c, vec);
+      else N_VConst_Serial_x86(c, vec);
+    }
+
+
+    public static double N_VL1Norm_Serial(IntPtr vec) {
+      if (Environment.Is64BitProcess) return N_VL1Norm_Serial_x64(vec);
+      else return N_VL1Norm_Serial_x86(vec);
+    }
+
+    public static IntPtr N_VMake_Serial(long vec_length, double[] v_data) {
+      if (Environment.Is64BitProcess) return N_VMake_Serial_x64(vec_length, v_data);
+      else return N_VMake_Serial_x86(vec_length, v_data);
+    }
+
+    ///  Performs the operation z = c*x
+    public static void N_VScale(double s,
+      IntPtr x, // N_Vector
+      IntPtr z // N_Vector
+      ) {
+      if (Environment.Is64BitProcess) N_VScale_x64(s, x, z);
+      else N_VScale_x86(s, x, z);
+    }
+
+    public unsafe static double* N_VGetArrayPointer_Serial(IntPtr vec) {
+      if (Environment.Is64BitProcess) return N_VGetArrayPointer_Serial_x64(vec);
+      else return N_VGetArrayPointer_Serial_x86(vec);
+    }
+
+    public static IntPtr N_VCloneVectorArray_Serial(int count, IntPtr vec) {
+      if (Environment.Is64BitProcess) return N_VCloneVectorArray_Serial_x64(count, vec);
+      else return N_VCloneVectorArray_Serial_x86(count, vec);
+    }
+
+
+    /*
+#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] )
+*/
+    // methods for macros
+    // the vector is a pointer to a struct
+    // the struct has following layout
+    // {
+    //    long length,
+    //    int  own_data,   // flag to store whether the memory for the vector is managed internally
+    //    double* data,    // pointer to the actual elements
+    // }
+
+    private unsafe static IntPtr NV_CONTENT_S(IntPtr v) {
+      if (Environment.Is64BitProcess) {
+        return new IntPtr(*(Int64*)v.ToPointer());
+      } else {
+        return new IntPtr(*(Int32*)v.ToPointer());
+      }
+    }
+
+    public unsafe static long NV_LENGTH_S(IntPtr v) {
+      long length = *(long*)NV_CONTENT_S(v).ToPointer();
+      return length;
+    }
+    public unsafe static bool NV_OWN_DATA_S(IntPtr v) {
+      var content = (int*)NV_CONTENT_S(v).ToPointer();
+      int own_data = *(content + 2);
+      return own_data > 0;
+    }
+    public unsafe static double* NV_DATA_S(IntPtr v) {
+      if (Environment.Is64BitProcess) {
+        var content = (long*)NV_CONTENT_S(v).ToPointer();
+        double* data = (double*)*(content + 2); // different alignment or sizeof(int)?
+        return data;
+      } else {
+        var content = (int*)NV_CONTENT_S(v).ToPointer();
+        double* data = (double*)*(content + 3);
+        return data;
+      }
+    }
+    public unsafe static double NV_Get_Ith_S(IntPtr v, long i) {
+      return NV_DATA_S(v)[i];
+    }
+    public unsafe static void NV_Set_Ith_S(IntPtr v, long i, double val) {
+      NV_DATA_S(v)[i] = val;
+    }
+    #endregion
+
+
+    #region x86
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeCreate", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    // returns a void* to the cvodes memory block if successful otherwise NULL
+    private static extern IntPtr CVodeCreate_x86(MultistepMethod lmm, NonlinearSolverIteration iter);
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeInit_x86(
+      IntPtr cvode_mem, // pointer returned by CVodeCreate
+      CVRhsFunc f,
+      double t0, // realtype, the inital value of t
+      IntPtr y0 // N_Vector the initial value of y
+    );
+
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSStolerances_x86(
+      IntPtr cvode_mem,
+      double reltol,
+      double abstol
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetLinearSolver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetLinearSolver_x86(
+      IntPtr cvode_mem,
+      IntPtr linearSolver, // SUNLinearSolver
+      IntPtr j // SUNMatrix
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetJacFn", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetJacFn_x86(
+      IntPtr cvode_mem,
+      CVDlsJacFunc jacFunc
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSensInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSensInit_x86(
+      IntPtr cvode_mem,
+      int Ns, // number of parameters
+      int ism, // sensitivity solution method, CV_SIMULTANEOUS or CV_STAGGERED
+      CVSensRhsFn fS, // right hand side function which computes all sensitivity RHS at the same time
+      IntPtr yS0 // N_Vector
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSensSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSensSStolerances_x86(
+      IntPtr cvode_mem,
+      double reltol,
+      double[] abstol
+    );
+
+    /* Call CVodeSensEEtolerances to estimate tolerances for sensitivity 
+   variables based on the rolerances supplied for states variables and 
+   the scaling factor pbar */
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSensEEtolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSensEEtolerances_x86(
+      IntPtr cvode_mem
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetSens", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetSens_x86(
+      IntPtr cvode_mem,
+      ref double tret,
+      IntPtr yS //N_Vector*, one vector for each parameter
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeQuadInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeQuadInit_x86(
+      IntPtr cvode_mem,
+      CVQuadRhsFn qF,
+      IntPtr yQ0 // N_Vector, initial value of yQ
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeQuadInitB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeQuadInitB_x86(
+      IntPtr cvode_mem,
+      int indexB,
+      CVQuadRhsFnB rhsQB,
+      IntPtr yQB0 // N_Vector, initial value of yQB
+    );
+
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeAdjInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeAdjInit_x86(
+      IntPtr cvode_mem,
+      int nd,  // integration steps between checkpoints
+      int interpType // either CV_POLYNOMIAL or CV_HERMITE
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeF", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeF_x86(
+        IntPtr cvode_mem,
+        double t_out, // the next time at which a computed solution is desired
+        IntPtr y, // N_Vector, the solution vector y
+        ref double t_ret, // the time reached by the solver (output)
+        int itask, // CV_NORMAL or CV_ONE_STEP
+        ref int ncheck  // the number of internal checkpoints stored so far.
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetNumSteps", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetNumSteps_x86(
+      IntPtr cvode_mem,
+      ref long ncheck  // the number of steps taken
+    );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeCreateB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeCreateB_x86(
+        IntPtr cvode_mem,
+        MultistepMethod lmmB,
+        NonlinearSolverIteration iterB,
+        ref int which
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeInitB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeInitB_x86(
+        IntPtr cvode_mem,
+        int which,
+        CVRhsFuncB rightHandSide,
+        double tB0, // endpoint T where final conditions are provided (equal to endpoint of forward integration)
+        IntPtr yB0 // N_Vector inital value at t=tb0 of backward solution
+      );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVode", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVode_x86(
+      IntPtr cvode_mem,
+      double tout, // next time at which a solution is desired
+      IntPtr yout, // N_Vector
+      ref double tret, // the time reached by the solver (output)
+      int itask // flag indicating the job of the solver for the next step. 
+      );
+
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeSStolerancesB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSStolerancesB_x86(
+      IntPtr cvode_mem,
+      int which,
+      double reltol,
+      double abstol
+    );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetLinearSolverB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetLinearSolverB_x86(
+      IntPtr cvode_mem,
+      int which,
+      IntPtr linearSolver, // SUNLinearSolver
+      IntPtr j // SUNMatrix
+    );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVDlsSetJacFnB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetJacFnB_x86(
+      IntPtr cvode_mem,
+      int which,
+      CVDlsJacFuncB jacFunc
+    );
+
+    [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeB_x86(
+      IntPtr cvode_mem,
+      double tout, // next time at which a solution is desired
+      int itask // flag indicating the job of the solver for the next step. 
     );
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeGetB(
+    private static extern int CVodeGetB_x86(
           IntPtr cvode_mem,
           int which,
@@ -342,5 +792,5 @@
         );
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetAdjY", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeGetAdjY(
+    private static extern int CVodeGetAdjY_x86(
           IntPtr cvode_mem,
           double t,
@@ -349,5 +799,5 @@
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetAdjCVodeBmem", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern IntPtr CVodeGetAdjCVodeBmem(
+    private static extern IntPtr CVodeGetAdjCVodeBmem_x86(
               IntPtr cvode_mem,
               int which
@@ -355,5 +805,5 @@
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeGetQuadB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int CVodeGetQuadB(
+    private static extern int CVodeGetQuadB_x86(
         IntPtr cvode_mem,
         int which,
@@ -364,34 +814,22 @@
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "CVodeFree", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
 
-    public static extern int CVodeFree(ref IntPtr cvode_mem);
+    private static extern int CVodeFree_x86(ref IntPtr cvode_mem);
 
     #region matrix
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNDenseMatrix", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern IntPtr SUNDenseMatrix(long m, long n);
+    private static extern IntPtr SUNDenseMatrix_x86(long m, long n);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNMatDestroy", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern void SUNMatDestroy(IntPtr A);
+    private static extern void SUNMatDestroy_x86(IntPtr A);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNDenseMatrix_Data", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public unsafe static extern double* SUNDenseMatrix_Data(IntPtr matrix);
+    private unsafe static extern double* SUNDenseMatrix_Data_x86(IntPtr matrix);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNDenseMatrix_Cols", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern long SUNDenseMatrix_Cols(IntPtr matrix);
+    private static extern long SUNDenseMatrix_Cols_x86(IntPtr matrix);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNDenseMatrix_Rows", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern long SUNDenseMatrix_Rows(IntPtr matrix);
-
-
-    public unsafe static double SUNDenseMatrix_Get(IntPtr mat, long i, long j) {
-      long M = SUNDenseMatrix_Rows(mat);
-      // the(i, j)th element of A(with 0 <= i<M and 0 <= j<N) is given by(A->data)[j*M+i]
-      return SUNDenseMatrix_Data(mat)[j * M + i];
-    }
-
-    public unsafe static void SUNDenseMatrix_Set(IntPtr mat, long i, long j, double val) {
-      long M = SUNDenseMatrix_Rows(mat);
-      // the(i, j)th element of A(with 0 <= i<M and 0 <= j<N) is given by(A->data)[j*M+i]
-      SUNDenseMatrix_Data(mat)[j * M + i] = val;
-    }
+    private static extern long SUNDenseMatrix_Rows_x86(IntPtr matrix);
+
 
     #endregion
@@ -399,5 +837,5 @@
     #region linear solver
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNDenseLinearSolver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern IntPtr SUNDenseLinearSolver(
+    private static extern IntPtr SUNDenseLinearSolver_x86(
       IntPtr y, // N_Vector
       IntPtr A // SUNMatrix
@@ -405,8 +843,8 @@
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNLinSolInitialize", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int SUNLinSolInitialize(IntPtr linearSolver);
+    private static extern int SUNLinSolInitialize_x86(IntPtr linearSolver);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNLinSolSetup", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int SUNLinSolSetup(
+    private static extern int SUNLinSolSetup_x86(
       IntPtr linearSolver,
       IntPtr A // SUNMatrix
@@ -414,5 +852,5 @@
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNLinSolSolve", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int SUNLinSolSolve(
+    private static extern int SUNLinSolSolve_x86(
       IntPtr linearSolver,
       IntPtr A, // SUNMatrix
@@ -423,5 +861,5 @@
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "SUNLinSolFree", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern int SUNLinSolFree(IntPtr linearSolver);
+    private static extern int SUNLinSolFree_x86(IntPtr linearSolver);
 
     #endregion
@@ -429,28 +867,28 @@
     #region N_Vector
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VNew_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern IntPtr N_VNew_Serial(long vec_length);
+    private static extern IntPtr N_VNew_Serial_x86(long vec_length);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VDestroy_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern void N_VDestroy_Serial(IntPtr vec);
+    private static extern void N_VDestroy_Serial_x86(IntPtr vec);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VDestroyVectorArray_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern void N_VDestroyVectorArray_Serial(IntPtr vecArr, int count);
+    private static extern void N_VDestroyVectorArray_Serial_x86(IntPtr vecArr, int count);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VPrint_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern void N_VPrint_Serial(IntPtr vec);
+    private static extern void N_VPrint_Serial_x86(IntPtr vec);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VConst_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern void N_VConst_Serial(double c, IntPtr vec);
+    private static extern void N_VConst_Serial_x86(double c, IntPtr vec);
 
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VL1Norm_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern double N_VL1Norm_Serial(IntPtr vec);
+    private static extern double N_VL1Norm_Serial_x86(IntPtr vec);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VMake_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern IntPtr N_VMake_Serial(long vec_length, double[] v_data);
+    private static extern IntPtr N_VMake_Serial_x86(long vec_length, double[] v_data);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VScale", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
     ///  Performs the operation z = c*x
-    public static extern void N_VScale(double s,
+    private static extern void N_VScale_x86(double s,
       IntPtr x, // N_Vector
       IntPtr z // N_Vector
@@ -458,50 +896,293 @@
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VMake_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public unsafe static extern double* N_VGetArrayPointer_Serial(IntPtr vec);
+    private unsafe static extern double* N_VGetArrayPointer_Serial_x86(IntPtr vec);
 
     [DllImport("sundials_cvodes-x86.dll", EntryPoint = "N_VCloneVectorArray_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
-    public static extern IntPtr N_VCloneVectorArray_Serial(int count, IntPtr vec); // returns N_Vector* !
-
-
-    /*
-#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] )
-*/
-    // methods for macros
-    public unsafe static int* NV_CONTENT_S(IntPtr v) {
-      int* content = (int*)*(int*)v.ToPointer();
-      return content;
-    }
-
-    public unsafe static long NV_LENGTH_S(IntPtr v) {
-      long length = *NV_CONTENT_S(v);
-      return length;
-    }
-    public unsafe static bool NV_OWN_DATA_S(IntPtr v) {
-      var content = NV_CONTENT_S(v);
-      int own_data = *(content + 2);
-      return own_data > 0;
-    }
-    public unsafe static double* NV_DATA_S(IntPtr v) {
-      var content = NV_CONTENT_S(v);
-      double* data = (double*)*(content + 3);
-      return data;
-    }
-    public unsafe static double NV_Get_Ith_S(IntPtr v, long i) {
-      return NV_DATA_S(v)[i];
-    }
-    public unsafe static void NV_Set_Ith_S(IntPtr v, long i, double val) {
-      NV_DATA_S(v)[i] = val;
-    }
+    private static extern IntPtr N_VCloneVectorArray_Serial_x86(int count, IntPtr vec); // returns N_Vector* !
+
     #endregion
 
-
+    #endregion
+
+    #region x64
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeCreate", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    // returns a void* to the cvodes memory block if successful otherwise NULL
+    private static extern IntPtr CVodeCreate_x64(MultistepMethod lmm, NonlinearSolverIteration iter);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeInit_x64(
+      IntPtr cvode_mem, // pointer returned by CVodeCreate
+      CVRhsFunc f,
+      double t0, // realtype, the inital value of t
+      IntPtr y0 // N_Vector the initial value of y
+    );
+
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSStolerances_x64(
+      IntPtr cvode_mem,
+      double reltol,
+      double abstol
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVDlsSetLinearSolver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetLinearSolver_x64(
+      IntPtr cvode_mem,
+      IntPtr linearSolver, // SUNLinearSolver
+      IntPtr j // SUNMatrix
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVDlsSetJacFn", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetJacFn_x64(
+      IntPtr cvode_mem,
+      CVDlsJacFunc jacFunc
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeSensInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSensInit_x64(
+      IntPtr cvode_mem,
+      int Ns, // number of parameters
+      int ism, // sensitivity solution method, CV_SIMULTANEOUS or CV_STAGGERED
+      CVSensRhsFn fS, // right hand side function which computes all sensitivity RHS at the same time
+      IntPtr yS0 // N_Vector
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeSensSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSensSStolerances_x64(
+      IntPtr cvode_mem,
+      double reltol,
+      double[] abstol
+    );
+
+    /* Call CVodeSensEEtolerances to estimate tolerances for sensitivity 
+   variables based on the rolerances supplied for states variables and 
+   the scaling factor pbar */
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeSensEEtolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSensEEtolerances_x64(
+      IntPtr cvode_mem
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeGetSens", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetSens_x64(
+      IntPtr cvode_mem,
+      ref double tret,
+      IntPtr yS //N_Vector*, one vector for each parameter
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeQuadInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeQuadInit_x64(
+      IntPtr cvode_mem,
+      CVQuadRhsFn qF,
+      IntPtr yQ0 // N_Vector, initial value of yQ
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeQuadInitB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeQuadInitB_x64(
+      IntPtr cvode_mem,
+      int indexB,
+      CVQuadRhsFnB rhsQB,
+      IntPtr yQB0 // N_Vector, initial value of yQB
+    );
+
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeAdjInit", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeAdjInit_x64(
+      IntPtr cvode_mem,
+      int nd,  // integration steps between checkpoints
+      int interpType // either CV_POLYNOMIAL or CV_HERMITE
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeF", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeF_x64(
+        IntPtr cvode_mem,
+        double t_out, // the next time at which a computed solution is desired
+        IntPtr y, // N_Vector, the solution vector y
+        ref double t_ret, // the time reached by the solver (output)
+        int itask, // CV_NORMAL or CV_ONE_STEP
+        ref int ncheck  // the number of internal checkpoints stored so far.
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeGetNumSteps", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetNumSteps_x64(
+      IntPtr cvode_mem,
+      ref long ncheck  // the number of steps taken
+    );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeCreateB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeCreateB_x64(
+        IntPtr cvode_mem,
+        MultistepMethod lmmB,
+        NonlinearSolverIteration iterB,
+        ref int which
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeInitB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeInitB_x64(
+        IntPtr cvode_mem,
+        int which,
+        CVRhsFuncB rightHandSide,
+        double tB0, // endpoint T where final conditions are provided (equal to endpoint of forward integration)
+        IntPtr yB0 // N_Vector inital value at t=tb0 of backward solution
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVode", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVode_x64(
+      IntPtr cvode_mem,
+      double tout, // next time at which a solution is desired
+      IntPtr yout, // N_Vector
+      ref double tret, // the time reached by the solver (output)
+      int itask // flag indicating the job of the solver for the next step. 
+      );
+
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeSStolerancesB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeSStolerancesB_x64(
+      IntPtr cvode_mem,
+      int which,
+      double reltol,
+      double abstol
+    );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVDlsSetLinearSolverB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetLinearSolverB_x64(
+      IntPtr cvode_mem,
+      int which,
+      IntPtr linearSolver, // SUNLinearSolver
+      IntPtr j // SUNMatrix
+    );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVDlsSetJacFnB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVDlsSetJacFnB_x64(
+      IntPtr cvode_mem,
+      int which,
+      CVDlsJacFuncB jacFunc
+    );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeB_x64(
+      IntPtr cvode_mem,
+      double tout, // next time at which a solution is desired
+      int itask // flag indicating the job of the solver for the next step. 
+    );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeGetB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetB_x64(
+          IntPtr cvode_mem,
+          int which,
+          ref double tret,
+          IntPtr yB // the backward solution at time tret
+        );
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeGetAdjY", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetAdjY_x64(
+          IntPtr cvode_mem,
+          double t,
+          IntPtr y // the forward solution y(t)
+        );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeGetAdjCVodeBmem", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern IntPtr CVodeGetAdjCVodeBmem_x64(
+              IntPtr cvode_mem,
+              int which
+            );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeGetQuadB", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int CVodeGetQuadB_x64(
+        IntPtr cvode_mem,
+        int which,
+        ref double tret,
+        IntPtr yQB // N_Vector
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "CVodeFree", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+
+    private static extern int CVodeFree_x64(ref IntPtr cvode_mem);
+
+    #region matrix
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNDenseMatrix", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern IntPtr SUNDenseMatrix_x64(long m, long n);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNMatDestroy", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern void SUNMatDestroy_x64(IntPtr A);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNDenseMatrix_Data", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private unsafe static extern double* SUNDenseMatrix_Data_x64(IntPtr matrix);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNDenseMatrix_Cols", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern long SUNDenseMatrix_Cols_x64(IntPtr matrix);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNDenseMatrix_Rows", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern long SUNDenseMatrix_Rows_x64(IntPtr matrix);
+
+    #endregion
+
+    #region linear solver
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNDenseLinearSolver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern IntPtr SUNDenseLinearSolver_x64(
+      IntPtr y, // N_Vector
+      IntPtr A // SUNMatrix
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNLinSolInitialize", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int SUNLinSolInitialize_x64(IntPtr linearSolver);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNLinSolSetup", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int SUNLinSolSetup_x64(
+      IntPtr linearSolver,
+      IntPtr A // SUNMatrix
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNLinSolSolve", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int SUNLinSolSolve_x64(
+      IntPtr linearSolver,
+      IntPtr A, // SUNMatrix
+      IntPtr x, // N_Vector
+      IntPtr b, // N_Vector
+      double tol
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "SUNLinSolFree", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern int SUNLinSolFree_x64(IntPtr linearSolver);
+
+    #endregion
+
+    #region N_Vector
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VNew_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern IntPtr N_VNew_Serial_x64(long vec_length);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VDestroy_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern void N_VDestroy_Serial_x64(IntPtr vec);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VDestroyVectorArray_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern void N_VDestroyVectorArray_Serial_x64(IntPtr vecArr, int count);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VPrint_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern void N_VPrint_Serial_x64(IntPtr vec);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VConst_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern void N_VConst_Serial_x64(double c, IntPtr vec);
+
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VL1Norm_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern double N_VL1Norm_Serial_x64(IntPtr vec);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VMake_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern IntPtr N_VMake_Serial_x64(long vec_length, double[] v_data);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VScale", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    ///  Performs the operation z = c*x
+    private static extern void N_VScale_x64(double s,
+      IntPtr x, // N_Vector
+      IntPtr z // N_Vector
+      );
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VMake_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private unsafe static extern double* N_VGetArrayPointer_Serial_x64(IntPtr vec);
+
+    [DllImport("sundials_cvodes-x64.dll", EntryPoint = "N_VCloneVectorArray_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
+    private static extern IntPtr N_VCloneVectorArray_Serial_x64(int count, IntPtr vec); // returns N_Vector* !
+    #endregion
+
+    #endregion
   }
 }
Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/HeuristicLab.Problems.DynamicalSystemsModelling-3.3.csproj
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/HeuristicLab.Problems.DynamicalSystemsModelling-3.3.csproj	(revision 16254)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/HeuristicLab.Problems.DynamicalSystemsModelling-3.3.csproj	(revision 16256)
@@ -221,4 +221,7 @@
   </ItemGroup>
   <ItemGroup>
+    <Content Include="sundials_cvodes-x64.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="sundials_cvodes-x86.dll">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
