casadi 3.6.5__cp38-none-manylinux2014_x86_64.whl → 3.6.7__cp38-none-manylinux2014_x86_64.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 (429) hide show
  1. casadi/_casadi.so +0 -0
  2. casadi/casadi.py +739 -308
  3. casadi/cbc +0 -0
  4. casadi/clp +0 -0
  5. casadi/cmake/casadi-config-version.cmake +1 -1
  6. casadi/cmake/highs/highs-config.cmake +6 -13
  7. casadi/cmake/highs/highs-targets-release.cmake +13 -13
  8. casadi/cmake/highs/highs-targets.cmake +13 -10
  9. casadi/highs +0 -0
  10. casadi/include/casadi/casadi.i +3 -0
  11. casadi/include/casadi/casadi_c.h +2 -0
  12. casadi/include/casadi/config.h +8 -8
  13. casadi/include/casadi/core/casadi_common.hpp +1 -0
  14. casadi/include/casadi/core/casadi_misc.hpp +52 -0
  15. casadi/include/casadi/core/casadi_types.hpp +3 -2
  16. casadi/include/casadi/core/code_generator.hpp +30 -1
  17. casadi/include/casadi/core/global_options.hpp +2 -0
  18. casadi/include/casadi/core/mx.hpp +18 -3
  19. casadi/include/casadi/core/optistack.hpp +23 -0
  20. casadi/include/casadi/core/runtime/casadi_nlp.hpp +19 -4
  21. casadi/include/casadi/core/runtime/casadi_ocp_block.hpp +55 -0
  22. casadi/include/casadi/core/runtime/casadi_oracle.hpp +44 -0
  23. casadi/include/casadi/core/runtime/casadi_oracle_callback.hpp +39 -0
  24. casadi/include/casadi/core/runtime/casadi_runtime.hpp +4 -1
  25. casadi/include/casadi/core/runtime/casadi_scaled_copy.hpp +31 -0
  26. casadi/include/casadi/core/serializing_stream.hpp +2 -2
  27. casadi/include/casadi/core/sparsity.hpp +7 -0
  28. casadi/include/casadi/doc.i +1513 -1016
  29. casadi/include/casadi/doc_merged.i +965 -719
  30. casadi/include/casadi/mem.h +1 -0
  31. casadi/include/daqp/api.h +46 -0
  32. casadi/include/daqp/auxiliary.h +29 -0
  33. casadi/include/daqp/bnb.h +32 -0
  34. casadi/include/daqp/codegen.h +18 -0
  35. casadi/include/daqp/constants.h +92 -0
  36. casadi/include/daqp/daqp.h +22 -0
  37. casadi/include/daqp/daqp_prox.h +18 -0
  38. casadi/include/daqp/factorization.h +18 -0
  39. casadi/include/daqp/types.h +161 -0
  40. casadi/include/daqp/utils.h +44 -0
  41. casadi/include/fatrop/auxiliary/Common.hpp +34 -0
  42. casadi/include/fatrop/auxiliary/DynamicLib.hpp +34 -0
  43. casadi/include/fatrop/auxiliary/FatropOptions.hpp +68 -0
  44. casadi/include/fatrop/auxiliary/FatropVector.hpp +143 -0
  45. casadi/include/fatrop/auxiliary/LinearAlgebra.hpp +88 -0
  46. casadi/include/fatrop/auxiliary/VectorUtils.hpp +54 -0
  47. casadi/include/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp +493 -0
  48. casadi/include/fatrop/fatrop.hpp +39 -0
  49. casadi/include/fatrop/function_evaluation/CasadiCodegen.hpp +104 -0
  50. casadi/include/fatrop/function_evaluation/FunctionEvaluation.hpp +60 -0
  51. casadi/include/fatrop/json/json.h +946 -0
  52. casadi/include/fatrop/ocp/CasadiCApiUserdataWrap.hpp +87 -0
  53. casadi/include/fatrop/ocp/DuInfEvaluator.hpp +38 -0
  54. casadi/include/fatrop/ocp/FatropOCP.hpp +161 -0
  55. casadi/include/fatrop/ocp/FatropOCPBuilder.hpp +52 -0
  56. casadi/include/fatrop/ocp/FatropOCPResto.hpp +299 -0
  57. casadi/include/fatrop/ocp/OCP.hpp +82 -0
  58. casadi/include/fatrop/ocp/OCPAbstract.hpp +254 -0
  59. casadi/include/fatrop/ocp/OCPAdapter.hpp +197 -0
  60. casadi/include/fatrop/ocp/OCPCInterface.h +289 -0
  61. casadi/include/fatrop/ocp/OCPDims.hpp +60 -0
  62. casadi/include/fatrop/ocp/OCPInitializer.hpp +41 -0
  63. casadi/include/fatrop/ocp/OCPKKT.hpp +69 -0
  64. casadi/include/fatrop/ocp/OCPLSRiccati.hpp +198 -0
  65. casadi/include/fatrop/ocp/OCPLSScaler.hpp +66 -0
  66. casadi/include/fatrop/ocp/OCPLinearSolver.hpp +75 -0
  67. casadi/include/fatrop/ocp/OCPNoScaling.hpp +42 -0
  68. casadi/include/fatrop/ocp/OCPScalingMethod.hpp +42 -0
  69. casadi/include/fatrop/ocp/StageOCP.hpp +592 -0
  70. casadi/include/fatrop/ocp/StageOCPApplication.hpp +242 -0
  71. casadi/include/fatrop/ocp/StageOCPExpressions.hpp +182 -0
  72. casadi/include/fatrop/ocp/UStageEvalAbstract.hpp +168 -0
  73. casadi/include/fatrop/ocp/UStageOCPImpl.hpp +152 -0
  74. casadi/include/fatrop/quasi_newton/bfgs.hpp +159 -0
  75. casadi/include/fatrop/solver/AlgBuilder.hpp +76 -0
  76. casadi/include/fatrop/solver/AlgStrategy.hpp +33 -0
  77. casadi/include/fatrop/solver/FatropAlg.hpp +121 -0
  78. casadi/include/fatrop/solver/FatropData.hpp +188 -0
  79. casadi/include/fatrop/solver/FatropOptions.hpp +95 -0
  80. casadi/include/fatrop/solver/FatropPrinter.hpp +65 -0
  81. casadi/include/fatrop/solver/FatropStats.hpp +63 -0
  82. casadi/include/fatrop/solver/Filter.hpp +54 -0
  83. casadi/include/fatrop/solver/IterationData.hpp +56 -0
  84. casadi/include/fatrop/solver/LineSearch.hpp +86 -0
  85. casadi/include/fatrop/solver/NLPL1.hpp +263 -0
  86. casadi/include/fatrop/templates/NLPAlg.hpp +104 -0
  87. casadi/include/highs/HConfig.h +6 -5
  88. casadi/include/highs/Highs.h +93 -23
  89. casadi/include/highs/filereaderlp/def.hpp +19 -0
  90. casadi/include/highs/interfaces/highs_c_api.h +200 -24
  91. casadi/include/highs/io/Filereader.h +1 -1
  92. casadi/include/highs/io/FilereaderEms.h +1 -1
  93. casadi/include/highs/io/FilereaderLp.h +1 -1
  94. casadi/include/highs/io/FilereaderMps.h +1 -1
  95. casadi/include/highs/io/HMPSIO.h +1 -1
  96. casadi/include/highs/io/HMpsFF.h +5 -3
  97. casadi/include/highs/io/HighsIO.h +18 -8
  98. casadi/include/highs/io/LoadOptions.h +1 -1
  99. casadi/include/highs/ipm/IpxSolution.h +35 -0
  100. casadi/include/highs/ipm/IpxWrapper.h +1 -1
  101. casadi/include/highs/ipm/basiclu/basiclu.h +161 -0
  102. casadi/include/highs/ipm/basiclu/basiclu_factorize.h +247 -0
  103. casadi/include/highs/ipm/basiclu/basiclu_get_factors.h +108 -0
  104. casadi/include/highs/ipm/basiclu/basiclu_initialize.h +119 -0
  105. casadi/include/highs/ipm/basiclu/basiclu_obj_factorize.h +34 -0
  106. casadi/include/highs/ipm/basiclu/basiclu_obj_free.h +19 -0
  107. casadi/include/highs/ipm/basiclu/basiclu_obj_get_factors.h +34 -0
  108. casadi/include/highs/ipm/basiclu/basiclu_obj_initialize.h +46 -0
  109. casadi/include/highs/ipm/basiclu/basiclu_obj_solve_dense.h +29 -0
  110. casadi/include/highs/ipm/basiclu/basiclu_obj_solve_for_update.h +42 -0
  111. casadi/include/highs/ipm/basiclu/basiclu_obj_solve_sparse.h +32 -0
  112. casadi/include/highs/ipm/basiclu/basiclu_obj_update.h +31 -0
  113. casadi/include/highs/ipm/basiclu/basiclu_object.h +30 -0
  114. casadi/include/highs/ipm/basiclu/basiclu_solve_dense.h +75 -0
  115. casadi/include/highs/ipm/basiclu/basiclu_solve_for_update.h +169 -0
  116. casadi/include/highs/ipm/basiclu/basiclu_solve_sparse.h +112 -0
  117. casadi/include/highs/ipm/basiclu/basiclu_update.h +125 -0
  118. casadi/include/highs/ipm/basiclu/lu_def.h +39 -0
  119. casadi/include/highs/ipm/basiclu/lu_file.h +21 -0
  120. casadi/include/highs/ipm/basiclu/lu_internal.h +220 -0
  121. casadi/include/highs/ipm/basiclu/lu_list.h +168 -0
  122. casadi/include/highs/ipm/ipx/basiclu_kernel.h +20 -0
  123. casadi/include/highs/ipm/ipx/basiclu_wrapper.h +47 -0
  124. casadi/include/highs/ipm/ipx/basis.h +351 -0
  125. casadi/include/highs/ipm/ipx/conjugate_residuals.h +74 -0
  126. casadi/include/highs/ipm/ipx/control.h +163 -0
  127. casadi/include/highs/ipm/ipx/crossover.h +157 -0
  128. casadi/include/highs/ipm/ipx/diagonal_precond.h +45 -0
  129. casadi/include/highs/ipm/ipx/forrest_tomlin.h +102 -0
  130. casadi/include/highs/ipm/ipx/guess_basis.h +21 -0
  131. casadi/include/highs/ipm/ipx/indexed_vector.h +113 -0
  132. casadi/include/highs/ipm/ipx/info.h +27 -0
  133. casadi/include/highs/ipm/ipx/ipm.h +94 -0
  134. casadi/include/highs/ipm/ipx/ipx_c.h +47 -0
  135. casadi/include/highs/ipm/ipx/ipx_config.h +9 -0
  136. casadi/include/highs/ipm/ipx/ipx_info.h +111 -0
  137. casadi/include/highs/ipm/ipx/ipx_internal.h +88 -0
  138. casadi/include/highs/ipm/ipx/ipx_parameters.h +75 -0
  139. casadi/include/highs/ipm/ipx/ipx_status.h +57 -0
  140. casadi/include/highs/ipm/ipx/iterate.h +328 -0
  141. casadi/include/highs/ipm/ipx/kkt_solver.h +70 -0
  142. casadi/include/highs/ipm/ipx/kkt_solver_basis.h +66 -0
  143. casadi/include/highs/ipm/ipx/kkt_solver_diag.h +48 -0
  144. casadi/include/highs/ipm/ipx/linear_operator.h +26 -0
  145. casadi/include/highs/ipm/ipx/lp_solver.h +201 -0
  146. casadi/include/highs/ipm/ipx/lu_factorization.h +79 -0
  147. casadi/include/highs/ipm/ipx/lu_update.h +129 -0
  148. casadi/include/highs/ipm/ipx/maxvolume.h +54 -0
  149. casadi/include/highs/ipm/ipx/model.h +409 -0
  150. casadi/include/highs/ipm/ipx/multistream.h +52 -0
  151. casadi/include/highs/ipm/ipx/normal_matrix.h +44 -0
  152. casadi/include/highs/ipm/ipx/power_method.h +44 -0
  153. casadi/include/highs/ipm/ipx/sparse_matrix.h +195 -0
  154. casadi/include/highs/ipm/ipx/sparse_utils.h +58 -0
  155. casadi/include/highs/ipm/ipx/splitted_normal_matrix.h +63 -0
  156. casadi/include/highs/ipm/ipx/starting_basis.h +39 -0
  157. casadi/include/highs/ipm/ipx/symbolic_invert.h +29 -0
  158. casadi/include/highs/ipm/ipx/timer.h +24 -0
  159. casadi/include/highs/ipm/ipx/utils.h +39 -0
  160. casadi/include/highs/lp_data/HConst.h +20 -10
  161. casadi/include/highs/lp_data/HStruct.h +23 -1
  162. casadi/include/highs/lp_data/HighsAnalysis.h +1 -1
  163. casadi/include/highs/lp_data/HighsCallback.h +10 -3
  164. casadi/include/highs/lp_data/HighsCallbackStruct.h +31 -5
  165. casadi/include/highs/lp_data/HighsDebug.h +1 -1
  166. casadi/include/highs/lp_data/HighsInfo.h +20 -2
  167. casadi/include/highs/lp_data/HighsInfoDebug.h +1 -1
  168. casadi/include/highs/lp_data/HighsLp.h +17 -1
  169. casadi/include/highs/lp_data/HighsLpSolverObject.h +1 -1
  170. casadi/include/highs/lp_data/HighsLpUtils.h +19 -19
  171. casadi/include/highs/lp_data/HighsModelUtils.h +1 -1
  172. casadi/include/highs/lp_data/HighsOptions.h +237 -10
  173. casadi/include/highs/lp_data/HighsRanging.h +1 -1
  174. casadi/include/highs/lp_data/HighsRuntimeOptions.h +2 -2
  175. casadi/include/highs/lp_data/HighsSolution.h +2 -2
  176. casadi/include/highs/lp_data/HighsSolutionDebug.h +1 -1
  177. casadi/include/highs/lp_data/HighsSolve.h +3 -1
  178. casadi/include/highs/lp_data/HighsStatus.h +1 -1
  179. casadi/include/highs/mip/HighsCliqueTable.h +4 -4
  180. casadi/include/highs/mip/HighsConflictPool.h +1 -1
  181. casadi/include/highs/mip/HighsCutGeneration.h +1 -1
  182. casadi/include/highs/mip/HighsCutPool.h +2 -2
  183. casadi/include/highs/mip/HighsDebugSol.h +22 -29
  184. casadi/include/highs/mip/HighsDomain.h +10 -2
  185. casadi/include/highs/mip/HighsDomainChange.h +1 -1
  186. casadi/include/highs/mip/HighsDynamicRowMatrix.h +5 -3
  187. casadi/include/highs/mip/HighsGFkSolve.h +3 -3
  188. casadi/include/highs/mip/HighsImplications.h +3 -3
  189. casadi/include/highs/mip/HighsLpAggregator.h +1 -1
  190. casadi/include/highs/mip/HighsLpRelaxation.h +6 -1
  191. casadi/include/highs/mip/HighsMipSolver.h +4 -2
  192. casadi/include/highs/mip/HighsMipSolverData.h +47 -4
  193. casadi/include/highs/mip/HighsModkSeparator.h +2 -2
  194. casadi/include/highs/mip/HighsNodeQueue.h +5 -3
  195. casadi/include/highs/mip/HighsObjectiveFunction.h +1 -1
  196. casadi/include/highs/mip/HighsPathSeparator.h +2 -2
  197. casadi/include/highs/mip/HighsPrimalHeuristics.h +1 -1
  198. casadi/include/highs/mip/HighsPseudocost.h +35 -23
  199. casadi/include/highs/mip/HighsRedcostFixing.h +1 -1
  200. casadi/include/highs/mip/HighsSearch.h +2 -1
  201. casadi/include/highs/mip/HighsSeparation.h +1 -1
  202. casadi/include/highs/mip/HighsSeparator.h +1 -1
  203. casadi/include/highs/mip/HighsTableauSeparator.h +1 -1
  204. casadi/include/highs/mip/HighsTransformedLp.h +1 -1
  205. casadi/include/highs/model/HighsHessian.h +5 -0
  206. casadi/include/highs/model/HighsHessianUtils.h +2 -0
  207. casadi/include/highs/model/HighsModel.h +10 -1
  208. casadi/include/highs/parallel/HighsMutex.h +2 -1
  209. casadi/include/highs/parallel/HighsParallel.h +7 -2
  210. casadi/include/highs/parallel/HighsTask.h +1 -2
  211. casadi/include/highs/pdlp/CupdlpWrapper.h +93 -0
  212. casadi/include/highs/pdlp/cupdlp/cupdlp_cs.h +41 -0
  213. casadi/include/highs/pdlp/cupdlp/cupdlp_defs.h +423 -0
  214. casadi/include/highs/pdlp/cupdlp/cupdlp_linalg.h +183 -0
  215. casadi/include/highs/pdlp/cupdlp/cupdlp_proj.h +19 -0
  216. casadi/include/highs/pdlp/cupdlp/cupdlp_restart.h +31 -0
  217. casadi/include/highs/pdlp/cupdlp/cupdlp_scaling_cuda.h +28 -0
  218. casadi/include/highs/pdlp/cupdlp/cupdlp_solver.h +98 -0
  219. casadi/include/highs/pdlp/cupdlp/cupdlp_step.h +33 -0
  220. casadi/include/highs/pdlp/cupdlp/cupdlp_utils.c +1726 -0
  221. casadi/include/highs/pdqsort/pdqsort.h +532 -0
  222. casadi/include/highs/presolve/HPresolve.h +27 -14
  223. casadi/include/highs/presolve/HPresolveAnalysis.h +1 -1
  224. casadi/include/highs/presolve/HighsPostsolveStack.h +92 -68
  225. casadi/include/highs/presolve/HighsSymmetry.h +6 -5
  226. casadi/include/highs/presolve/ICrash.h +8 -2
  227. casadi/include/highs/presolve/ICrashUtil.h +1 -1
  228. casadi/include/highs/presolve/ICrashX.h +1 -1
  229. casadi/include/highs/presolve/PresolveComponent.h +1 -1
  230. casadi/include/highs/qpsolver/a_asm.hpp +23 -12
  231. casadi/include/highs/qpsolver/a_quass.hpp +8 -1
  232. casadi/include/highs/qpsolver/basis.hpp +150 -0
  233. casadi/include/highs/qpsolver/crashsolution.hpp +12 -0
  234. casadi/include/highs/qpsolver/dantzigpricing.hpp +72 -0
  235. casadi/include/highs/qpsolver/devexpricing.hpp +99 -0
  236. casadi/include/highs/qpsolver/eventhandler.hpp +23 -0
  237. casadi/include/highs/qpsolver/factor.hpp +400 -0
  238. casadi/include/highs/qpsolver/feasibility_bounded.hpp +105 -0
  239. casadi/include/highs/qpsolver/feasibility_highs.hpp +270 -0
  240. casadi/include/highs/qpsolver/gradient.hpp +39 -0
  241. casadi/include/highs/qpsolver/instance.hpp +63 -0
  242. casadi/include/highs/qpsolver/matrix.hpp +335 -0
  243. casadi/include/highs/qpsolver/pricing.hpp +15 -0
  244. casadi/include/highs/qpsolver/qpconst.hpp +27 -0
  245. casadi/include/highs/qpsolver/{vector.hpp → qpvector.hpp} +25 -25
  246. casadi/include/highs/qpsolver/quass.hpp +1 -1
  247. casadi/include/highs/qpsolver/ratiotest.hpp +19 -0
  248. casadi/include/highs/qpsolver/runtime.hpp +38 -0
  249. casadi/include/highs/qpsolver/settings.hpp +57 -0
  250. casadi/include/highs/qpsolver/snippets.hpp +29 -0
  251. casadi/include/highs/qpsolver/statistics.hpp +23 -0
  252. casadi/include/highs/qpsolver/steepestedgepricing.hpp +167 -0
  253. casadi/include/highs/simplex/HApp.h +1 -1
  254. casadi/include/highs/simplex/HEkk.h +52 -18
  255. casadi/include/highs/simplex/HEkkDual.h +1 -1
  256. casadi/include/highs/simplex/HEkkDualRHS.h +6 -7
  257. casadi/include/highs/simplex/HEkkDualRow.h +2 -2
  258. casadi/include/highs/simplex/HEkkPrimal.h +6 -1
  259. casadi/include/highs/simplex/HSimplex.h +1 -3
  260. casadi/include/highs/simplex/HSimplexDebug.h +1 -1
  261. casadi/include/highs/simplex/HSimplexNla.h +1 -1
  262. casadi/include/highs/simplex/HSimplexReport.h +1 -1
  263. casadi/include/highs/simplex/HighsSimplexAnalysis.h +228 -100
  264. casadi/include/highs/simplex/SimplexConst.h +1 -1
  265. casadi/include/highs/simplex/SimplexStruct.h +2 -2
  266. casadi/include/highs/simplex/SimplexTimer.h +1 -1
  267. casadi/include/highs/test/DevKkt.h +1 -1
  268. casadi/include/highs/test/KktCh2.h +1 -1
  269. casadi/include/highs/util/FactorTimer.h +1 -1
  270. casadi/include/highs/util/HFactor.h +35 -6
  271. casadi/include/highs/util/HFactorConst.h +1 -1
  272. casadi/include/highs/util/HFactorDebug.h +1 -1
  273. casadi/include/highs/util/HSet.h +1 -1
  274. casadi/include/highs/util/HVector.h +1 -1
  275. casadi/include/highs/util/HVectorBase.h +1 -1
  276. casadi/include/highs/util/HighsCDouble.h +3 -3
  277. casadi/include/highs/util/HighsComponent.h +1 -1
  278. casadi/include/highs/util/HighsDataStack.h +4 -4
  279. casadi/include/highs/util/HighsDisjointSets.h +1 -1
  280. casadi/include/highs/util/HighsHash.h +28 -21
  281. casadi/include/highs/util/HighsHashTree.h +63 -63
  282. casadi/include/highs/util/HighsInt.h +1 -1
  283. casadi/include/highs/util/HighsIntegers.h +8 -9
  284. casadi/include/highs/util/HighsLinearSumBounds.h +1 -1
  285. casadi/include/highs/util/HighsMatrixPic.h +1 -1
  286. casadi/include/highs/util/HighsMatrixSlice.h +9 -6
  287. casadi/include/highs/util/HighsMatrixUtils.h +1 -1
  288. casadi/include/highs/util/HighsMemoryAllocation.h +55 -0
  289. casadi/include/highs/util/HighsRandom.h +27 -15
  290. casadi/include/highs/util/HighsRbTree.h +2 -2
  291. casadi/include/highs/util/HighsSort.h +7 -7
  292. casadi/include/highs/util/HighsSparseMatrix.h +5 -2
  293. casadi/include/highs/util/HighsSparseVectorSum.h +2 -2
  294. casadi/include/highs/util/HighsSplay.h +1 -1
  295. casadi/include/highs/util/HighsTimer.h +18 -9
  296. casadi/include/highs/util/HighsUtils.h +15 -8
  297. casadi/include/highs/util/stringutil.h +9 -4
  298. casadi/include/highs/zstr/strict_fstream.hpp +237 -0
  299. casadi/include/highs/zstr/zstr.hpp +472 -0
  300. casadi/include/highs_export.h +42 -0
  301. casadi/include/licenses/daqp-external/LICENSE +21 -0
  302. casadi/include/licenses/fatrop-external/LICENSE.txt +165 -0
  303. casadi/include/licenses/fatrop-external/external/blasfeo/LICENSE.txt +26 -0
  304. casadi/include/licenses/fatrop-external/external/pybind11/LICENSE +29 -0
  305. casadi/include/licenses/highs-external/{LICENSE → LICENSE.txt} +1 -1
  306. casadi/include/osqp/constants.h +2 -3
  307. casadi/include/osqp/version.h +9 -0
  308. casadi/include/sleqp/defs.h +2 -2
  309. casadi/lib64/libtinyxml2.a +0 -0
  310. casadi/libCbcSolver.so +0 -0
  311. casadi/libCbcSolver.so.3 +0 -0
  312. casadi/libCbcSolver.so.3.10.11 +0 -0
  313. casadi/libClpSolver.so +0 -0
  314. casadi/libClpSolver.so.1 +0 -0
  315. casadi/libClpSolver.so.1.14.9 +0 -0
  316. casadi/libbonmin.so +0 -0
  317. casadi/libbonmin.so.4 +0 -0
  318. casadi/libbonmin.so.4.8.9 +0 -0
  319. casadi/libcasadi.so +0 -0
  320. casadi/libcasadi.so.3.7 +0 -0
  321. casadi/libcasadi_conic_cbc.so +0 -0
  322. casadi/libcasadi_conic_cbc.so.3.7 +0 -0
  323. casadi/libcasadi_conic_clp.so +0 -0
  324. casadi/libcasadi_conic_clp.so.3.7 +0 -0
  325. casadi/libcasadi_conic_cplex.so +0 -0
  326. casadi/libcasadi_conic_cplex.so.3.7 +0 -0
  327. casadi/libcasadi_conic_daqp.so +0 -0
  328. casadi/libcasadi_conic_daqp.so.3.7 +0 -0
  329. casadi/libcasadi_conic_fatrop.so +0 -0
  330. casadi/libcasadi_conic_fatrop.so.3.7 +0 -0
  331. casadi/libcasadi_conic_gurobi.so +0 -0
  332. casadi/libcasadi_conic_gurobi.so.3.7 +0 -0
  333. casadi/libcasadi_conic_highs.so +0 -0
  334. casadi/libcasadi_conic_highs.so.3.7 +0 -0
  335. casadi/libcasadi_conic_hpipm.so +0 -0
  336. casadi/libcasadi_conic_hpipm.so.3.7 +0 -0
  337. casadi/libcasadi_conic_ipqp.so +0 -0
  338. casadi/libcasadi_conic_ipqp.so.3.7 +0 -0
  339. casadi/libcasadi_conic_nlpsol.so +0 -0
  340. casadi/libcasadi_conic_nlpsol.so.3.7 +0 -0
  341. casadi/libcasadi_conic_osqp.so +0 -0
  342. casadi/libcasadi_conic_osqp.so.3.7 +0 -0
  343. casadi/libcasadi_conic_proxqp.so +0 -0
  344. casadi/libcasadi_conic_proxqp.so.3.7 +0 -0
  345. casadi/libcasadi_conic_qpoases.so +0 -0
  346. casadi/libcasadi_conic_qpoases.so.3.7 +0 -0
  347. casadi/libcasadi_conic_qrqp.so +0 -0
  348. casadi/libcasadi_conic_qrqp.so.3.7 +0 -0
  349. casadi/libcasadi_conic_superscs.so +0 -0
  350. casadi/libcasadi_conic_superscs.so.3.7 +0 -0
  351. casadi/libcasadi_integrator_collocation.so +0 -0
  352. casadi/libcasadi_integrator_collocation.so.3.7 +0 -0
  353. casadi/libcasadi_integrator_cvodes.so +0 -0
  354. casadi/libcasadi_integrator_cvodes.so.3.7 +0 -0
  355. casadi/libcasadi_integrator_idas.so +0 -0
  356. casadi/libcasadi_integrator_idas.so.3.7 +0 -0
  357. casadi/libcasadi_integrator_rk.so +0 -0
  358. casadi/libcasadi_integrator_rk.so.3.7 +0 -0
  359. casadi/libcasadi_nlpsol_alpaqa.so +0 -0
  360. casadi/libcasadi_nlpsol_alpaqa.so.3.7 +0 -0
  361. casadi/libcasadi_nlpsol_ampl.so +0 -0
  362. casadi/libcasadi_nlpsol_ampl.so.3.7 +0 -0
  363. casadi/libcasadi_nlpsol_blocksqp.so +0 -0
  364. casadi/libcasadi_nlpsol_blocksqp.so.3.7 +0 -0
  365. casadi/libcasadi_nlpsol_bonmin.so +0 -0
  366. casadi/libcasadi_nlpsol_bonmin.so.3.7 +0 -0
  367. casadi/libcasadi_nlpsol_fatrop.so +0 -0
  368. casadi/libcasadi_nlpsol_fatrop.so.3.7 +0 -0
  369. casadi/libcasadi_nlpsol_feasiblesqpmethod.so +0 -0
  370. casadi/libcasadi_nlpsol_feasiblesqpmethod.so.3.7 +0 -0
  371. casadi/libcasadi_nlpsol_ipopt.so +0 -0
  372. casadi/libcasadi_nlpsol_ipopt.so.3.7 +0 -0
  373. casadi/libcasadi_nlpsol_knitro.so +0 -0
  374. casadi/libcasadi_nlpsol_knitro.so.3.7 +0 -0
  375. casadi/libcasadi_nlpsol_madnlp.so +0 -0
  376. casadi/libcasadi_nlpsol_madnlp.so.3.7 +0 -0
  377. casadi/libcasadi_nlpsol_qrsqp.so +0 -0
  378. casadi/libcasadi_nlpsol_qrsqp.so.3.7 +0 -0
  379. casadi/libcasadi_nlpsol_scpgen.so +0 -0
  380. casadi/libcasadi_nlpsol_scpgen.so.3.7 +0 -0
  381. casadi/libcasadi_nlpsol_sleqp.so +0 -0
  382. casadi/libcasadi_nlpsol_sleqp.so.3.7 +0 -0
  383. casadi/libcasadi_nlpsol_snopt.so +0 -0
  384. casadi/libcasadi_nlpsol_snopt.so.3.7 +0 -0
  385. casadi/libcasadi_nlpsol_sqpmethod.so +0 -0
  386. casadi/libcasadi_nlpsol_sqpmethod.so.3.7 +0 -0
  387. casadi/libcasadi_nlpsol_worhp.so +0 -0
  388. casadi/libcasadi_nlpsol_worhp.so.3.7 +0 -0
  389. casadi/libcasadi_rootfinder_fast_newton.so +0 -0
  390. casadi/libcasadi_rootfinder_fast_newton.so.3.7 +0 -0
  391. casadi/libcasadi_rootfinder_kinsol.so +0 -0
  392. casadi/libcasadi_rootfinder_kinsol.so.3.7 +0 -0
  393. casadi/libcasadi_rootfinder_newton.so +0 -0
  394. casadi/libcasadi_rootfinder_newton.so.3.7 +0 -0
  395. casadi/libcasadi_rootfinder_nlpsol.so +0 -0
  396. casadi/libcasadi_rootfinder_nlpsol.so.3.7 +0 -0
  397. casadi/libcasadi_sundials_common.so +0 -0
  398. casadi/libcasadi_sundials_common.so.3.7 +0 -0
  399. casadi/libcoinmetis.la +1 -1
  400. casadi/libcoinmetis.so +0 -0
  401. casadi/libcoinmetis.so.2 +0 -0
  402. casadi/libcoinmetis.so.2.0.0 +0 -0
  403. casadi/libdaqp.so +0 -0
  404. casadi/libdaqpstat.a +0 -0
  405. casadi/libfatrop.so +0 -0
  406. casadi/libhighs.so +0 -0
  407. casadi/libhighs.so.1 +0 -0
  408. casadi/libhighs.so.1.7.2 +0 -0
  409. casadi/libindirect.a +0 -0
  410. casadi/liblinsys.a +0 -0
  411. casadi/libmatlab_ipc.so +0 -0
  412. casadi/libosqp.a +0 -0
  413. casadi/libosqp.so +0 -0
  414. casadi/libqdldl.a +0 -0
  415. casadi/libsleqp.so +0 -0
  416. casadi/libsleqp.so.1.0.1 +0 -0
  417. casadi/libspral.a +0 -0
  418. casadi/libsuperscs.a +0 -0
  419. casadi/pkgconfig/casadi.pc +1 -1
  420. casadi/pkgconfig/highs.pc +1 -1
  421. casadi/tools/__init__.py +4 -0
  422. casadi/tools/bounds.py +3 -3
  423. {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/METADATA +2 -2
  424. {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/RECORD +425 -255
  425. casadi/include/highs/fortran/highs_fortran_api.mod +0 -0
  426. casadi/libFortranHighs.so +0 -0
  427. casadi/libhighs.so.1.6 +0 -0
  428. casadi/libhighs.so.1.6.0 +0 -0
  429. {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/WHEEL +0 -0
@@ -0,0 +1,237 @@
1
+ #pragma once
2
+
3
+ #include <cassert>
4
+ #include <fstream>
5
+ #include <cstring>
6
+ #include <string>
7
+ #include <vector>
8
+
9
+ /**
10
+ * This namespace defines wrappers for std::ifstream, std::ofstream, and
11
+ * std::fstream objects. The wrappers perform the following steps:
12
+ * - check the open modes make sense
13
+ * - check that the call to open() is successful
14
+ * - (for input streams) check that the opened file is peek-able
15
+ * - turn on the badbit in the exception mask
16
+ */
17
+ namespace strict_fstream
18
+ {
19
+
20
+ // Help people out a bit, it seems like this is a common recommendation since
21
+ // musl breaks all over the place.
22
+ #if defined(__NEED_size_t) && !defined(__MUSL__)
23
+ #warning "It seems to be recommended to patch in a define for __MUSL__ if you use musl globally: https://www.openwall.com/lists/musl/2013/02/10/5"
24
+ #define __MUSL__
25
+ #endif
26
+
27
+ // Workaround for broken musl implementation
28
+ // Since musl insists that they are perfectly compatible, ironically enough,
29
+ // they don't officially have a __musl__ or similar. But __NEED_size_t is defined in their
30
+ // relevant header (and not in working implementations), so we can use that.
31
+ #ifdef __MUSL__
32
+ #warning "Working around broken strerror_r() implementation in musl, remove when musl is fixed"
33
+ #endif
34
+
35
+ // Non-gnu variants of strerror_* don't necessarily null-terminate if
36
+ // truncating, so we have to do things manually.
37
+ inline std::string trim_to_null(const std::vector<char> &buff)
38
+ {
39
+ std::string ret(buff.begin(), buff.end());
40
+
41
+ const std::string::size_type pos = ret.find('\0');
42
+ if (pos == std::string::npos) {
43
+ ret += " [...]"; // it has been truncated
44
+ } else {
45
+ ret.resize(pos);
46
+ }
47
+ return ret;
48
+ }
49
+
50
+ /// Overload of error-reporting function, to enable use with VS and non-GNU
51
+ /// POSIX libc's
52
+ /// Ref:
53
+ /// - http://stackoverflow.com/a/901316/717706
54
+ static std::string strerror()
55
+ {
56
+ // Can't use std::string since we're pre-C++17
57
+ std::vector<char> buff(256, '\0');
58
+
59
+ #ifdef _WIN32
60
+ // Since strerror_s might set errno itself, we need to store it.
61
+ const int err_num = errno;
62
+ if (strerror_s(buff.data(), buff.size(), err_num) != 0) {
63
+ return trim_to_null(buff);
64
+ } else {
65
+ return "Unknown error (" + std::to_string(err_num) + ")";
66
+ }
67
+ #elif ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && ! _GNU_SOURCE) || defined(__MUSL__)
68
+ // XSI-compliant strerror_r()
69
+ const int err_num = errno; // See above
70
+ if (strerror_r(err_num, buff.data(), buff.size()) == 0) {
71
+ return trim_to_null(buff);
72
+ } else {
73
+ return "Unknown error (" + std::to_string(err_num) + ")";
74
+ }
75
+ #else
76
+ // GNU-specific strerror_r()
77
+ char * p = strerror_r(errno, &buff[0], buff.size());
78
+ return std::string(p, std::strlen(p));
79
+ #endif
80
+ }
81
+
82
+ /// Exception class thrown by failed operations.
83
+ class Exception
84
+ : public std::exception
85
+ {
86
+ public:
87
+ Exception(const std::string& msg) : _msg(msg) {}
88
+ const char * what() const noexcept { return _msg.c_str(); }
89
+ private:
90
+ std::string _msg;
91
+ }; // class Exception
92
+
93
+ namespace detail
94
+ {
95
+
96
+ struct static_method_holder
97
+ {
98
+ static std::string mode_to_string(std::ios_base::openmode mode)
99
+ {
100
+ static const int n_modes = 6;
101
+ static const std::ios_base::openmode mode_val_v[n_modes] =
102
+ {
103
+ std::ios_base::in,
104
+ std::ios_base::out,
105
+ std::ios_base::app,
106
+ std::ios_base::ate,
107
+ std::ios_base::trunc,
108
+ std::ios_base::binary
109
+ };
110
+
111
+ static const char * mode_name_v[n_modes] =
112
+ {
113
+ "in",
114
+ "out",
115
+ "app",
116
+ "ate",
117
+ "trunc",
118
+ "binary"
119
+ };
120
+ std::string res;
121
+ for (int i = 0; i < n_modes; ++i)
122
+ {
123
+ if (mode & mode_val_v[i])
124
+ {
125
+ res += (! res.empty()? "|" : "");
126
+ res += mode_name_v[i];
127
+ }
128
+ }
129
+ if (res.empty()) res = "none";
130
+ return res;
131
+ }
132
+ static void check_mode(const std::string& filename, std::ios_base::openmode mode)
133
+ {
134
+ if ((mode & std::ios_base::trunc) && ! (mode & std::ios_base::out))
135
+ {
136
+ throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: trunc and not out");
137
+ }
138
+ else if ((mode & std::ios_base::app) && ! (mode & std::ios_base::out))
139
+ {
140
+ throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: app and not out");
141
+ }
142
+ else if ((mode & std::ios_base::trunc) && (mode & std::ios_base::app))
143
+ {
144
+ throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: trunc and app");
145
+ }
146
+ }
147
+ static void check_open(std::ios * s_p, const std::string& filename, std::ios_base::openmode mode)
148
+ {
149
+ if (s_p->fail())
150
+ {
151
+ throw Exception(std::string("strict_fstream: open('")
152
+ + filename + "'," + mode_to_string(mode) + "): open failed: "
153
+ + strerror());
154
+ }
155
+ }
156
+ static void check_peek(std::istream * is_p, const std::string& filename, std::ios_base::openmode mode)
157
+ {
158
+ bool peek_failed = true;
159
+ try
160
+ {
161
+ is_p->peek();
162
+ peek_failed = is_p->fail();
163
+ }
164
+ catch (const std::ios_base::failure &) {}
165
+ if (peek_failed)
166
+ {
167
+ throw Exception(std::string("strict_fstream: open('")
168
+ + filename + "'," + mode_to_string(mode) + "): peek failed: "
169
+ + strerror());
170
+ }
171
+ is_p->clear();
172
+ }
173
+ }; // struct static_method_holder
174
+
175
+ } // namespace detail
176
+
177
+ class ifstream
178
+ : public std::ifstream
179
+ {
180
+ public:
181
+ ifstream() = default;
182
+ ifstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
183
+ {
184
+ open(filename, mode);
185
+ }
186
+ void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
187
+ {
188
+ mode |= std::ios_base::in;
189
+ exceptions(std::ios_base::badbit);
190
+ detail::static_method_holder::check_mode(filename, mode);
191
+ std::ifstream::open(filename, mode);
192
+ detail::static_method_holder::check_open(this, filename, mode);
193
+ detail::static_method_holder::check_peek(this, filename, mode);
194
+ }
195
+ }; // class ifstream
196
+
197
+ class ofstream
198
+ : public std::ofstream
199
+ {
200
+ public:
201
+ ofstream() = default;
202
+ ofstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out)
203
+ {
204
+ open(filename, mode);
205
+ }
206
+ void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out)
207
+ {
208
+ mode |= std::ios_base::out;
209
+ exceptions(std::ios_base::badbit);
210
+ detail::static_method_holder::check_mode(filename, mode);
211
+ std::ofstream::open(filename, mode);
212
+ detail::static_method_holder::check_open(this, filename, mode);
213
+ }
214
+ }; // class ofstream
215
+
216
+ class fstream
217
+ : public std::fstream
218
+ {
219
+ public:
220
+ fstream() = default;
221
+ fstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
222
+ {
223
+ open(filename, mode);
224
+ }
225
+ void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in)
226
+ {
227
+ if (! (mode & std::ios_base::out)) mode |= std::ios_base::in;
228
+ exceptions(std::ios_base::badbit);
229
+ detail::static_method_holder::check_mode(filename, mode);
230
+ std::fstream::open(filename, mode);
231
+ detail::static_method_holder::check_open(this, filename, mode);
232
+ detail::static_method_holder::check_peek(this, filename, mode);
233
+ }
234
+ }; // class fstream
235
+
236
+ } // namespace strict_fstream
237
+
@@ -0,0 +1,472 @@
1
+ //---------------------------------------------------------
2
+ // Copyright 2015 Ontario Institute for Cancer Research
3
+ // Written by Matei David (matei@cs.toronto.edu)
4
+ //---------------------------------------------------------
5
+
6
+ // Reference:
7
+ // http://stackoverflow.com/questions/14086417/how-to-write-custom-input-stream-in-c
8
+
9
+ #pragma once
10
+
11
+ #include <zlib.h>
12
+
13
+ #include <cassert>
14
+ #include <fstream>
15
+ #include <iostream>
16
+ #include <memory>
17
+ #include <sstream>
18
+
19
+ #include "../extern/zstr/strict_fstream.hpp"
20
+
21
+ namespace zstr {
22
+
23
+ static const std::size_t default_buff_size = static_cast<std::size_t>(1 << 20);
24
+
25
+ /// Exception class thrown by failed zlib operations.
26
+ class Exception : public std::ios_base::failure {
27
+ public:
28
+ static std::string error_to_message(z_stream* zstrm_p, int ret) {
29
+ std::string msg = "zlib: ";
30
+ switch (ret) {
31
+ case Z_STREAM_ERROR:
32
+ msg += "Z_STREAM_ERROR: ";
33
+ break;
34
+ case Z_DATA_ERROR:
35
+ msg += "Z_DATA_ERROR: ";
36
+ break;
37
+ case Z_MEM_ERROR:
38
+ msg += "Z_MEM_ERROR: ";
39
+ break;
40
+ case Z_VERSION_ERROR:
41
+ msg += "Z_VERSION_ERROR: ";
42
+ break;
43
+ case Z_BUF_ERROR:
44
+ msg += "Z_BUF_ERROR: ";
45
+ break;
46
+ default:
47
+ std::ostringstream oss;
48
+ oss << ret;
49
+ msg += "[" + oss.str() + "]: ";
50
+ break;
51
+ }
52
+ if (zstrm_p->msg) {
53
+ msg += zstrm_p->msg;
54
+ }
55
+ msg +=
56
+ " ("
57
+ "next_in: " +
58
+ std::to_string(uintptr_t(zstrm_p->next_in)) +
59
+ ", avail_in: " + std::to_string(uintptr_t(zstrm_p->avail_in)) +
60
+ ", next_out: " + std::to_string(uintptr_t(zstrm_p->next_out)) +
61
+ ", avail_out: " + std::to_string(uintptr_t(zstrm_p->avail_out)) + ")";
62
+ return msg;
63
+ }
64
+
65
+ Exception(z_stream* zstrm_p, int ret)
66
+ : std::ios_base::failure(error_to_message(zstrm_p, ret)) {}
67
+ }; // class Exception
68
+
69
+ namespace detail {
70
+
71
+ class z_stream_wrapper : public z_stream {
72
+ public:
73
+ z_stream_wrapper(bool _is_input, int _level, int _window_bits)
74
+ : is_input(_is_input) {
75
+ this->zalloc = nullptr; // Z_NULL
76
+ this->zfree = nullptr; // Z_NULL
77
+ this->opaque = nullptr; // Z_NULL
78
+ int ret;
79
+ if (is_input) {
80
+ this->avail_in = 0;
81
+ this->next_in = nullptr; // Z_NULL
82
+ ret = inflateInit2(this, _window_bits ? _window_bits : 15 + 32);
83
+ } else {
84
+ ret = deflateInit2(this, _level, Z_DEFLATED,
85
+ _window_bits ? _window_bits : 15 + 16, 8,
86
+ Z_DEFAULT_STRATEGY);
87
+ }
88
+ if (ret != Z_OK) throw Exception(this, ret);
89
+ }
90
+ ~z_stream_wrapper() {
91
+ if (is_input) {
92
+ inflateEnd(this);
93
+ } else {
94
+ deflateEnd(this);
95
+ }
96
+ }
97
+
98
+ private:
99
+ bool is_input;
100
+ }; // class z_stream_wrapper
101
+
102
+ } // namespace detail
103
+
104
+ class istreambuf : public std::streambuf {
105
+ public:
106
+ istreambuf(std::streambuf* _sbuf_p,
107
+ std::size_t _buff_size = default_buff_size,
108
+ bool _auto_detect = true, int _window_bits = 0)
109
+ : sbuf_p(_sbuf_p),
110
+ in_buff(),
111
+ in_buff_start(nullptr),
112
+ in_buff_end(nullptr),
113
+ out_buff(),
114
+ zstrm_p(nullptr),
115
+ buff_size(_buff_size),
116
+ auto_detect(_auto_detect),
117
+ auto_detect_run(false),
118
+ is_text(false),
119
+ window_bits(_window_bits) {
120
+ assert(sbuf_p);
121
+ in_buff = std::unique_ptr<char[]>(new char[buff_size]);
122
+ in_buff_start = in_buff.get();
123
+ in_buff_end = in_buff.get();
124
+ out_buff = std::unique_ptr<char[]>(new char[buff_size]);
125
+ setg(out_buff.get(), out_buff.get(), out_buff.get());
126
+ }
127
+
128
+ istreambuf(const istreambuf&) = delete;
129
+ istreambuf& operator=(const istreambuf&) = delete;
130
+
131
+ pos_type seekoff(off_type off, std::ios_base::seekdir dir,
132
+ std::ios_base::openmode which) override {
133
+ if (off != 0 || dir != std::ios_base::cur) {
134
+ return std::streambuf::seekoff(off, dir, which);
135
+ }
136
+
137
+ if (!zstrm_p) {
138
+ return 0;
139
+ }
140
+
141
+ return static_cast<long int>(zstrm_p->total_out -
142
+ static_cast<uLong>(in_avail()));
143
+ }
144
+
145
+ std::streambuf::int_type underflow() override {
146
+ if (this->gptr() == this->egptr()) {
147
+ // pointers for free region in output buffer
148
+ char* out_buff_free_start = out_buff.get();
149
+ int tries = 0;
150
+ do {
151
+ if (++tries > 1000) {
152
+ throw std::ios_base::failure(
153
+ "Failed to fill buffer after 1000 tries");
154
+ }
155
+
156
+ // read more input if none available
157
+ if (in_buff_start == in_buff_end) {
158
+ // empty input buffer: refill from the start
159
+ in_buff_start = in_buff.get();
160
+ std::streamsize sz = sbuf_p->sgetn(
161
+ in_buff.get(), static_cast<std::streamsize>(buff_size));
162
+ in_buff_end = in_buff_start + sz;
163
+ if (in_buff_end == in_buff_start) break; // end of input
164
+ }
165
+ // auto detect if the stream contains text or deflate data
166
+ if (auto_detect && !auto_detect_run) {
167
+ auto_detect_run = true;
168
+ unsigned char b0 = *reinterpret_cast<unsigned char*>(in_buff_start);
169
+ unsigned char b1 =
170
+ *reinterpret_cast<unsigned char*>(in_buff_start + 1);
171
+ // Ref:
172
+ // http://en.wikipedia.org/wiki/Gzip
173
+ // http://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like
174
+ is_text = !(in_buff_start + 2 <= in_buff_end &&
175
+ ((b0 == 0x1F && b1 == 0x8B) // gzip header
176
+ || (b0 == 0x78 && (b1 == 0x01 // zlib header
177
+ || b1 == 0x9C || b1 == 0xDA))));
178
+ }
179
+ if (is_text) {
180
+ // simply swap in_buff and out_buff, and adjust pointers
181
+ assert(in_buff_start == in_buff.get());
182
+ std::swap(in_buff, out_buff);
183
+ out_buff_free_start = in_buff_end;
184
+ in_buff_start = in_buff.get();
185
+ in_buff_end = in_buff.get();
186
+ } else {
187
+ // run inflate() on input
188
+ if (!zstrm_p)
189
+ zstrm_p = std::unique_ptr<detail::z_stream_wrapper>(
190
+ new detail::z_stream_wrapper(true, Z_DEFAULT_COMPRESSION,
191
+ window_bits));
192
+ zstrm_p->next_in =
193
+ reinterpret_cast<decltype(zstrm_p->next_in)>(in_buff_start);
194
+ zstrm_p->avail_in = uint32_t(in_buff_end - in_buff_start);
195
+ zstrm_p->next_out = reinterpret_cast<decltype(zstrm_p->next_out)>(
196
+ out_buff_free_start);
197
+ zstrm_p->avail_out =
198
+ uint32_t((out_buff.get() + buff_size) - out_buff_free_start);
199
+ int ret = inflate(zstrm_p.get(), Z_NO_FLUSH);
200
+ // process return code
201
+ if (ret != Z_OK && ret != Z_STREAM_END)
202
+ throw Exception(zstrm_p.get(), ret);
203
+ // update in&out pointers following inflate()
204
+ in_buff_start =
205
+ reinterpret_cast<decltype(in_buff_start)>(zstrm_p->next_in);
206
+ in_buff_end = in_buff_start + zstrm_p->avail_in;
207
+ out_buff_free_start = reinterpret_cast<decltype(out_buff_free_start)>(
208
+ zstrm_p->next_out);
209
+ assert(out_buff_free_start + zstrm_p->avail_out ==
210
+ out_buff.get() + buff_size);
211
+
212
+ if (ret == Z_STREAM_END) {
213
+ // if stream ended, deallocate inflator
214
+ zstrm_p.reset();
215
+ }
216
+ }
217
+ } while (out_buff_free_start == out_buff.get());
218
+ // 2 exit conditions:
219
+ // - end of input: there might or might not be output available
220
+ // - out_buff_free_start != out_buff: output available
221
+ this->setg(out_buff.get(), out_buff.get(), out_buff_free_start);
222
+ }
223
+ return this->gptr() == this->egptr()
224
+ ? traits_type::eof()
225
+ : traits_type::to_int_type(*this->gptr());
226
+ }
227
+
228
+ private:
229
+ std::streambuf* sbuf_p;
230
+ std::unique_ptr<char[]> in_buff;
231
+ char* in_buff_start;
232
+ char* in_buff_end;
233
+ std::unique_ptr<char[]> out_buff;
234
+ std::unique_ptr<detail::z_stream_wrapper> zstrm_p;
235
+ std::size_t buff_size;
236
+ bool auto_detect;
237
+ bool auto_detect_run;
238
+ bool is_text;
239
+ int window_bits;
240
+
241
+ }; // class istreambuf
242
+
243
+ class ostreambuf : public std::streambuf {
244
+ public:
245
+ ostreambuf(std::streambuf* _sbuf_p,
246
+ std::size_t _buff_size = default_buff_size,
247
+ int _level = Z_DEFAULT_COMPRESSION, int _window_bits = 0)
248
+ : sbuf_p(_sbuf_p),
249
+ in_buff(),
250
+ out_buff(),
251
+ zstrm_p(new detail::z_stream_wrapper(false, _level, _window_bits)),
252
+ buff_size(_buff_size) {
253
+ assert(sbuf_p);
254
+ in_buff = std::unique_ptr<char[]>(new char[buff_size]);
255
+ out_buff = std::unique_ptr<char[]>(new char[buff_size]);
256
+ setp(in_buff.get(), in_buff.get() + buff_size);
257
+ }
258
+
259
+ ostreambuf(const ostreambuf&) = delete;
260
+ ostreambuf& operator=(const ostreambuf&) = delete;
261
+
262
+ int deflate_loop(int flush) {
263
+ while (true) {
264
+ zstrm_p->next_out =
265
+ reinterpret_cast<decltype(zstrm_p->next_out)>(out_buff.get());
266
+ zstrm_p->avail_out = uint32_t(buff_size);
267
+ int ret = deflate(zstrm_p.get(), flush);
268
+ if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) {
269
+ failed = true;
270
+ throw Exception(zstrm_p.get(), ret);
271
+ }
272
+ std::streamsize sz = sbuf_p->sputn(
273
+ out_buff.get(),
274
+ reinterpret_cast<decltype(out_buff.get())>(zstrm_p->next_out) -
275
+ out_buff.get());
276
+ if (sz != reinterpret_cast<decltype(out_buff.get())>(zstrm_p->next_out) -
277
+ out_buff.get()) {
278
+ // there was an error in the sink stream
279
+ return -1;
280
+ }
281
+ if (ret == Z_STREAM_END || ret == Z_BUF_ERROR || sz == 0) {
282
+ break;
283
+ }
284
+ }
285
+ return 0;
286
+ }
287
+
288
+ virtual ~ostreambuf() {
289
+ // flush the zlib stream
290
+ //
291
+ // NOTE: Errors here (sync() return value not 0) are ignored, because we
292
+ // cannot throw in a destructor. This mirrors the behaviour of
293
+ // std::basic_filebuf::~basic_filebuf(). To see an exception on error,
294
+ // close the ofstream with an explicit call to close(), and do not rely
295
+ // on the implicit call in the destructor.
296
+ //
297
+ if (!failed) try {
298
+ sync();
299
+ } catch (...) {
300
+ }
301
+ }
302
+ std::streambuf::int_type overflow(
303
+ std::streambuf::int_type c = traits_type::eof()) override {
304
+ zstrm_p->next_in = reinterpret_cast<decltype(zstrm_p->next_in)>(pbase());
305
+ zstrm_p->avail_in = uint32_t(pptr() - pbase());
306
+ while (zstrm_p->avail_in > 0) {
307
+ int r = deflate_loop(Z_NO_FLUSH);
308
+ if (r != 0) {
309
+ setp(nullptr, nullptr);
310
+ return traits_type::eof();
311
+ }
312
+ }
313
+ setp(in_buff.get(), in_buff.get() + buff_size);
314
+ return traits_type::eq_int_type(c, traits_type::eof())
315
+ ? traits_type::eof()
316
+ : sputc(char_type(c));
317
+ }
318
+ int sync() override {
319
+ // first, call overflow to clear in_buff
320
+ overflow();
321
+ if (!pptr()) return -1;
322
+ // then, call deflate asking to finish the zlib stream
323
+ zstrm_p->next_in = nullptr;
324
+ zstrm_p->avail_in = 0;
325
+ if (deflate_loop(Z_FINISH) != 0) return -1;
326
+ deflateReset(zstrm_p.get());
327
+ return 0;
328
+ }
329
+
330
+ private:
331
+ std::streambuf* sbuf_p = nullptr;
332
+ std::unique_ptr<char[]> in_buff;
333
+ std::unique_ptr<char[]> out_buff;
334
+ std::unique_ptr<detail::z_stream_wrapper> zstrm_p;
335
+ std::size_t buff_size;
336
+ bool failed = false;
337
+
338
+ }; // class ostreambuf
339
+
340
+ class istream : public std::istream {
341
+ public:
342
+ istream(std::istream& is, std::size_t _buff_size = default_buff_size,
343
+ bool _auto_detect = true, int _window_bits = 0)
344
+ : std::istream(new istreambuf(is.rdbuf(), _buff_size, _auto_detect,
345
+ _window_bits)) {
346
+ exceptions(std::ios_base::badbit);
347
+ }
348
+ explicit istream(std::streambuf* sbuf_p)
349
+ : std::istream(new istreambuf(sbuf_p)) {
350
+ exceptions(std::ios_base::badbit);
351
+ }
352
+ virtual ~istream() { delete rdbuf(); }
353
+ }; // class istream
354
+
355
+ class ostream : public std::ostream {
356
+ public:
357
+ ostream(std::ostream& os, std::size_t _buff_size = default_buff_size,
358
+ int _level = Z_DEFAULT_COMPRESSION, int _window_bits = 0)
359
+ : std::ostream(
360
+ new ostreambuf(os.rdbuf(), _buff_size, _level, _window_bits)) {
361
+ exceptions(std::ios_base::badbit);
362
+ }
363
+ explicit ostream(std::streambuf* sbuf_p)
364
+ : std::ostream(new ostreambuf(sbuf_p)) {
365
+ exceptions(std::ios_base::badbit);
366
+ }
367
+ virtual ~ostream() { delete rdbuf(); }
368
+ }; // class ostream
369
+
370
+ namespace detail {
371
+
372
+ template <typename FStream_Type>
373
+ struct strict_fstream_holder {
374
+ strict_fstream_holder(const std::string& filename,
375
+ std::ios_base::openmode mode = std::ios_base::in)
376
+ : _fs(filename, mode) {}
377
+ strict_fstream_holder() = default;
378
+ FStream_Type _fs{};
379
+ }; // class strict_fstream_holder
380
+
381
+ } // namespace detail
382
+
383
+ class ifstream
384
+ : private detail::strict_fstream_holder<strict_fstream::ifstream>,
385
+ public std::istream {
386
+ public:
387
+ explicit ifstream(const std::string filename,
388
+ std::ios_base::openmode mode = std::ios_base::in,
389
+ size_t buff_size = default_buff_size)
390
+ : detail::strict_fstream_holder<strict_fstream::ifstream>(
391
+ filename, mode
392
+ #ifdef _WIN32 // to avoid problems with conversion of \r\n, only windows as
393
+ // otherwise there are problems on mac
394
+ | std::ios_base::binary
395
+ #endif
396
+ ),
397
+ std::istream(new istreambuf(_fs.rdbuf(), buff_size)) {
398
+ exceptions(std::ios_base::badbit);
399
+ }
400
+ explicit ifstream()
401
+ : detail::strict_fstream_holder<strict_fstream::ifstream>(),
402
+ std::istream(new istreambuf(_fs.rdbuf())) {}
403
+ void close() { _fs.close(); }
404
+ void open(const std::string filename,
405
+ std::ios_base::openmode mode = std::ios_base::in) {
406
+ _fs.open(filename, mode
407
+ #ifdef _WIN32 // to avoid problems with conversion of \r\n, only windows as
408
+ // otherwise there are problems on mac
409
+ | std::ios_base::binary
410
+ #endif
411
+ );
412
+ // make sure the previous buffer is deleted by putting it into a unique_ptr
413
+ // and set a new one after opening file
414
+ std::unique_ptr<std::streambuf> oldbuf(rdbuf(new istreambuf(_fs.rdbuf())));
415
+ // call move assignment operator on istream which does not alter the stream
416
+ // buffer
417
+ std::istream::operator=(std::istream(rdbuf()));
418
+ }
419
+ bool is_open() const { return _fs.is_open(); }
420
+ virtual ~ifstream() {
421
+ if (_fs.is_open()) close();
422
+ if (rdbuf()) delete rdbuf();
423
+ }
424
+
425
+ /// Return the position within the compressed file (wrapped filestream)
426
+ std::streampos compressed_tellg() { return _fs.tellg(); }
427
+ }; // class ifstream
428
+
429
+ class ofstream
430
+ : private detail::strict_fstream_holder<strict_fstream::ofstream>,
431
+ public std::ostream {
432
+ public:
433
+ explicit ofstream(const std::string filename,
434
+ std::ios_base::openmode mode = std::ios_base::out,
435
+ int level = Z_DEFAULT_COMPRESSION,
436
+ size_t buff_size = default_buff_size)
437
+ : detail::strict_fstream_holder<strict_fstream::ofstream>(
438
+ filename, mode | std::ios_base::binary),
439
+ std::ostream(new ostreambuf(_fs.rdbuf(), buff_size, level)) {
440
+ exceptions(std::ios_base::badbit);
441
+ }
442
+ explicit ofstream()
443
+ : detail::strict_fstream_holder<strict_fstream::ofstream>(),
444
+ std::ostream(new ostreambuf(_fs.rdbuf())) {}
445
+ void close() {
446
+ std::ostream::flush();
447
+ _fs.close();
448
+ }
449
+ void open(const std::string filename,
450
+ std::ios_base::openmode mode = std::ios_base::out,
451
+ int level = Z_DEFAULT_COMPRESSION) {
452
+ flush();
453
+ _fs.open(filename, mode | std::ios_base::binary);
454
+ std::ostream::operator=(
455
+ std::ostream(new ostreambuf(_fs.rdbuf(), default_buff_size, level)));
456
+ }
457
+ bool is_open() const { return _fs.is_open(); }
458
+ ofstream& flush() {
459
+ std::ostream::flush();
460
+ _fs.flush();
461
+ return *this;
462
+ }
463
+ virtual ~ofstream() {
464
+ if (_fs.is_open()) close();
465
+ if (rdbuf()) delete rdbuf();
466
+ }
467
+
468
+ // Return the position within the compressed file (wrapped filestream)
469
+ std::streampos compressed_tellp() { return _fs.tellp(); }
470
+ }; // class ofstream
471
+
472
+ } // namespace zstr