octave-sundials4.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. # HG changeset patch
  2. # User Bill Greene <w.h.greene@gmail.com>
  3. # Date 1550229868 -3600
  4. # Fri Feb 15 12:24:28 2019 +0100
  5. # Node ID 4bf27c090f5695bcf545fc4af15e2a61a3941d46
  6. # Parent f034b29320ad5034ad5c66480f64411e9d773440
  7. Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
  8. * libinterp/dldfcn/__ode15__.cc : use SUNDIALS API version 3.x
  9. diff --git a/libinterp/dldfcn/__ode15__.cc b/libinterp/dldfcn/__ode15__.cc
  10. --- a/libinterp/dldfcn/__ode15__.cc
  11. +++ b/libinterp/dldfcn/__ode15__.cc
  12. @@ -1,6 +1,7 @@
  13. /*
  14. Copyright (C) 2016-2019 Francesco Faccio <francesco.faccio@mail.polimi.it>
  15. +Copyright (C) 2019 William Greene <w.h.greene@gmail.com>
  16. This file is part of Octave.
  17. @@ -112,7 +113,8 @@
  18. havejacsparse (false), mem (nullptr), num (), ida_fun (nullptr),
  19. ida_jac (nullptr), dfdy (nullptr), dfdyp (nullptr), spdfdy (nullptr),
  20. spdfdyp (nullptr), fun (nullptr), jacfun (nullptr), jacspfun (nullptr),
  21. - jacdcell (nullptr), jacspcell (nullptr)
  22. + jacdcell (nullptr), jacspcell (nullptr),
  23. + sunJacMatrix (nullptr), sunLinearSolver (nullptr)
  24. { }
  25. @@ -122,11 +124,17 @@
  26. havejacsparse (false), mem (nullptr), num (), ida_fun (ida_fcn),
  27. ida_jac (nullptr), dfdy (nullptr), dfdyp (nullptr), spdfdy (nullptr),
  28. spdfdyp (nullptr), fun (daefun), jacfun (nullptr), jacspfun (nullptr),
  29. - jacdcell (nullptr), jacspcell (nullptr)
  30. + jacdcell (nullptr), jacspcell (nullptr),
  31. + sunJacMatrix (nullptr), sunLinearSolver (nullptr)
  32. { }
  33. - ~IDA (void) { IDAFree (&mem); }
  34. + ~IDA (void)
  35. + {
  36. + IDAFree (&mem);
  37. + SUNLinSolFree(sunLinearSolver);
  38. + SUNMatDestroy(sunJacMatrix);
  39. + }
  40. IDA&
  41. set_jacobian (octave_function *jac, DAEJacFuncDense j)
  42. @@ -184,7 +192,7 @@
  43. static N_Vector ColToNVec (const ColumnVector& data, long int n);
  44. void
  45. - set_up (void);
  46. + set_up (const ColumnVector& y);
  47. void
  48. set_tolerance (ColumnVector& abstol, realtype reltol);
  49. @@ -199,25 +207,24 @@
  50. void
  51. resfun_impl (realtype t, N_Vector& yy,
  52. N_Vector& yyp, N_Vector& rr);
  53. -
  54. static int
  55. - jacdense (long int Neq, realtype t, realtype cj, N_Vector yy,
  56. - N_Vector yyp, N_Vector, DlsMat JJ, void *user_data,
  57. + jacdense (realtype t, realtype cj, N_Vector yy,
  58. + N_Vector yyp, N_Vector, SUNMatrix JJ, void *user_data,
  59. N_Vector, N_Vector, N_Vector)
  60. {
  61. IDA *self = static_cast <IDA *> (user_data);
  62. - self->jacdense_impl (Neq, t, cj, yy, yyp, JJ);
  63. + self->jacdense_impl (t, cj, yy, yyp, JJ);
  64. return 0;
  65. }
  66. void
  67. - jacdense_impl (long int Neq, realtype t, realtype cj,
  68. - N_Vector& yy, N_Vector& yyp, DlsMat& JJ);
  69. + jacdense_impl (realtype t, realtype cj,
  70. + N_Vector& yy, N_Vector& yyp, SUNMatrix& JJ);
  71. # if defined (HAVE_SUNDIALS_IDAKLU)
  72. static int
  73. jacsparse (realtype t, realtype cj, N_Vector yy, N_Vector yyp,
  74. - N_Vector, SlsMat Jac, void *user_data, N_Vector,
  75. + N_Vector, SUNMatrix Jac, void *user_data, N_Vector,
  76. N_Vector, N_Vector)
  77. {
  78. IDA *self = static_cast <IDA *> (user_data);
  79. @@ -227,7 +234,7 @@
  80. void
  81. jacsparse_impl (realtype t, realtype cj, N_Vector& yy,
  82. - N_Vector& yyp, SlsMat& Jac);
  83. + N_Vector& yyp, SUNMatrix& Jac);
  84. #endif
  85. void set_maxstep (realtype maxstep);
  86. @@ -291,6 +298,8 @@
  87. DAEJacFuncSparse jacspfun;
  88. DAEJacCellDense jacdcell;
  89. DAEJacCellSparse jacspcell;
  90. + SUNMatrix sunJacMatrix;
  91. + SUNLinearSolver sunLinearSolver;
  92. };
  93. int
  94. @@ -323,36 +332,61 @@
  95. }
  96. void
  97. - IDA::set_up (void)
  98. + IDA::set_up (const ColumnVector& y)
  99. {
  100. + N_Vector yy = ColToNVec(y, num);
  101. +
  102. if (havejacsparse)
  103. {
  104. # if defined (HAVE_SUNDIALS_IDAKLU)
  105. - if (IDAKLU (mem, num, num*num, CSC_MAT) != 0)
  106. - error ("IDAKLU solver not initialized");
  107. +
  108. + sunJacMatrix = SUNSparseMatrix (num, num, num*num, CSC_MAT);
  109. + if (! sunJacMatrix)
  110. + error ("Unable to create sparse Jacobian for Sundials");
  111. +
  112. + sunLinearSolver = SUNKLU (yy, sunJacMatrix);
  113. + if (! sunLinearSolver)
  114. + error ("Unable to create KLU sparse solver");
  115. - IDASlsSetSparseJacFn (mem, IDA::jacsparse);
  116. + if (IDADlsSetLinearSolver (mem, sunLinearSolver, sunJacMatrix))
  117. + error ("Unable to set sparse linear solver");
  118. +
  119. + IDADlsSetJacFn (mem, IDA::jacsparse);
  120. +
  121. # else
  122. - error ("IDAKLU is not available in this version of Octave");
  123. + error ("SUNDIALS SUNLINSOL KLU is not available in this version of Octave");
  124. # endif
  125. +
  126. }
  127. else
  128. {
  129. - if (IDADense (mem, num) != 0)
  130. - error ("IDADense solver not initialized");
  131. +
  132. + sunJacMatrix = SUNDenseMatrix (num, num);
  133. + if (! sunJacMatrix)
  134. + error ("Unable to create dense Jacobian for Sundials");
  135. - if (havejac && IDADlsSetDenseJacFn (mem, IDA::jacdense) != 0)
  136. - error ("Dense Jacobian not set");
  137. + sunLinearSolver = SUNDenseLinearSolver (yy, sunJacMatrix);
  138. + if (! sunLinearSolver)
  139. + error ("Unable to create dense linear solver");
  140. +
  141. + if (IDADlsSetLinearSolver (mem, sunLinearSolver, sunJacMatrix))
  142. + error ("Unable to set dense linear solver");
  143. +
  144. + if (havejac && IDADlsSetJacFn (mem, IDA::jacdense) != 0)
  145. + error ("Unable to set dense Jacobian function");
  146. +
  147. }
  148. }
  149. void
  150. - IDA::jacdense_impl (long int Neq, realtype t, realtype cj,
  151. - N_Vector& yy, N_Vector& yyp, DlsMat& JJ)
  152. + IDA::jacdense_impl (realtype t, realtype cj,
  153. + N_Vector& yy, N_Vector& yyp, SUNMatrix& JJ)
  154. {
  155. BEGIN_INTERRUPT_WITH_EXCEPTIONS;
  156. + long int Neq = NV_LENGTH_S(yy);
  157. +
  158. ColumnVector y = NVecToCol (yy, Neq);
  159. ColumnVector yp = NVecToCol (yyp, Neq);
  160. @@ -366,7 +400,7 @@
  161. std::copy (jac.fortran_vec (),
  162. jac.fortran_vec () + jac.numel (),
  163. - JJ->data);
  164. + SUNDenseMatrix_Data(JJ));
  165. END_INTERRUPT_WITH_EXCEPTIONS;
  166. }
  167. @@ -374,7 +408,7 @@
  168. # if defined (HAVE_SUNDIALS_IDAKLU)
  169. void
  170. IDA::jacsparse_impl (realtype t, realtype cj, N_Vector& yy, N_Vector& yyp,
  171. - SlsMat& Jac)
  172. + SUNMatrix& Jac)
  173. {
  174. BEGIN_INTERRUPT_WITH_EXCEPTIONS;
  175. @@ -390,17 +424,18 @@
  176. else
  177. jac = (*jacspcell) (spdfdy, spdfdyp, cj);
  178. - SparseSetMatToZero (Jac);
  179. - int *colptrs = *(Jac->colptrs);
  180. - int *rowvals = *(Jac->rowvals);
  181. + SUNMatZero_Sparse (Jac);
  182. + octave_idx_type *colptrs = SUNSparseMatrix_IndexPointers (Jac);
  183. + octave_idx_type *rowvals = SUNSparseMatrix_IndexValues (Jac);
  184. for (int i = 0; i < num + 1; i++)
  185. colptrs[i] = jac.cidx(i);
  186. + double *d = SUNSparseMatrix_Data (Jac);
  187. for (int i = 0; i < jac.nnz (); i++)
  188. {
  189. rowvals[i] = jac.ridx(i);
  190. - Jac->data[i] = jac.data(i);
  191. + d[i] = jac.data(i);
  192. }
  193. END_INTERRUPT_WITH_EXCEPTIONS;
  194. @@ -567,7 +602,7 @@
  195. //main loop
  196. while (((posdirection == 1 && tsol < tend)
  197. - || (posdirection == 0 && tsol > tend))
  198. + || (posdirection == 0 && tsol > tend))
  199. && status == 0)
  200. {
  201. if (IDASolve (mem, tend, &tsol, yy, yyp, IDA_ONE_STEP) != 0)
  202. @@ -692,7 +727,7 @@
  203. // Linear interpolation
  204. ie(0) = index(0);
  205. te(0) = tsol - val (index(0)) * (tsol - told)
  206. - / (val (index(0)) - oldval (index(0)));
  207. + / (val (index(0)) - oldval (index(0)));
  208. ColumnVector ytemp
  209. = y - ((tsol - te(0)) * (y - yold) / (tsol - told));
  210. @@ -717,7 +752,7 @@
  211. // Linear interpolation
  212. ie(temp+i) = index(i);
  213. te(temp+i) = tsol - val(index(i)) * (tsol - told)
  214. - / (val(index(i)) - oldval(index(i)));
  215. + / (val(index(i)) - oldval(index(i)));
  216. ColumnVector ytemp
  217. = y - (tsol - te (temp + i)) * (y - yold) / (tsol - told);
  218. @@ -1096,7 +1131,7 @@
  219. event_fcn = options.getfield("Events").function_value ();
  220. // Set up linear solver
  221. - dae.set_up ();
  222. + dae.set_up (y0);
  223. // Integrate
  224. retval = dae.integrate (numt, tspan, y0, yp0, refine,
  225. # HG changeset patch
  226. # User Carlo de Falco <carlo.defalco@polimi.it>
  227. # Date 1550230515 -3600
  228. # Fri Feb 15 12:35:15 2019 +0100
  229. # Node ID 9b27b77d2fec1a334baa7f4b2ec70751f4bf2b99
  230. # Parent 4bf27c090f5695bcf545fc4af15e2a61a3941d46
  231. Update detection of sundials in the build system (bug #52475).
  232. * m4/acnclude.m4 : check for sunlinsol_klu.h and sunlinsol_dense.h
  233. * configure.ac : update check for sundials features
  234. * script/ode/ode15i.m : update conditionals in tests
  235. * script/ode/ode15s.m : update conditionals in tests
  236. * libinterp/dldfcn/__ode15__.cc : udate conditionals in preprocessor directives
  237. diff --git a/configure.ac b/configure.ac
  238. --- a/configure.ac
  239. +++ b/configure.ac
  240. @@ -2206,15 +2206,15 @@
  241. [], [don't use SUNDIALS IDA library, solvers ode15i and ode15s will be disabled],
  242. [warn_sundials_ida=
  243. OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE
  244. - OCTAVE_CHECK_SUNDIALS_IDA_DENSE
  245. - OCTAVE_CHECK_SUNDIALS_IDAKLU])
  246. + OCTAVE_CHECK_SUNDIALS_SUNLINSOL_DENSE
  247. + OCTAVE_CHECK_SUNDIALS_SUNLINSOL_KLU])
  248. LIBS="$save_LIBS"
  249. dnl Define this way instead of with an #if in oct-conf-post.h so that
  250. dnl the build features script will get the correct value.
  251. if test -n "$SUNDIALS_IDA_LIBS" \
  252. && test -n "$SUNDIALS_NVECSERIAL_LIBS" \
  253. - && test $octave_cv_sundials_ida_dense = yes \
  254. + && test $octave_cv_sundials_sunlinsol_dense = yes \
  255. && test $octave_cv_sundials_realtype_is_double = yes; then
  256. AC_DEFINE(HAVE_SUNDIALS, 1, [Define to 1 if SUNDIALS is available.])
  257. fi
  258. diff --git a/libinterp/dldfcn/__ode15__.cc b/libinterp/dldfcn/__ode15__.cc
  259. --- a/libinterp/dldfcn/__ode15__.cc
  260. +++ b/libinterp/dldfcn/__ode15__.cc
  261. @@ -45,15 +45,31 @@
  262. # include <ida/ida.h>
  263. # endif
  264. -# if defined (HAVE_IDA_IDA_DENSE_H)
  265. -# include <ida/ida_dense.h>
  266. +# if defined (HAVE_SUNDIALS_SUNDIALS_MATRIX_H)
  267. +# include <sundials/sundials_matrix.h>
  268. +# endif
  269. +
  270. +# if defined (HAVE_SUNDIALS_SUNDIALS_LINEARSOLVER_H)
  271. +# include <sundials/sundials_linearsolver.h>
  272. +# endif
  273. +
  274. +# if defined (HAVE_SUNLINSOL_SUNLINSOL_DENSE_H)
  275. +# include <sunlinsol/sunlinsol_dense.h>
  276. # endif
  277. -# if defined (HAVE_IDA_IDA_KLU_H)
  278. -# include <ida/ida_klu.h>
  279. +# if defined (HAVE_IDA_IDA_DIRECT_H)
  280. +# include <ida/ida_direct.h>
  281. +# endif
  282. +
  283. +# if defined (HAVE_SUNDIALS_SUNDIALS_SPARSE_H)
  284. # include <sundials/sundials_sparse.h>
  285. # endif
  286. +
  287. +# if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H)
  288. +# include <sunlinsol/sunlinsol_klu.h>
  289. +# endif
  290. +
  291. # if defined (HAVE_NVECTOR_NVECTOR_SERIAL_H)
  292. # include <nvector/nvector_serial.h>
  293. # endif
  294. @@ -221,7 +237,7 @@
  295. jacdense_impl (realtype t, realtype cj,
  296. N_Vector& yy, N_Vector& yyp, SUNMatrix& JJ);
  297. -# if defined (HAVE_SUNDIALS_IDAKLU)
  298. +# if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
  299. static int
  300. jacsparse (realtype t, realtype cj, N_Vector yy, N_Vector yyp,
  301. N_Vector, SUNMatrix Jac, void *user_data, N_Vector,
  302. @@ -338,7 +354,7 @@
  303. if (havejacsparse)
  304. {
  305. -# if defined (HAVE_SUNDIALS_IDAKLU)
  306. +#if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
  307. sunJacMatrix = SUNSparseMatrix (num, num, num*num, CSC_MAT);
  308. if (! sunJacMatrix)
  309. @@ -405,7 +421,7 @@
  310. END_INTERRUPT_WITH_EXCEPTIONS;
  311. }
  312. -# if defined (HAVE_SUNDIALS_IDAKLU)
  313. +# if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
  314. void
  315. IDA::jacsparse_impl (realtype t, realtype cj, N_Vector& yy, N_Vector& yyp,
  316. SUNMatrix& Jac)
  317. diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
  318. --- a/m4/acinclude.m4
  319. +++ b/m4/acinclude.m4
  320. @@ -2210,14 +2210,11 @@
  321. dnl precision realtype.
  322. dnl
  323. AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE], [
  324. - AC_CHECK_HEADERS([ida/ida.h ida.h])
  325. AC_CACHE_CHECK([whether SUNDIALS IDA is configured with double precision realtype],
  326. [octave_cv_sundials_realtype_is_double],
  327. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  328. #if defined (HAVE_IDA_IDA_H)
  329. #include <ida/ida.h>
  330. - #else
  331. - #include <ida.h>
  332. #endif
  333. #include <assert.h>
  334. ]], [[
  335. @@ -2233,61 +2230,72 @@
  336. fi
  337. ])
  338. dnl
  339. -dnl Check whether SUNDIALS IDA library is configured with IDAKLU
  340. +dnl Check whether SUNDIALS IDA library is configured with SUNLINSOL_KLU
  341. dnl enabled.
  342. dnl
  343. -AC_DEFUN([OCTAVE_CHECK_SUNDIALS_IDAKLU], [
  344. - AC_CHECK_HEADERS([ida/ida_klu.h ida_klu.h])
  345. - AC_CACHE_CHECK([whether SUNDIALS IDA is configured with IDAKLU enabled],
  346. - [octave_cv_sundials_idaklu],
  347. +AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNLINSOL_KLU], [
  348. + AC_CHECK_HEADERS([sundials/sundials_sparse.h sunlinsol/sunlinsol_klu.h])
  349. + AC_CACHE_CHECK([whether SUNDIALS IDA is configured with SUNLINSOL_KLU enabled],
  350. + [octave_cv_sundials_sunlinsol_klu],
  351. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  352. - #if defined (HAVE_IDA_IDA_KLU_H)
  353. - #include <ida/ida_klu.h>
  354. - #else
  355. - #include <ida_klu.h>
  356. + #if defined (HAVE_IDA_IDA_H)
  357. + #include <ida/ida.h>
  358. + #endif
  359. + #if defined (HAVE_SUNDIALS_SUNDIALS_SPARSE_H)
  360. + #include <sundials/sundials_sparse.h>
  361. + #endif
  362. + #if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H)
  363. + #include <sunlinsol/sunlinsol_klu.h>
  364. #endif
  365. ]], [[
  366. - IDAKLU (0, 0, 0, 0);
  367. + SUNKLU (0, 0);
  368. ]])],
  369. - octave_cv_sundials_idaklu=yes,
  370. - octave_cv_sundials_idaklu=no)
  371. + octave_cv_sundials_sunlinsol_klu=yes,
  372. + octave_cv_sundials_sunlinsol_klu=no)
  373. ])
  374. - if test $octave_cv_sundials_idaklu = yes; then
  375. - AC_DEFINE(HAVE_SUNDIALS_IDAKLU, 1,
  376. - [Define to 1 if SUNDIALS IDA is configured with IDAKLU enabled.])
  377. + if test $octave_cv_sundials_sunlinsol_klu = yes; then
  378. + AC_DEFINE(HAVE_SUNDIALS_SUNLINSOL_KLU, 1,
  379. + [Define to 1 if SUNDIALS IDA is configured with SUNLINSOL_KLU enabled.])
  380. else
  381. - warn_sundials_idaklu="SUNDIALS IDA library not configured with IDAKLU, ode15i and ode15s will not support the sparse Jacobian feature"
  382. - OCTAVE_CONFIGURE_WARNING([warn_sundials_idaklu])
  383. + warn_sundials_idaklu="SUNDIALS IDA library not configured with SUNLINSOL_KLU, ode15i and ode15s will not support the sparse Jacobian feature"
  384. + OCTAVE_CONFIGURE_WARNING([warn_sundials_sunlinsol_klu])
  385. fi
  386. ])
  387. dnl
  388. -dnl Check whether SUNDIALS IDA library has the IDADENSE linear solver.
  389. +dnl Check whether SUNDIALS IDA library has the SUNLINSOL_DENSE linear solver.
  390. dnl The IDADENSE API was removed in SUNDIALS version 3.0.0.
  391. dnl
  392. -AC_DEFUN([OCTAVE_CHECK_SUNDIALS_IDA_DENSE], [
  393. - AC_CHECK_HEADERS([ida/ida_dense.h ida_dense.h])
  394. - AC_CACHE_CHECK([whether SUNDIALS IDA includes the IDADENSE linear solver],
  395. - [octave_cv_sundials_ida_dense],
  396. +AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNLINSOL_DENSE], [
  397. + AC_CHECK_HEADERS([sunlinsol/sunlinsol_dense.h sundials/sundials_matrix.h sundials/sundials_linearsolver.h ida/ida_direct.h])
  398. + AC_CACHE_CHECK([whether SUNDIALS IDA includes the SUNLINSOL_DENSE linear solver],
  399. + [octave_cv_sundials_sunlinsol_dense],
  400. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  401. - #if defined (HAVE_IDA_IDA_DENSE_H)
  402. - #include <ida/ida_dense.h>
  403. - #else
  404. - #include <ida_dense.h>
  405. + #if defined (HAVE_IDA_IDA_H)
  406. + #include <ida/ida.h>
  407. + #endif
  408. + #if defined (HAVE_SUNDIALS_SUNDIALS_MATRIX_H)
  409. + #include <sundials/sundials_matrix.h>
  410. #endif
  411. + #if defined (HAVE_SUNDIALS_SUNDIALS_LINEARSOLVER_H)
  412. + #include <sundials/sundials_linearsolver.h>
  413. + #endif
  414. + #if defined (HAVE_IDA_IDA_DIRECT_H)
  415. + #include <ida/ida_direct.h>
  416. + #endif
  417. ]], [[
  418. void *mem = 0;
  419. long int num = 0;
  420. IDADense (mem, num);
  421. ]])],
  422. - octave_cv_sundials_ida_dense=yes,
  423. - octave_cv_sundials_ida_dense=no)
  424. + octave_cv_sundials_sunlinsol_dense=yes,
  425. + octave_cv_sundials_sunlinsol_dense=no)
  426. ])
  427. - if test $octave_cv_sundials_ida_dense = yes; then
  428. - AC_DEFINE(HAVE_SUNDIALS_IDADENSE, 1,
  429. - [Define to 1 if SUNDIALS IDA includes the IDADENSE linear solver.])
  430. + if test $octave_cv_sundials_sunlinsol_dense = yes; then
  431. + AC_DEFINE(HAVE_SUNDIALS_SUNLINSOL_DENSE, 1,
  432. + [Define to 1 if SUNDIALS IDA includes the SUNLINSOL_DENSE linear solver.])
  433. else
  434. - warn_sundials_ida_dense="SUNDIALS IDA library does not include the IDADENSE linear solver, ode15i and ode15s will be disabled"
  435. - OCTAVE_CONFIGURE_WARNING([warn_sundials_ida_dense])
  436. + warn_sundials_ida_dense="SUNDIALS IDA library does not include the SUNLINSOL_DENSE linear solver, ode15i and ode15s will be disabled"
  437. + OCTAVE_CONFIGURE_WARNING([warn_sundials_sunlinsol_dense])
  438. fi
  439. ])
  440. dnl
  441. diff --git a/scripts/ode/ode15i.m b/scripts/ode/ode15i.m
  442. --- a/scripts/ode/ode15i.m
  443. +++ b/scripts/ode/ode15i.m
  444. @@ -452,7 +452,7 @@
  445. %! assert ([t(end), y(end,:)], fref, 1e-3);
  446. ## Jacobian fun sparse
  447. -%!testif HAVE_SUNDIALS_IDAKLU
  448. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  449. %! opt = odeset ("Jacobian", @jacfunsparse, "AbsTol", 1e-7, "RelTol", 1e-7);
  450. %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt);
  451. %! assert ([t(end), y(end,:)], fref, 1e-3);
  452. @@ -545,7 +545,7 @@
  453. %! "invalid value assigned to field 'Jacobian'");
  454. ## Jacobian cell sparse wrong dimension
  455. -%!testif HAVE_SUNDIALS_IDAKLU
  456. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  457. %! DFDY = sparse ([-0.04, 1;
  458. %! 0.04, 1]);
  459. %! DFDYP = sparse ([-1, 0, 0;
  460. diff --git a/scripts/ode/ode15s.m b/scripts/ode/ode15s.m
  461. --- a/scripts/ode/ode15s.m
  462. +++ b/scripts/ode/ode15s.m
  463. @@ -545,21 +545,21 @@
  464. %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt);
  465. %! assert ([t(end), y(end,:)], frefrob, 1e-3);
  466. -%!testif HAVE_SUNDIALS_IDAKLU
  467. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  468. %! opt = odeset ("MStateDependence", "none",
  469. %! "Mass", [1, 0, 0; 0, 1, 0; 0, 0, 0],
  470. %! "Jacobian", @jacfunsparse);
  471. %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt);
  472. %! assert ([t(end), y(end,:)], frefrob, 1e-3);
  473. -%!testif HAVE_SUNDIALS_IDAKLU
  474. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  475. %! opt = odeset ("MStateDependence", "none",
  476. %! "Mass", sparse ([1, 0, 0; 0, 1, 0; 0, 0, 0]),
  477. %! "Jacobian", @jacfunsparse);
  478. %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt);
  479. %! assert ([t(end), y(end,:)], frefrob, 1e-3);
  480. -%!testif HAVE_SUNDIALS_IDAKLU
  481. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  482. %! warning ("off", "ode15s:mass_state_dependent_provided", "local");
  483. %! opt = odeset ("MStateDependence", "none",
  484. %! "Mass", @massdensefunstate,
  485. @@ -575,14 +575,14 @@
  486. %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt);
  487. %! assert ([t(end), y(end,:)], frefrob, 1e-3);
  488. -%!testif HAVE_SUNDIALS_IDAKLU
  489. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  490. %! opt = odeset ("MStateDependence", "none",
  491. %! "Mass", @massdensefuntime,
  492. %! "Jacobian", @jacfunsparse);
  493. %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt);
  494. %! assert ([t(end), y(end,:)], frefrob, 1e-3);
  495. -%!testif HAVE_SUNDIALS_IDAKLU
  496. +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU
  497. %! opt = odeset ("MStateDependence", "none",
  498. %! "Mass", @masssparsefuntime,
  499. %! "Jacobian", @jacfunsparse);
  500. # HG changeset patch
  501. # Parent 6ef7a85c3b1908f57665a08d1d7205c15018c2af
  502. diff --git a/libinterp/dldfcn/__ode15__.cc b/libinterp/dldfcn/__ode15__.cc
  503. --- a/libinterp/dldfcn/__ode15__.cc
  504. +++ b/libinterp/dldfcn/__ode15__.cc
  505. @@ -67,6 +67,18 @@
  506. # if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H)
  507. +# if defined (HAVE_KLU_H)
  508. +# include <klu.h>
  509. +# endif
  510. +# if defined (HAVE_KLU_KLU_H)
  511. +# include <klu/klu.h>
  512. +# endif
  513. +# if defined (HAVE_SUITESPARSE_KLU_H)
  514. +# include <suitesparse/klu.h>
  515. +# endif
  516. +# if defined (HAVE_UFPARSE_KLU_H)
  517. +# include <ufsparse/klu.h>
  518. +# endif
  519. # include <sunlinsol/sunlinsol_klu.h>
  520. # endif
  521. diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
  522. --- a/m4/acinclude.m4
  523. +++ b/m4/acinclude.m4
  524. @@ -2244,6 +2244,18 @@
  525. #if defined (HAVE_SUNDIALS_SUNDIALS_SPARSE_H)
  526. #include <sundials/sundials_sparse.h>
  527. #endif
  528. + #if defined (HAVE_KLU_H)
  529. + #include <klu.h>
  530. + #endif
  531. + #if defined (HAVE_KLU_KLU_H)
  532. + #include <klu/klu.h>
  533. + #endif
  534. + #if defined (HAVE_SUITESPARSE_KLU_H)
  535. + #include <suitesparse/klu.h>
  536. + #endif
  537. + #if defined (HAVE_UFPARSE_KLU_H)
  538. + #include <ufsparse/klu.h>
  539. + #endif
  540. #if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H)
  541. #include <sunlinsol/sunlinsol_klu.h>
  542. #endif