- Timestamp:
- 10/10/18 11:49:47 (6 years ago)
- Location:
- branches/2925_AutoDiffForDynamicalModels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2925_AutoDiffForDynamicalModels/AutoDiffForDynamicalModelsTest/TestCvodes.cs
r16225 r16226 33 33 int numberOfEquations = 1; 34 34 var y = Problem.N_VNew_Serial(numberOfEquations); 35 Problem.N_VConst_Serial(100.0, y); 35 // y must be initialized before calling CVodeInit 36 // Problem.N_VConst_Serial(100.0, y); 37 Problem.NV_Set_Ith_S(y, 0, 100.0); 36 38 37 39 var cvode_mem = Problem.CVodeCreate(Problem.MultistepMethod.CV_ADAMS, Problem.NonlinearSolverIteration.CV_FUNCTIONAL); … … 85 87 IntPtr user_data) { 86 88 87 Problem.N _VScale(-0.1, y, ydot);89 Problem.NV_Set_Ith_S(ydot, 0, -0.1 * Problem.NV_Get_Ith_S(y, 0)); 88 90 return 0; 89 91 ; -
branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs
r16225 r16226 258 258 [DllImport("sundials_cvodes.dll", EntryPoint = "CVodeSStolerances", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] 259 259 public static extern int CVodeSStolerances( 260 IntPtr cvode_mem, 261 double reltol, 260 IntPtr cvode_mem, 261 double reltol, 262 262 double abstol 263 263 ); … … 272 272 [DllImport("sundials_cvodes.dll", EntryPoint = "CVDlsSetJacFn", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] 273 273 public static extern int CVDlsSetJacFn( 274 IntPtr cvode_mem, 274 IntPtr cvode_mem, 275 275 CVDlsJacFunc jacFunc 276 276 ); … … 309 309 [DllImport("sundials_cvodes.dll", EntryPoint = "SUNLinSolSetup", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] 310 310 public static extern int SUNLinSolSetup( 311 IntPtr linearSolver, 311 IntPtr linearSolver, 312 312 IntPtr A // SUNMatrix 313 313 ); … … 340 340 public static extern void N_VConst_Serial(double c, IntPtr vec); 341 341 342 342 343 343 [DllImport("sundials_cvodes.dll", EntryPoint = "N_VL1Norm_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] 344 344 public static extern double N_VL1Norm_Serial(IntPtr vec); … … 356 356 [DllImport("sundials_cvodes.dll", EntryPoint = "N_VMake_Serial", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] 357 357 public unsafe static extern double* N_VGetArrayPointer_Serial(IntPtr vec); 358 359 /* 360 #define NV_CONTENT_S(v) ( (N_VectorContent_Serial)(v->content) ) 361 362 #define NV_LENGTH_S(v) ( NV_CONTENT_S(v)->length ) 363 364 #define NV_OWN_DATA_S(v) ( NV_CONTENT_S(v)->own_data ) 365 366 #define NV_DATA_S(v) ( NV_CONTENT_S(v)->data ) 367 368 #define NV_Ith_S(v,i) ( NV_DATA_S(v)[i] ) 369 */ 370 // methods for macros 371 public unsafe static int* NV_CONTENT_S(IntPtr v) { 372 int* content = (int*)*(int*)v.ToPointer(); 373 return content; 374 } 375 376 public unsafe static long NV_LENGTH_S(IntPtr v) { 377 long length = *NV_CONTENT_S(v); 378 return length; 379 } 380 public unsafe static bool NV_OWN_DATA_S(IntPtr v) { 381 var content = NV_CONTENT_S(v); 382 int own_data = *(content + 2); 383 return own_data > 0; 384 } 385 public unsafe static double* NV_DATA_S(IntPtr v) { 386 var content = NV_CONTENT_S(v); 387 double* data = (double*)*(content + 3); 388 return data; 389 } 390 public unsafe static double NV_Get_Ith_S(IntPtr v, long i) { 391 return NV_DATA_S(v)[i]; 392 } 393 public unsafe static void NV_Set_Ith_S(IntPtr v, long i, double val) { 394 NV_DATA_S(v)[i] = val; 395 } 358 396 #endregion 359 397
Note: See TracChangeset
for help on using the changeset viewer.