casadi 3.6.2__cp311-none-manylinux2014_i686.whl → 3.6.4__cp311-none-manylinux2014_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. casadi/_casadi.so +0 -0
  2. casadi/casadi.py +217 -60
  3. casadi/cbc +0 -0
  4. casadi/clp +0 -0
  5. casadi/cmake/alpaqa/alpaqaConfig.cmake +24 -0
  6. casadi/cmake/alpaqa/alpaqaConfigVersion.cmake +70 -0
  7. casadi/cmake/alpaqa/alpaqaTargets-release.cmake +29 -0
  8. casadi/cmake/alpaqa/alpaqaTargets.cmake +131 -0
  9. casadi/cmake/casadi-config-version.cmake +1 -1
  10. casadi/cmake/casadi-config.cmake +4 -0
  11. casadi/cmake/highs/highs-config.cmake +18 -4
  12. casadi/cmake/highs/highs-targets-release.cmake +3 -3
  13. casadi/cmake/highs/highs-targets.cmake +1 -1
  14. casadi/cmake/sleqp/sleqp-config-version.cmake +70 -0
  15. casadi/cmake/sleqp/sleqp-config.cmake +1 -0
  16. casadi/cmake/sleqp/sleqp-targets-release.cmake +20 -0
  17. casadi/cmake/sleqp/sleqp-targets.cmake +102 -0
  18. casadi/cmake/trlib/trlib-config-release.cmake +19 -0
  19. casadi/cmake/trlib/trlib-config-version.cmake +88 -0
  20. casadi/cmake/trlib/trlib-config.cmake +107 -0
  21. casadi/highs +0 -0
  22. casadi/include/casadi/casadi.i +20 -3
  23. casadi/include/casadi/config.h +8 -8
  24. casadi/include/casadi/core/calculus.hpp +1 -1
  25. casadi/include/casadi/core/code_generator.hpp +10 -0
  26. casadi/include/casadi/core/fmu.hpp +224 -0
  27. casadi/include/casadi/core/generic_matrix.hpp +4 -2
  28. casadi/include/casadi/core/nlpsol.hpp +0 -2
  29. casadi/include/casadi/core/runtime/casadi_finite_diff.hpp +204 -11
  30. casadi/include/casadi/core/serializing_stream.hpp +12 -0
  31. casadi/include/casadi/core/sparsity_interface.hpp +55 -1
  32. casadi/include/casadi/doc.i +916 -462
  33. casadi/include/casadi/doc_merged.i +492 -176
  34. casadi/include/casadi/mem.h +13 -2
  35. casadi/include/casadi/valgrind-casadi.supp +82 -0
  36. casadi/include/casadi/valgrind-python.supp +39 -0
  37. casadi/include/highs/HConfig.h +4 -7
  38. casadi/include/highs/Highs.h +240 -51
  39. casadi/include/highs/filereaderlp/builder.hpp +12 -13
  40. casadi/include/highs/filereaderlp/model.hpp +32 -35
  41. casadi/include/highs/fortran/highs_fortran_api.mod +0 -0
  42. casadi/include/highs/interfaces/highs_c_api.h +964 -577
  43. casadi/include/highs/io/Filereader.h +2 -4
  44. casadi/include/highs/io/FilereaderEms.h +2 -4
  45. casadi/include/highs/io/FilereaderLp.h +2 -4
  46. casadi/include/highs/io/FilereaderMps.h +2 -4
  47. casadi/include/highs/io/HMPSIO.h +2 -4
  48. casadi/include/highs/io/HMpsFF.h +2 -4
  49. casadi/include/highs/io/HighsIO.h +19 -13
  50. casadi/include/highs/io/LoadOptions.h +7 -6
  51. casadi/include/highs/ipm/IpxWrapper.h +4 -5
  52. casadi/include/highs/lp_data/HConst.h +60 -15
  53. casadi/include/highs/lp_data/HStruct.h +32 -8
  54. casadi/include/highs/lp_data/HighsAnalysis.h +2 -4
  55. casadi/include/highs/lp_data/HighsCallback.h +33 -0
  56. casadi/include/highs/lp_data/HighsCallbackStruct.h +36 -0
  57. casadi/include/highs/lp_data/HighsDebug.h +2 -4
  58. casadi/include/highs/lp_data/HighsInfo.h +22 -23
  59. casadi/include/highs/lp_data/HighsInfoDebug.h +2 -4
  60. casadi/include/highs/lp_data/HighsLp.h +14 -6
  61. casadi/include/highs/lp_data/HighsLpSolverObject.h +6 -5
  62. casadi/include/highs/lp_data/HighsLpUtils.h +23 -12
  63. casadi/include/highs/lp_data/HighsModelUtils.h +22 -8
  64. casadi/include/highs/lp_data/HighsOptions.h +175 -106
  65. casadi/include/highs/lp_data/HighsRanging.h +2 -4
  66. casadi/include/highs/lp_data/HighsRuntimeOptions.h +21 -6
  67. casadi/include/highs/lp_data/HighsSolution.h +4 -4
  68. casadi/include/highs/lp_data/HighsSolutionDebug.h +2 -4
  69. casadi/include/highs/lp_data/HighsSolve.h +2 -4
  70. casadi/include/highs/lp_data/HighsStatus.h +2 -4
  71. casadi/include/highs/mip/HighsCliqueTable.h +18 -20
  72. casadi/include/highs/mip/HighsConflictPool.h +2 -4
  73. casadi/include/highs/mip/HighsCutGeneration.h +2 -4
  74. casadi/include/highs/mip/HighsCutPool.h +2 -4
  75. casadi/include/highs/mip/HighsDebugSol.h +2 -4
  76. casadi/include/highs/mip/HighsDomain.h +5 -5
  77. casadi/include/highs/mip/HighsDomainChange.h +2 -4
  78. casadi/include/highs/mip/HighsDynamicRowMatrix.h +2 -4
  79. casadi/include/highs/mip/HighsGFkSolve.h +2 -4
  80. casadi/include/highs/mip/HighsImplications.h +2 -4
  81. casadi/include/highs/mip/HighsLpAggregator.h +2 -4
  82. casadi/include/highs/mip/HighsLpRelaxation.h +2 -4
  83. casadi/include/highs/mip/HighsMipSolver.h +18 -6
  84. casadi/include/highs/mip/HighsMipSolverData.h +8 -4
  85. casadi/include/highs/mip/HighsModkSeparator.h +2 -4
  86. casadi/include/highs/mip/HighsNodeQueue.h +3 -9
  87. casadi/include/highs/mip/HighsObjectiveFunction.h +2 -4
  88. casadi/include/highs/mip/HighsPathSeparator.h +2 -4
  89. casadi/include/highs/mip/HighsPrimalHeuristics.h +2 -4
  90. casadi/include/highs/mip/HighsPseudocost.h +2 -4
  91. casadi/include/highs/mip/HighsRedcostFixing.h +2 -4
  92. casadi/include/highs/mip/HighsSearch.h +2 -4
  93. casadi/include/highs/mip/HighsSeparation.h +2 -4
  94. casadi/include/highs/mip/HighsSeparator.h +2 -4
  95. casadi/include/highs/mip/HighsTableauSeparator.h +2 -4
  96. casadi/include/highs/mip/HighsTransformedLp.h +2 -4
  97. casadi/include/highs/model/HighsHessian.h +3 -1
  98. casadi/include/highs/model/HighsModel.h +2 -0
  99. casadi/include/highs/parallel/HighsSpinMutex.h +2 -1
  100. casadi/include/highs/parallel/HighsSplitDeque.h +1 -1
  101. casadi/include/highs/parallel/HighsTaskExecutor.h +10 -2
  102. casadi/include/highs/presolve/HPresolve.h +9 -6
  103. casadi/include/highs/presolve/HPresolveAnalysis.h +5 -4
  104. casadi/include/highs/presolve/HighsPostsolveStack.h +50 -13
  105. casadi/include/highs/presolve/HighsSymmetry.h +2 -4
  106. casadi/include/highs/presolve/ICrash.h +4 -3
  107. casadi/include/highs/presolve/ICrashUtil.h +2 -2
  108. casadi/include/highs/presolve/ICrashX.h +4 -6
  109. casadi/include/highs/presolve/PresolveComponent.h +4 -42
  110. casadi/include/highs/qpsolver/a_asm.hpp +56 -0
  111. casadi/include/highs/qpsolver/a_quass.hpp +12 -0
  112. casadi/include/highs/qpsolver/quass.hpp +1 -4
  113. casadi/include/highs/simplex/HApp.h +14 -16
  114. casadi/include/highs/simplex/HEkk.h +12 -11
  115. casadi/include/highs/simplex/HEkkDual.h +2 -4
  116. casadi/include/highs/simplex/HEkkDualRHS.h +5 -6
  117. casadi/include/highs/simplex/HEkkDualRow.h +2 -4
  118. casadi/include/highs/simplex/HEkkPrimal.h +2 -4
  119. casadi/include/highs/simplex/HSimplex.h +2 -4
  120. casadi/include/highs/simplex/HSimplexDebug.h +2 -4
  121. casadi/include/highs/simplex/HSimplexNla.h +2 -4
  122. casadi/include/highs/simplex/HSimplexReport.h +3 -5
  123. casadi/include/highs/simplex/HighsSimplexAnalysis.h +2 -4
  124. casadi/include/highs/simplex/SimplexConst.h +7 -5
  125. casadi/include/highs/simplex/SimplexStruct.h +11 -5
  126. casadi/include/highs/simplex/SimplexTimer.h +2 -4
  127. casadi/include/highs/test/DevKkt.h +2 -4
  128. casadi/include/highs/test/KktCh2.h +2 -4
  129. casadi/include/highs/util/FactorTimer.h +2 -4
  130. casadi/include/highs/util/HFactor.h +2 -4
  131. casadi/include/highs/util/HFactorConst.h +2 -4
  132. casadi/include/highs/util/HFactorDebug.h +2 -4
  133. casadi/include/highs/util/HSet.h +3 -5
  134. casadi/include/highs/util/HVector.h +2 -4
  135. casadi/include/highs/util/HVectorBase.h +2 -4
  136. casadi/include/highs/util/HighsCDouble.h +2 -4
  137. casadi/include/highs/util/HighsComponent.h +2 -4
  138. casadi/include/highs/util/HighsDataStack.h +3 -5
  139. casadi/include/highs/util/HighsDisjointSets.h +8 -10
  140. casadi/include/highs/util/HighsHash.h +22 -7
  141. casadi/include/highs/util/HighsHashTree.h +25 -7
  142. casadi/include/highs/util/HighsInt.h +2 -4
  143. casadi/include/highs/util/HighsIntegers.h +2 -4
  144. casadi/include/highs/util/HighsLinearSumBounds.h +2 -4
  145. casadi/include/highs/util/HighsMatrixPic.h +2 -4
  146. casadi/include/highs/util/HighsMatrixSlice.h +2 -4
  147. casadi/include/highs/util/HighsMatrixUtils.h +2 -4
  148. casadi/include/highs/util/HighsRandom.h +2 -4
  149. casadi/include/highs/util/HighsRbTree.h +2 -4
  150. casadi/include/highs/util/HighsSort.h +2 -4
  151. casadi/include/highs/util/HighsSparseMatrix.h +11 -7
  152. casadi/include/highs/util/HighsSparseVectorSum.h +2 -4
  153. casadi/include/highs/util/HighsSplay.h +2 -4
  154. casadi/include/highs/util/HighsTimer.h +3 -4
  155. casadi/include/highs/util/HighsUtils.h +14 -4
  156. casadi/include/highs/util/stringutil.h +2 -4
  157. casadi/include/licenses/alpaqa-external/LICENSE +165 -0
  158. casadi/include/licenses/highs-external/LICENSE +1 -1
  159. casadi/include/licenses/sleqp-external/LICENSE +165 -0
  160. casadi/include/licenses/trlib-external/LICENSE +21 -0
  161. casadi/include/trlib/trlib_eigen_inverse.h +118 -0
  162. casadi/include/trlib/trlib_krylov.h +493 -0
  163. casadi/include/trlib/trlib_leftmost.h +181 -0
  164. casadi/include/trlib/trlib_private.h +109 -0
  165. casadi/include/trlib/trlib_quadratic_zero.h +57 -0
  166. casadi/include/trlib/trlib_tri_factor.h +409 -0
  167. casadi/include/trlib/trlib_types.h +36 -0
  168. casadi/lib/libtinyxml2.a +0 -0
  169. casadi/libCbc.la +3 -3
  170. casadi/libCbc.so +0 -0
  171. casadi/libCbc.so.3 +0 -0
  172. casadi/libCbc.so.3.10.11 +0 -0
  173. casadi/libCbcSolver.la +3 -3
  174. casadi/libCbcSolver.so +0 -0
  175. casadi/libCbcSolver.so.3 +0 -0
  176. casadi/libCbcSolver.so.3.10.11 +0 -0
  177. casadi/libCgl.la +2 -2
  178. casadi/libCgl.so +0 -0
  179. casadi/libCgl.so.1 +0 -0
  180. casadi/libCgl.so.1.10.8 +0 -0
  181. casadi/libClp.la +2 -2
  182. casadi/libClp.so +0 -0
  183. casadi/libClp.so.1 +0 -0
  184. casadi/{libClp.so.1.14.7 → libClp.so.1.14.9} +0 -0
  185. casadi/libClpSolver.la +2 -2
  186. casadi/libClpSolver.so +0 -0
  187. casadi/libClpSolver.so.1 +0 -0
  188. casadi/{libClpSolver.so.1.14.7 → libClpSolver.so.1.14.9} +0 -0
  189. casadi/libCoinUtils.la +2 -2
  190. casadi/libCoinUtils.so +0 -0
  191. casadi/libCoinUtils.so.3 +0 -0
  192. casadi/libCoinUtils.so.3.11.10 +0 -0
  193. casadi/libFortranHighs.so +0 -0
  194. casadi/libOsi.la +2 -2
  195. casadi/libOsiCbc.la +3 -3
  196. casadi/libOsiCbc.so +0 -0
  197. casadi/libOsiCbc.so.3 +0 -0
  198. casadi/{libOsiCbc.so.3.10.6 → libOsiCbc.so.3.10.11} +0 -0
  199. casadi/libOsiClp.la +2 -2
  200. casadi/libOsiClp.so +0 -0
  201. casadi/libOsiClp.so.1 +0 -0
  202. casadi/libOsiClp.so.1.14.9 +0 -0
  203. casadi/libOsiCommonTests.la +2 -2
  204. casadi/libOsiCommonTests.so +0 -0
  205. casadi/libOsiCommonTests.so.1 +0 -0
  206. casadi/{libOsiCommonTests.so.1.13.7 → libOsiCommonTests.so.1.13.9} +0 -0
  207. casadi/libalpaqa-dl-loader.so +0 -0
  208. casadi/libalpaqa-dl-loader.so.1.0.0 +0 -0
  209. casadi/libalpaqa.so +0 -0
  210. casadi/libalpaqa.so.1.0.0 +0 -0
  211. casadi/libbonmin.la +3 -3
  212. casadi/libbonmin.so +0 -0
  213. casadi/libbonmin.so.4 +0 -0
  214. casadi/libbonmin.so.4.8.9 +0 -0
  215. casadi/libcasadi.so +0 -0
  216. casadi/libcasadi.so.3.7 +0 -0
  217. casadi/libcasadi_conic_cbc.so +0 -0
  218. casadi/libcasadi_conic_cbc.so.3.7 +0 -0
  219. casadi/libcasadi_conic_clp.so +0 -0
  220. casadi/libcasadi_conic_clp.so.3.7 +0 -0
  221. casadi/libcasadi_conic_gurobi.so +0 -0
  222. casadi/libcasadi_conic_gurobi.so.3.7 +0 -0
  223. casadi/libcasadi_conic_highs.so +0 -0
  224. casadi/libcasadi_conic_highs.so.3.7 +0 -0
  225. casadi/libcasadi_conic_ipqp.so +0 -0
  226. casadi/libcasadi_conic_ipqp.so.3.7 +0 -0
  227. casadi/libcasadi_conic_nlpsol.so +0 -0
  228. casadi/libcasadi_conic_nlpsol.so.3.7 +0 -0
  229. casadi/libcasadi_conic_osqp.so +0 -0
  230. casadi/libcasadi_conic_osqp.so.3.7 +0 -0
  231. casadi/libcasadi_conic_proxqp.so +0 -0
  232. casadi/libcasadi_conic_proxqp.so.3.7 +0 -0
  233. casadi/libcasadi_conic_qpoases.so +0 -0
  234. casadi/libcasadi_conic_qpoases.so.3.7 +0 -0
  235. casadi/libcasadi_conic_qrqp.so +0 -0
  236. casadi/libcasadi_conic_qrqp.so.3.7 +0 -0
  237. casadi/libcasadi_conic_superscs.so +0 -0
  238. casadi/libcasadi_conic_superscs.so.3.7 +0 -0
  239. casadi/libcasadi_integrator_collocation.so +0 -0
  240. casadi/libcasadi_integrator_collocation.so.3.7 +0 -0
  241. casadi/libcasadi_integrator_cvodes.so +0 -0
  242. casadi/libcasadi_integrator_cvodes.so.3.7 +0 -0
  243. casadi/libcasadi_integrator_idas.so +0 -0
  244. casadi/libcasadi_integrator_idas.so.3.7 +0 -0
  245. casadi/libcasadi_interpolant_bspline.so +0 -0
  246. casadi/libcasadi_interpolant_bspline.so.3.7 +0 -0
  247. casadi/libcasadi_interpolant_linear.so +0 -0
  248. casadi/libcasadi_interpolant_linear.so.3.7 +0 -0
  249. casadi/libcasadi_linsol_lapacklu.so +0 -0
  250. casadi/libcasadi_linsol_lapacklu.so.3.7 +0 -0
  251. casadi/libcasadi_linsol_lapackqr.so +0 -0
  252. casadi/libcasadi_linsol_lapackqr.so.3.7 +0 -0
  253. casadi/libcasadi_linsol_ldl.so +0 -0
  254. casadi/libcasadi_linsol_ldl.so.3.7 +0 -0
  255. casadi/libcasadi_linsol_mumps.so +0 -0
  256. casadi/libcasadi_linsol_mumps.so.3.7 +0 -0
  257. casadi/libcasadi_linsol_qr.so +0 -0
  258. casadi/libcasadi_linsol_qr.so.3.7 +0 -0
  259. casadi/libcasadi_linsol_symbolicqr.so +0 -0
  260. casadi/libcasadi_linsol_symbolicqr.so.3.7 +0 -0
  261. casadi/libcasadi_nlpsol_alpaqa.so +0 -0
  262. casadi/libcasadi_nlpsol_alpaqa.so.3.7 +0 -0
  263. casadi/libcasadi_nlpsol_ampl.so +0 -0
  264. casadi/libcasadi_nlpsol_ampl.so.3.7 +0 -0
  265. casadi/libcasadi_nlpsol_blocksqp.so +0 -0
  266. casadi/libcasadi_nlpsol_blocksqp.so.3.7 +0 -0
  267. casadi/libcasadi_nlpsol_bonmin.so +0 -0
  268. casadi/libcasadi_nlpsol_bonmin.so.3.7 +0 -0
  269. casadi/libcasadi_nlpsol_feasiblesqpmethod.so +0 -0
  270. casadi/libcasadi_nlpsol_feasiblesqpmethod.so.3.7 +0 -0
  271. casadi/libcasadi_nlpsol_ipopt.so +0 -0
  272. casadi/libcasadi_nlpsol_ipopt.so.3.7 +0 -0
  273. casadi/libcasadi_nlpsol_knitro.so +0 -0
  274. casadi/libcasadi_nlpsol_knitro.so.3.7 +0 -0
  275. casadi/libcasadi_nlpsol_qrsqp.so +0 -0
  276. casadi/libcasadi_nlpsol_qrsqp.so.3.7 +0 -0
  277. casadi/libcasadi_nlpsol_scpgen.so +0 -0
  278. casadi/libcasadi_nlpsol_scpgen.so.3.7 +0 -0
  279. casadi/libcasadi_nlpsol_sleqp.so +0 -0
  280. casadi/libcasadi_nlpsol_sleqp.so.3.7 +0 -0
  281. casadi/libcasadi_nlpsol_snopt.so +0 -0
  282. casadi/libcasadi_nlpsol_snopt.so.3.7 +0 -0
  283. casadi/libcasadi_nlpsol_sqpmethod.so +0 -0
  284. casadi/libcasadi_nlpsol_sqpmethod.so.3.7 +0 -0
  285. casadi/libcasadi_nlpsol_worhp.so +0 -0
  286. casadi/libcasadi_nlpsol_worhp.so.3.7 +0 -0
  287. casadi/libcasadi_rootfinder_fast_newton.so +0 -0
  288. casadi/libcasadi_rootfinder_fast_newton.so.3.7 +0 -0
  289. casadi/libcasadi_rootfinder_newton.so +0 -0
  290. casadi/libcasadi_rootfinder_newton.so.3.7 +0 -0
  291. casadi/libcasadi_sundials_common.so +0 -0
  292. casadi/libcasadi_sundials_common.so.3.7 +0 -0
  293. casadi/libhighs.so +0 -0
  294. casadi/libhighs.so.1.6 +0 -0
  295. casadi/libhighs.so.1.6.0 +0 -0
  296. casadi/libindirect.a +0 -0
  297. casadi/liblinsys.a +0 -0
  298. casadi/libosqp.a +0 -0
  299. casadi/libqdldl.a +0 -0
  300. casadi/libsleqp.so +0 -0
  301. casadi/libsleqp.so.1.0.1 +0 -0
  302. casadi/libspral.a +0 -0
  303. casadi/libsuperscs.a +0 -0
  304. casadi/libtrlib.so +0 -0
  305. casadi/libtrlib.so.0.4 +0 -0
  306. casadi/pkgconfig/blas.pc +11 -0
  307. casadi/pkgconfig/bonmin.pc +1 -1
  308. casadi/pkgconfig/casadi.pc +1 -1
  309. casadi/pkgconfig/cbc.pc +2 -2
  310. casadi/pkgconfig/cgl.pc +2 -2
  311. casadi/pkgconfig/clp.pc +1 -1
  312. casadi/pkgconfig/coinutils.pc +1 -1
  313. casadi/pkgconfig/highs.pc +3 -3
  314. casadi/pkgconfig/lapack.pc +11 -0
  315. casadi/pkgconfig/openblas.pc +1 -1
  316. casadi/pkgconfig/osi-cbc.pc +1 -1
  317. casadi/pkgconfig/osi-clp.pc +1 -1
  318. casadi/pkgconfig/osi-unittests.pc +1 -1
  319. casadi/pkgconfig/osi.pc +1 -1
  320. casadi/pkgconfig/sleqp.pc +10 -0
  321. {casadi-3.6.2.dist-info → casadi-3.6.4.dist-info}/METADATA +1 -1
  322. {casadi-3.6.2.dist-info → casadi-3.6.4.dist-info}/RECORD +324 -283
  323. casadi/libCbc.so.3.10.6 +0 -0
  324. casadi/libCbcSolver.so.3.10.6 +0 -0
  325. casadi/libCgl.so.1.10.4 +0 -0
  326. casadi/libCoinUtils.so.3.11.6 +0 -0
  327. casadi/libOsiClp.so.1.14.7 +0 -0
  328. casadi/libbonmin.so.4.8.8 +0 -0
  329. casadi/libhighs.so.1.4 +0 -0
  330. casadi/libhighs.so.1.4.0 +0 -0
  331. /casadi/{libOsi.so.1.13.7 → libOsi.so.1.13.9} +0 -0
  332. {casadi-3.6.2.dist-info → casadi-3.6.4.dist-info}/WHEEL +0 -0
@@ -17,6 +17,201 @@
17
17
  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
18
  //
19
19
 
20
+ // C-REPLACE "std::numeric_limits<T1>::quiet_NaN()" "NAN"
21
+ // C-REPLACE "fmax" "casadi_fmax"
22
+
23
+ // SYMBOL "forward_diff"
24
+ template<typename T1>
25
+ void casadi_forward_diff(const T1** yk, T1* J, T1 h, casadi_int n_y) {
26
+ // Local variables
27
+ casadi_int i;
28
+ const double *yf, *yc;
29
+ T1 hinv;
30
+ // Inverse of step size
31
+ hinv = 1. / h;
32
+ // Get stencil
33
+ yc = yk[0];
34
+ yf = yk[1];
35
+ // Calculate FD approximation
36
+ for (i = 0; i < n_y; ++i) J[i] = hinv * (yf[i] - yc[i]);
37
+ }
38
+
39
+ // SYMBOL "central_diff"
40
+ template<typename T1>
41
+ void casadi_central_diff(const T1** yk, T1* J, T1 h, casadi_int n_y) {
42
+ // Local variables
43
+ casadi_int i;
44
+ const T1 *yf, *yc, *yb;
45
+ T1 hinv;
46
+ // Inverse of step size
47
+ hinv = 1. / h;
48
+ // Get stencil
49
+ yb = yk[0];
50
+ yc = yk[1];
51
+ yf = yk[2];
52
+ // Set u and stencils to zero (also supresses warnings)
53
+ for (i = 0; i < n_y; ++i) {
54
+ if (isfinite(yb[i])) {
55
+ if (isfinite(yf[i])) {
56
+ // Both forward and backward allowed
57
+ J[i] = 0.5 * hinv * (yf[i] - yb[i]);
58
+ } else {
59
+ // Backward but not forward allowed
60
+ J[i] = hinv * (yc[i] - yb[i]);
61
+ }
62
+ } else {
63
+ if (isfinite(yf[i])) {
64
+ // Forward but not backward allowed
65
+ J[i] = hinv * (yf[i] - yc[i]);
66
+ } else {
67
+ // Neither forward nor backward possible
68
+ J[i] = std::numeric_limits<T1>::quiet_NaN();
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ // SYMBOL "central_diff_err"
75
+ template<typename T1>
76
+ T1 casadi_central_diff_err(const T1** yk, T1 h, casadi_int n_y, casadi_int i,
77
+ T1 abstol, T1 reltol) {
78
+ // Local variables
79
+ const T1 *yf, *yc, *yb;
80
+ T1 err_trunc, err_round;
81
+ // Get stencil
82
+ yb = yk[0];
83
+ yc = yk[1];
84
+ yf = yk[2];
85
+ // Only consider points where both forward and backward allowed
86
+ if (isfinite(yb[i]) && isfinite(yf[i])) {
87
+ // Truncation error
88
+ err_trunc = yf[i] - 2*yc[i] + yb[i];
89
+ // Roundoff error
90
+ err_round = reltol / h * fmax(fabs(yf[i] - yc[i]), fabs(yc[i] - yb[i])) + abstol;
91
+ // Error quotient estimate
92
+ return err_trunc / err_round;
93
+ } else {
94
+ // Cannot be calculated
95
+ return std::numeric_limits<T1>::quiet_NaN();;
96
+ }
97
+ }
98
+
99
+ // SYMBOL "smoothing_diff_weights"
100
+ template<typename T1>
101
+ T1 casadi_smoothing_diff_weights(casadi_int k, T1 yb, T1 yc, T1 yf, T1 *J) {
102
+ // Calculate shifted finite difference approximation, weights
103
+ if (k == 0) {
104
+ // Backward shifted
105
+ // 7.10 in Conte & Carl de Boor: Elementary Numerical Analysis (1972)
106
+ // and 25.3.4 in Abramowitz and Stegun, Handbook of Mathematical Functions (1964)
107
+ if (J) *J = 3 * yf - 4 * yc + yb;
108
+ // Relative weight is 1
109
+ return 1;
110
+ } else if (k == 1) {
111
+ // Central
112
+ // We give this the relative weight 4 since if all weights are equal,
113
+ // this would amount to a five point formula for the derivative
114
+ // (yb2 - 8*yb + 8*yf - y_f2)/(12*h)
115
+ // cf. 25.3.6 in Abramowitz and Stegun, Handbook of Mathematical Functions (1964)
116
+ if (J) *J = yf - yb;
117
+ // Relative weight is 4
118
+ return 4;
119
+ } else {
120
+ // Forward shifted, cf. backward shifted above
121
+ if (J) *J = -3 * yb + 4 * yc - yf;
122
+ // Relative weight is 1
123
+ return 1;
124
+ }
125
+ }
126
+
127
+ // SYMBOL "smoothing_diff"
128
+ template<typename T1>
129
+ void casadi_smoothing_diff(const T1** yk, T1* J, T1 h, casadi_int n_y, T1 smoothing) {
130
+ // Stencil
131
+ T1 yb, yc, yf;
132
+ // Local variables
133
+ T1 Jk, wk, sw, ui, sm;
134
+ casadi_int i, k;
135
+ // Set stencils to zero (also supresses warnings)
136
+ yf = yc = yb = 0;
137
+ for (i = 0; i < n_y; ++i) {
138
+ // Reset derivative estimate, sum of weights, error estimate
139
+ J[i] = sw = ui = 0;
140
+ // For backward shifted, central and forward shifted
141
+ for (k = 0; k < 3; ++k) {
142
+ // Get stencil
143
+ yb = yk[k][i];
144
+ yc = yk[k + 1][i];
145
+ yf = yk[k + 2][i];
146
+ // No contribuation if any value is infinite
147
+ if (!isfinite(yb) || !isfinite(yc) || !isfinite(yf)) continue;
148
+ // Calculate weights
149
+ wk = casadi_smoothing_diff_weights(k, yb, yc, yf, &Jk);
150
+ // Smoothness measure (second order derivative)
151
+ sm = yf - 2*yc + yb;
152
+ sm /= h*h;
153
+ // Modify the weight according to smoothness
154
+ wk /= sm*sm + smoothing;
155
+ sw += wk;
156
+ // Added weighted contribution to weight and error
157
+ J[i] += wk * Jk;
158
+ }
159
+ // If sw is 0, no stencil worked
160
+ if (sw == 0) {
161
+ // Set component to 0, return -1
162
+ J[i] = std::numeric_limits<T1>::quiet_NaN();
163
+ } else {
164
+ // Finalize estimate using the sum of weights and the step length
165
+ J[i] /= 2*h*sw;
166
+ }
167
+ }
168
+ }
169
+
170
+ // SYMBOL "smoothing_diff_err"
171
+ template<typename T1>
172
+ T1 casadi_smoothing_diff_err(const T1** yk, T1 h, casadi_int n_y, casadi_int i,
173
+ T1 abstol, T1 reltol, T1 smoothing) {
174
+ // Stencil
175
+ T1 yb, yc, yf;
176
+ // Local variables
177
+ T1 wk, sw, ui, err_trunc, err_round, sm;
178
+ casadi_int k;
179
+ // Set stencils to zero (also supresses warnings)
180
+ yf = yc = yb = 0;
181
+ // Reset derivative estimate, sum of weights, error estimate
182
+ sw = ui = 0;
183
+ // For backward shifted, central and forward shifted
184
+ for (k = 0; k < 3; ++k) {
185
+ // Get stencil
186
+ yb = yk[k][i];
187
+ yc = yk[k + 1][i];
188
+ yf = yk[k + 2][i];
189
+ // No contribuation if any value is infinite
190
+ if (!isfinite(yb) || !isfinite(yc) || !isfinite(yf)) continue;
191
+ // Calculate weights
192
+ wk = casadi_smoothing_diff_weights(k, yb, yc, yf, static_cast<T1*>(0));
193
+ // Truncation error
194
+ err_trunc = yf - 2*yc + yb;
195
+ // Roundoff error
196
+ err_round = reltol/h*fmax(fabs(yf - yc), fabs(yc - yb)) + abstol;
197
+ // We use the second order derivative as a smoothness measure
198
+ sm = err_trunc/(h*h);
199
+ // Modify the weight according to smoothness
200
+ wk /= sm*sm + smoothing;
201
+ sw += wk;
202
+ // Added weighted contribution to weight and error
203
+ ui += wk * fabs(err_trunc / err_round);
204
+ }
205
+ // If sw is 0, no stencil worked
206
+ if (sw == 0) {
207
+ // Cannot be calculated
208
+ return std::numeric_limits<T1>::quiet_NaN();;
209
+ } else {
210
+ // Finalize estimate using the sum of weights and the step length
211
+ return ui / sw;
212
+ }
213
+ }
214
+
20
215
  // SYMBOL "finite_diff_mem"
21
216
  template<typename T1>
22
217
  struct casadi_finite_diff_mem {
@@ -31,13 +226,11 @@ struct casadi_finite_diff_mem {
31
226
  };
32
227
 
33
228
  // C-REPLACE "casadi_finite_diff_mem<T1>" "struct casadi_finite_diff_mem"
34
- // C-REPLACE "std::numeric_limits<T1>::quiet_NaN()" "NAN"
35
- // C-REPLACE "fmax" "casadi_fmax"
36
229
 
37
- // SYMBOL "forward_diff"
230
+ // SYMBOL "forward_diff_old"
38
231
  template<typename T1>
39
- T1 casadi_forward_diff(T1** yk, T1* y0, T1* J,
40
- T1 h, casadi_int n_y, const casadi_finite_diff_mem<T1>* m) {
232
+ T1 casadi_forward_diff_old(T1** yk, T1* y0, T1* J,
233
+ T1 h, casadi_int n_y, const casadi_finite_diff_mem<T1>* m) {
41
234
  casadi_int i;
42
235
  for (i=0; i<n_y; ++i) {
43
236
  J[i] = (yk[0][i]-y0[i])/h;
@@ -45,10 +238,10 @@ T1 casadi_forward_diff(T1** yk, T1* y0, T1* J,
45
238
  return -1;
46
239
  }
47
240
 
48
- // SYMBOL "central_diff"
241
+ // SYMBOL "central_diff_old"
49
242
  template<typename T1>
50
- T1 casadi_central_diff(T1** yk, T1* y0, T1* J,
51
- T1 h, casadi_int n_y, const casadi_finite_diff_mem<T1>* m) {
243
+ T1 casadi_central_diff_old(T1** yk, T1* y0, T1* J,
244
+ T1 h, casadi_int n_y, const casadi_finite_diff_mem<T1>* m) {
52
245
  // Return value
53
246
  T1 u;
54
247
  // Stencil
@@ -77,10 +270,10 @@ T1 casadi_central_diff(T1** yk, T1* y0, T1* J,
77
270
  return u;
78
271
  }
79
272
 
80
- // SYMBOL "smoothing_diff"
273
+ // SYMBOL "smoothing_diff_old"
81
274
  template<typename T1>
82
- T1 casadi_smoothing_diff(T1** yk, T1* y0, T1* J,
83
- T1 h, casadi_int n_y, const casadi_finite_diff_mem<T1>* m) {
275
+ T1 casadi_smoothing_diff_old(T1** yk, T1* y0, T1* J,
276
+ T1 h, casadi_int n_y, const casadi_finite_diff_mem<T1>* m) {
84
277
  // Return value
85
278
  T1 u;
86
279
  // Stencil
@@ -29,6 +29,8 @@
29
29
  #include <set>
30
30
  #include <sstream>
31
31
  #include <unordered_map>
32
+ #include <cstdint>
33
+ #include <climits>
32
34
 
33
35
  namespace casadi {
34
36
  class Slice;
@@ -39,6 +41,7 @@ namespace casadi {
39
41
  class SXElem;
40
42
  class GenericType;
41
43
  class Importer;
44
+ class Fmu;
42
45
  class SharedObject;
43
46
  class SharedObjectInternal;
44
47
  class SXNode;
@@ -90,10 +93,15 @@ namespace casadi {
90
93
  }
91
94
  void unpack(Function& e);
92
95
  void unpack(Importer& e);
96
+ void unpack(Fmu& e);
93
97
  void unpack(GenericType& e);
94
98
  void unpack(std::ostream& s);
95
99
  void unpack(Slice& e);
96
100
  void unpack(int& e);
101
+
102
+ #if SIZE_MAX != UINT_MAX
103
+ void unpack(unsigned int& e);
104
+ #endif
97
105
  void unpack(bool& e);
98
106
  void unpack(casadi_int& e);
99
107
  void unpack(size_t& e);
@@ -223,10 +231,14 @@ namespace casadi {
223
231
  }
224
232
  void pack(const Function& e);
225
233
  void pack(const Importer& e);
234
+ void pack(const Fmu& e);
226
235
  void pack(const Slice& e);
227
236
  void pack(const GenericType& e);
228
237
  void pack(std::istream& s);
229
238
  void pack(int e);
239
+ #if SIZE_MAX != UINT_MAX
240
+ void pack(unsigned int e);
241
+ #endif
230
242
  void pack(bool e);
231
243
  void pack(casadi_int e);
232
244
  void pack(size_t e);
@@ -72,6 +72,8 @@ namespace casadi {
72
72
  static MatType mtimes(const std::vector<MatType> &args);
73
73
  static std::vector<MatType > horzsplit(const MatType& x, casadi_int incr);
74
74
  static std::vector<MatType > vertsplit(const MatType& x, casadi_int incr);
75
+ static std::vector<MatType > horzsplit_n(const MatType& x, casadi_int n);
76
+ static std::vector<MatType > vertsplit_n(const MatType& x, casadi_int n);
75
77
  static MatType repmat(const MatType &A, const std::pair<casadi_int, casadi_int>& rc) {
76
78
  return MatType::repmat(A, rc.first, rc.second);
77
79
  }
@@ -122,15 +124,32 @@ namespace casadi {
122
124
 
123
125
  /** \brief split horizontally, retaining fixed-sized groups of columns
124
126
 
125
- * \param incr Size of each group of columns
127
+ * \param incr Size (width) of each group of columns
126
128
  *
127
129
  * horzcat(horzsplit(x, ...)) = x
130
+ *
131
+ * \seealso horzsplit_n
128
132
 
129
133
  \identifier{3h} */
130
134
  inline friend std::vector<MatType > horzsplit(const MatType& x, casadi_int incr=1) {
131
135
  return MatType::horzsplit(x, incr);
132
136
  }
133
137
 
138
+ /** \brief split horizontally, retaining fixed-sized groups of columns
139
+
140
+ * \param n Number of groups of columns
141
+ *
142
+ * Will error when the number of columns is not a multiple of n
143
+ *
144
+ * horzcat(horzsplit(x, ...)) = x
145
+ *
146
+ * \seealso horzsplit
147
+
148
+ \identifier{277} */
149
+ inline friend std::vector<MatType > horzsplit_n(const MatType& x, casadi_int n) {
150
+ return MatType::horzsplit_n(x, n);
151
+ }
152
+
134
153
  /** \brief split vertically, retaining groups of rows
135
154
 
136
155
  * \param output_offset List of all start rows for each group
@@ -178,11 +197,29 @@ namespace casadi {
178
197
  [DM([0, 1]), DM([2, 3]), DM(4)]
179
198
  \enddoctest
180
199
  *
200
+
201
+ * \seealso vertsplit_n
202
+
181
203
  \identifier{3k} */
182
204
  inline friend std::vector<MatType > vertsplit(const MatType &x, casadi_int incr=1) {
183
205
  return MatType::vertsplit(x, incr);
184
206
  }
185
207
 
208
+ /** \brief split vertically, retaining fixed-sized groups of rows
209
+
210
+ * \param n Number of groups of rows
211
+ *
212
+ * Will error when the number of rows is not a multiple of n
213
+ *
214
+ * vertcat(vertsplit(x, ...)) = x
215
+ *
216
+ * \seealso vertsplit
217
+
218
+ \identifier{278} */
219
+ inline friend std::vector<MatType > vertsplit_n(const MatType& x, casadi_int n) {
220
+ return MatType::vertsplit_n(x, n);
221
+ }
222
+
186
223
  /** \brief Construct a matrix from a list of list of blocks.
187
224
 
188
225
  \identifier{3l} */
@@ -684,6 +721,23 @@ namespace casadi {
684
721
  offset1.push_back(sz1);
685
722
  return MatType::vertsplit(x, offset1);
686
723
  }
724
+ template<typename MatType>
725
+ std::vector<MatType > SparsityInterface<MatType>::horzsplit_n(const MatType& x, casadi_int n) {
726
+ casadi_assert(n>=0, "horzsplit_n(x,n): n (" + str(n) + ") must be non-negative");
727
+ if (x.size2()==0) return std::vector<MatType>(n, x);
728
+ casadi_assert(x.size2() % n==0, "horzsplit_n(x,n): x.size2() (" + str(x.size2()) +
729
+ ") must be a multiple of n (" + str(n) + ")");
730
+ return horzsplit(x, x.size2()/n);
731
+ }
732
+ template<typename MatType>
733
+ std::vector<MatType > SparsityInterface<MatType>::vertsplit_n(const MatType& x, casadi_int n) {
734
+ casadi_assert(n>=0, "vertsplit_n(x,n): n (" + str(n) + ") must be non-negative");
735
+ if (x.size1()==0) return std::vector<MatType>(n, x);
736
+ casadi_assert(x.size1() % n==0, "vertsplit(x,n): x.size1() (" + str(x.size1()) +
737
+ ") must be a multiple of n (" + str(n) + ")");
738
+ return vertsplit(x, x.size1()/n);
739
+ }
740
+
687
741
  #endif // SWIG
688
742
 
689
743
  } // namespace casadi