sleipnirgroup-jormungandr 0.6.7.dev177__tar.gz → 0.6.7.dev179__tar.gz
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.
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/PKG-INFO +1 -1
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/Pybind11MkdocPostprocess.cmake +3 -2
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_real.cpp +90 -14
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_real_matrix.cpp +31 -12
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_real_submatrix.cpp +47 -44
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/docstrings.hpp +2 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/main.cpp +13 -7
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/bind_problem.cpp +6 -3
- sleipnirgroup_jormungandr-0.6.7.dev179/python/cpp/real_scalar.hpp +109 -0
- sleipnirgroup_jormungandr-0.6.7.dev179/python/cpp/real_scalar_comparisons.hpp +47 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/src/sleipnir/__init__.py +1 -1
- sleipnirgroup_jormungandr-0.6.7.dev179/python/test/autodiff/real_test.py +172 -0
- sleipnirgroup_jormungandr-0.6.7.dev177/python/test/autodiff/real_test.py +0 -85
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/CMakeLists.txt +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/LICENSE.txt +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/README.md +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/SleipnirConfig.cmake.in +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/BuildTypes.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/CompilerFlags.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/Pybind11Mkdoc.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/SubdirList.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/aarch64-linux-gnu.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/cmake/arm-none-eabi.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/expression.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/expression_functions.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/expression_graph.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/expression_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/gradient.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/hessian.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/jacobian.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/real.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/real_matrix.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/real_submatrix.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/sleipnir_base.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/autodiff/slice.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/multistart.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/ocp/dynamics_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/ocp/timestep_method.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/ocp/transcription_method.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/ocp.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/problem.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/control_flow.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/exit_status.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/ipm.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/ipm_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/iteration_info.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/newton.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/newton_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/options.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/sqp.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/sqp_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/all_finite.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/append_as_triplets.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/barrier_parameter.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/bounds.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/constraint_violation.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/dense_kkt_solver.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/feasibility_restoration.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/feasibility_restoration_cycle_detector.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/filter.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/first_derivatives.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/fraction_to_the_boundary_rule.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/function_values.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/iterates.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/kkt_error.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/kkt_solver.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/kkt_system.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/problem_scaling.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/regularization_limits.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/ruiz_equilibration.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/sparse_inf_norms.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/sparse_kkt_solver.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/step.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/optimization/solver/util/time_trace.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/assert.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/concepts.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/empty.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/force_inline.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/function_ref.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/intrusive_shared_ptr.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/pool.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/print.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/print_diagnostics.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/scope_exit.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/spy.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/symbol_exports.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/include/sleipnir/util/time_tracer.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/pyproject.toml +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/.clang-tidy +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/arity.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_expression_type.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_gradient.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_hessian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/autodiff/bind_jacobian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/binders.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/for_each_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/numpy_ops.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/bind_equality_constraints.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/bind_inequality_constraints.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/bind_ocp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/ocp/bind_dynamics_type.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/ocp/bind_timestep_method.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/ocp/bind_transcription_method.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/solver/bind_exit_status.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/optimization/solver/bind_iteration_info.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/slice_tuple.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/text_wrap.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/cpp/try_cast.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/postprocess_stubs.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/src/sleipnir/autodiff/__init__.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/src/sleipnir/optimization/__init__.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/autodiff/gradient_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/autodiff/hessian_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/autodiff/jacobian_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/autodiff/real_matrix_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/arm_on_elevator_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/cart_pole_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/cart_pole_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/cart_pole_util.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/constraints_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/differential_drive_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/differential_drive_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/differential_drive_util.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/double_integrator_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/flywheel_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/flywheel_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/flywheel_util.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/linear_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/multistart_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/nonlinear_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/problem_spy_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/problem_variable_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/quadratic_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/rk4.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/solver/exit_status_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/tolerance.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/python/test/optimization/trivial_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/autodiff/gradient.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/autodiff/hessian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/autodiff/jacobian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/autodiff/real_matrix.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/optimization/ocp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/optimization/problem.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/optimization/solver/ipm.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/optimization/solver/newton.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/optimization/solver/sqp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev177 → sleipnirgroup_jormungandr-0.6.7.dev179}/src/util/pool.cpp +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Replaces pybind11_mkdoc's docstring pointers with constexpr arrays
|
|
1
|
+
# Replaces pybind11_mkdoc's docstring pointers with constexpr arrays and adds an
|
|
2
|
+
# include guard
|
|
2
3
|
#
|
|
3
4
|
# Usage: cmake -DFILE=<docstrings.hpp> -P Pybind11MkdocPostprocess.cmake
|
|
4
5
|
|
|
@@ -9,4 +10,4 @@ string(
|
|
|
9
10
|
contents
|
|
10
11
|
"${contents}"
|
|
11
12
|
)
|
|
12
|
-
file(WRITE ${FILE} "${contents}")
|
|
13
|
+
file(WRITE ${FILE} "#pragma once\n\n${contents}")
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
#include "docstrings.hpp"
|
|
17
17
|
#include "for_each_type.hpp"
|
|
18
18
|
#include "numpy_ops.hpp"
|
|
19
|
+
#include "real_scalar.hpp"
|
|
20
|
+
#include "real_scalar_comparisons.hpp"
|
|
19
21
|
|
|
20
22
|
namespace nb = nanobind;
|
|
21
23
|
|
|
@@ -31,9 +33,11 @@ namespace slp {
|
|
|
31
33
|
template <typename F, typename... Args>
|
|
32
34
|
void def_unary_math(nb::module_& autodiff, const char* name, F&& f,
|
|
33
35
|
Args&&... args) {
|
|
34
|
-
//
|
|
36
|
+
// Python real number overload. RealScalar rejects complex NumPy scalars,
|
|
37
|
+
// which double's caster converts by dropping the imaginary part.
|
|
35
38
|
autodiff.def(
|
|
36
|
-
name, [=](
|
|
39
|
+
name, [=](RealScalar x) { return f(x.value); },
|
|
40
|
+
std::forward<Args>(args)...);
|
|
37
41
|
|
|
38
42
|
// Real overload
|
|
39
43
|
autodiff.def(name, f, std::forward<Args>(args)...);
|
|
@@ -57,13 +61,14 @@ template <typename F, typename... Args>
|
|
|
57
61
|
void def_binary_math(nb::module_& autodiff, const char* name, F&& f,
|
|
58
62
|
Args&&... args) {
|
|
59
63
|
using V = Real<double>;
|
|
60
|
-
for_each_type<
|
|
61
|
-
for_each_type<
|
|
64
|
+
for_each_type<RealScalar, const V&>([&]<typename L> {
|
|
65
|
+
for_each_type<RealScalar, const V&>([&]<typename R> {
|
|
62
66
|
if constexpr (std::same_as<L, const V&> && std::same_as<R, const V&>) {
|
|
63
67
|
autodiff.def(name, f, std::forward<Args>(args)...);
|
|
64
68
|
} else {
|
|
65
69
|
autodiff.def(
|
|
66
|
-
name,
|
|
70
|
+
name,
|
|
71
|
+
[=](L&& l, R&& r) { return f(unwrap_scalar(l), unwrap_scalar(r)); },
|
|
67
72
|
std::forward<Args>(args)...);
|
|
68
73
|
}
|
|
69
74
|
});
|
|
@@ -75,15 +80,18 @@ template <typename F, typename... Args>
|
|
|
75
80
|
void def_ternary_math(nb::module_& autodiff, const char* name, F&& f,
|
|
76
81
|
Args&&... args) {
|
|
77
82
|
using V = Real<double>;
|
|
78
|
-
for_each_type<
|
|
79
|
-
for_each_type<
|
|
80
|
-
for_each_type<
|
|
83
|
+
for_each_type<RealScalar, const V&>([&]<typename L> {
|
|
84
|
+
for_each_type<RealScalar, const V&>([&]<typename M> {
|
|
85
|
+
for_each_type<RealScalar, const V&>([&]<typename R> {
|
|
81
86
|
if constexpr (std::same_as<L, const V&> && std::same_as<M, const V&> &&
|
|
82
87
|
std::same_as<R, const V&>) {
|
|
83
88
|
autodiff.def(name, f, std::forward<Args>(args)...);
|
|
84
89
|
} else {
|
|
85
90
|
autodiff.def(
|
|
86
|
-
name,
|
|
91
|
+
name,
|
|
92
|
+
[=](L&& l, M&& m, R&& r) {
|
|
93
|
+
return f(unwrap_scalar(l), unwrap_scalar(m), unwrap_scalar(r));
|
|
94
|
+
},
|
|
87
95
|
std::forward<Args>(args)...);
|
|
88
96
|
}
|
|
89
97
|
});
|
|
@@ -91,17 +99,84 @@ void def_ternary_math(nb::module_& autodiff, const char* name, F&& f,
|
|
|
91
99
|
});
|
|
92
100
|
}
|
|
93
101
|
|
|
102
|
+
/// Bind arithmetic operators between Real and Python real numbers.
|
|
103
|
+
///
|
|
104
|
+
/// RealScalar rejects complex NumPy scalars, so they reach the complex
|
|
105
|
+
/// overloads instead of dropping their imaginary part. nanobind's operator
|
|
106
|
+
/// templates need a C++ operator for the argument type, so these unwrap the
|
|
107
|
+
/// RealScalar themselves.
|
|
108
|
+
///
|
|
109
|
+
/// @param cls The Real class.
|
|
110
|
+
void def_real_scalar_arithmetic(nb::class_<Real<double>>& cls) {
|
|
111
|
+
using namespace nb::literals;
|
|
112
|
+
|
|
113
|
+
using V = Real<double>;
|
|
114
|
+
using R = RealScalar;
|
|
115
|
+
|
|
116
|
+
cls.def(
|
|
117
|
+
"__mul__", [](const V& lhs, R rhs) { return lhs * rhs.value; },
|
|
118
|
+
nb::is_operator(), "rhs"_a);
|
|
119
|
+
cls.def(
|
|
120
|
+
"__imul__", [](V& lhs, R rhs) -> V& { return lhs *= rhs.value; },
|
|
121
|
+
nb::is_operator(), nb::rv_policy::move, "rhs"_a,
|
|
122
|
+
DOC(slp, Real, operator, imul));
|
|
123
|
+
cls.def(
|
|
124
|
+
"__truediv__", [](const V& lhs, R rhs) { return lhs / rhs.value; },
|
|
125
|
+
nb::is_operator(), "rhs"_a);
|
|
126
|
+
cls.def(
|
|
127
|
+
"__itruediv__", [](V& lhs, R rhs) -> V& { return lhs /= rhs.value; },
|
|
128
|
+
nb::is_operator(), nb::rv_policy::move, "rhs"_a,
|
|
129
|
+
DOC(slp, Real, operator, idiv));
|
|
130
|
+
cls.def(
|
|
131
|
+
"__add__", [](const V& lhs, R rhs) { return lhs + rhs.value; },
|
|
132
|
+
nb::is_operator(), "rhs"_a);
|
|
133
|
+
cls.def(
|
|
134
|
+
"__iadd__", [](V& lhs, R rhs) -> V& { return lhs += rhs.value; },
|
|
135
|
+
nb::is_operator(), nb::rv_policy::move, "rhs"_a,
|
|
136
|
+
DOC(slp, Real, operator, iadd));
|
|
137
|
+
cls.def(
|
|
138
|
+
"__sub__", [](const V& lhs, R rhs) { return lhs - rhs.value; },
|
|
139
|
+
nb::is_operator(), "rhs"_a);
|
|
140
|
+
cls.def(
|
|
141
|
+
"__isub__", [](V& lhs, R rhs) -> V& { return lhs -= rhs.value; },
|
|
142
|
+
nb::is_operator(), nb::rv_policy::move, "rhs"_a,
|
|
143
|
+
DOC(slp, Real, operator, isub));
|
|
144
|
+
cls.def(
|
|
145
|
+
"__rmul__", [](const V& rhs, R lhs) { return lhs.value * rhs; },
|
|
146
|
+
nb::is_operator(), "lhs"_a);
|
|
147
|
+
cls.def(
|
|
148
|
+
"__rtruediv__", [](const V& rhs, R lhs) { return lhs.value / rhs; },
|
|
149
|
+
nb::is_operator(), "lhs"_a);
|
|
150
|
+
cls.def(
|
|
151
|
+
"__radd__", [](const V& rhs, R lhs) { return lhs.value + rhs; },
|
|
152
|
+
nb::is_operator(), "lhs"_a);
|
|
153
|
+
cls.def(
|
|
154
|
+
"__rsub__", [](const V& rhs, R lhs) { return lhs.value - rhs; },
|
|
155
|
+
nb::is_operator(), "lhs"_a);
|
|
156
|
+
}
|
|
157
|
+
|
|
94
158
|
void bind_real(nb::module_& autodiff, nb::class_<Real<double>>& cls) {
|
|
95
159
|
using namespace nb::literals;
|
|
96
160
|
|
|
97
161
|
cls.def(nb::init<>(), DOC(slp, Real, Real));
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
162
|
+
// RealScalar rejects complex NumPy scalars and arrays, which double's caster
|
|
163
|
+
// converts by dropping the imaginary part
|
|
164
|
+
cls.def(
|
|
165
|
+
"__init__",
|
|
166
|
+
[](Real<double>* self, RealScalar value) {
|
|
167
|
+
new (self) Real<double>{value.value};
|
|
168
|
+
},
|
|
169
|
+
"value"_a, DOC(slp, Real, Real, 2));
|
|
170
|
+
nb::implicitly_convertible<RealScalar, Real<double>>();
|
|
171
|
+
cls.def(
|
|
172
|
+
"set_value",
|
|
173
|
+
[](Real<double>& self, RealScalar value) { self.set_value(value.value); },
|
|
174
|
+
"value"_a, DOC(slp, Real, set_value));
|
|
101
175
|
cls.def("value", &Real<double>::value, DOC(slp, Real, value));
|
|
102
176
|
cls.def("type", &Real<double>::type, DOC(slp, Real, type));
|
|
103
177
|
|
|
104
|
-
|
|
178
|
+
def_real_scalar_arithmetic(cls);
|
|
179
|
+
for_each_type<nb::detail::self_t, int>([&]<typename T> {
|
|
105
180
|
cls.def(nb::self * T(), "rhs"_a);
|
|
106
181
|
cls.def(nb::self *= T(), "rhs"_a, DOC(slp, Real, operator, imul));
|
|
107
182
|
cls.def(nb::self / T(), "rhs"_a);
|
|
@@ -213,7 +288,8 @@ void bind_real(nb::module_& autodiff, nb::class_<Real<double>>& cls) {
|
|
|
213
288
|
cls.def(+nb::self);
|
|
214
289
|
|
|
215
290
|
// Comparison operators
|
|
216
|
-
|
|
291
|
+
def_real_scalar_comparisons(cls);
|
|
292
|
+
for_each_type<nb::detail::self_t, int>([&]<typename T> {
|
|
217
293
|
cls.def(nb::self == T(), "rhs"_a, DOC(slp, operator, eq));
|
|
218
294
|
cls.def(nb::self < T(), "rhs"_a, DOC(slp, operator, lt));
|
|
219
295
|
cls.def(nb::self <= T(), "rhs"_a, DOC(slp, operator, le));
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
#include "docstrings.hpp"
|
|
32
32
|
#include "for_each_type.hpp"
|
|
33
33
|
#include "numpy_ops.hpp"
|
|
34
|
+
#include "real_scalar.hpp"
|
|
35
|
+
#include "real_scalar_comparisons.hpp"
|
|
34
36
|
#include "slice_tuple.hpp"
|
|
35
37
|
#include "try_cast.hpp"
|
|
36
38
|
|
|
@@ -48,8 +50,24 @@ void bind_real_matrix(nb::module_& autodiff,
|
|
|
48
50
|
DOC(slp, RealMatrix, RealMatrix, 3));
|
|
49
51
|
cls.def(nb::init<const std::vector<std::vector<Real<double>>>&>(), "list"_a,
|
|
50
52
|
DOC(slp, RealMatrix, RealMatrix, 5));
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
// RealScalar rejects complex NumPy scalars, which double's caster converts by
|
|
54
|
+
// dropping the imaginary part
|
|
55
|
+
cls.def(
|
|
56
|
+
"__init__",
|
|
57
|
+
[](RealMatrix<double>* self,
|
|
58
|
+
const std::vector<std::vector<RealScalar>>& list) {
|
|
59
|
+
std::vector<std::vector<double>> values;
|
|
60
|
+
values.reserve(list.size());
|
|
61
|
+
for (const auto& row : list) {
|
|
62
|
+
auto& values_row = values.emplace_back();
|
|
63
|
+
values_row.reserve(row.size());
|
|
64
|
+
for (const auto& elem : row) {
|
|
65
|
+
values_row.emplace_back(elem.value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
new (self) RealMatrix<double>(values);
|
|
69
|
+
},
|
|
70
|
+
"list"_a, DOC(slp, RealMatrix, RealMatrix, 6));
|
|
53
71
|
cls.def(nb::init<nb::DRef<Eigen::MatrixXd>>(), "values"_a,
|
|
54
72
|
DOC(slp, RealMatrix, RealMatrix, 8));
|
|
55
73
|
cls.def(nb::init<nb::DRef<Eigen::MatrixXf>>(), "values"_a,
|
|
@@ -317,14 +335,14 @@ void bind_real_matrix(nb::module_& autodiff,
|
|
|
317
335
|
cls.def(nb::self / Real<double>(), "rhs"_a);
|
|
318
336
|
cls.def(nb::self /= Real<double>(), "rhs"_a,
|
|
319
337
|
DOC(slp, RealMatrix, operator, idiv));
|
|
320
|
-
for_each_type<
|
|
338
|
+
for_each_type<RealScalar, int, const Real<double>&,
|
|
321
339
|
const RealSubmatrix<RealMatrix<double>>,
|
|
322
340
|
nb::DRef<Eigen::MatrixXd>>([&]<typename T> {
|
|
323
341
|
cls.def(
|
|
324
342
|
"__add__",
|
|
325
343
|
[](const RealMatrix<double>& lhs, T&& rhs) {
|
|
326
|
-
if constexpr (
|
|
327
|
-
return lhs + Real<double>{rhs};
|
|
344
|
+
if constexpr (!MatrixLike<T>) {
|
|
345
|
+
return lhs + Real<double>{unwrap_scalar(rhs)};
|
|
328
346
|
} else {
|
|
329
347
|
return lhs + rhs;
|
|
330
348
|
}
|
|
@@ -333,8 +351,8 @@ void bind_real_matrix(nb::module_& autodiff,
|
|
|
333
351
|
cls.def(
|
|
334
352
|
"__radd__",
|
|
335
353
|
[](const RealMatrix<double>& rhs, T&& lhs) {
|
|
336
|
-
if constexpr (
|
|
337
|
-
return Real<double>{lhs} + rhs;
|
|
354
|
+
if constexpr (!MatrixLike<T>) {
|
|
355
|
+
return Real<double>{unwrap_scalar(lhs)} + rhs;
|
|
338
356
|
} else {
|
|
339
357
|
return lhs + rhs;
|
|
340
358
|
}
|
|
@@ -343,8 +361,8 @@ void bind_real_matrix(nb::module_& autodiff,
|
|
|
343
361
|
cls.def(
|
|
344
362
|
"__sub__",
|
|
345
363
|
[](const RealMatrix<double>& lhs, T&& rhs) {
|
|
346
|
-
if constexpr (
|
|
347
|
-
return lhs - Real<double>{rhs};
|
|
364
|
+
if constexpr (!MatrixLike<T>) {
|
|
365
|
+
return lhs - Real<double>{unwrap_scalar(rhs)};
|
|
348
366
|
} else {
|
|
349
367
|
return lhs - rhs;
|
|
350
368
|
}
|
|
@@ -353,8 +371,8 @@ void bind_real_matrix(nb::module_& autodiff,
|
|
|
353
371
|
cls.def(
|
|
354
372
|
"__rsub__",
|
|
355
373
|
[](const RealMatrix<double>& rhs, T&& lhs) {
|
|
356
|
-
if constexpr (
|
|
357
|
-
return Real<double>{lhs} - rhs;
|
|
374
|
+
if constexpr (!MatrixLike<T>) {
|
|
375
|
+
return Real<double>{unwrap_scalar(lhs)} - rhs;
|
|
358
376
|
} else {
|
|
359
377
|
return lhs - rhs;
|
|
360
378
|
}
|
|
@@ -400,7 +418,8 @@ void bind_real_matrix(nb::module_& autodiff,
|
|
|
400
418
|
"constant"_a, DOC(slp, RealMatrix, constant));
|
|
401
419
|
|
|
402
420
|
// Comparison operators
|
|
403
|
-
|
|
421
|
+
def_real_scalar_comparisons(cls);
|
|
422
|
+
for_each_type<nb::detail::self_t, int, Real<double>>([&]<typename T> {
|
|
404
423
|
cls.def(nb::self == T(), "rhs"_a, DOC(slp, operator, eq));
|
|
405
424
|
cls.def(nb::self < T(), "rhs"_a, DOC(slp, operator, lt));
|
|
406
425
|
cls.def(nb::self <= T(), "rhs"_a, DOC(slp, operator, le));
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
#include "docstrings.hpp"
|
|
31
31
|
#include "for_each_type.hpp"
|
|
32
32
|
#include "numpy_ops.hpp"
|
|
33
|
+
#include "real_scalar.hpp"
|
|
34
|
+
#include "real_scalar_comparisons.hpp"
|
|
33
35
|
#include "slice_tuple.hpp"
|
|
34
36
|
#include "try_cast.hpp"
|
|
35
37
|
|
|
@@ -284,49 +286,49 @@ void bind_real_submatrix(nb::class_<RealSubmatrix<RealMatrix<double>>>& cls) {
|
|
|
284
286
|
cls.def(nb::self / Real<double>(), "rhs"_a);
|
|
285
287
|
cls.def(nb::self /= Real<double>(), "rhs"_a,
|
|
286
288
|
DOC(slp, RealSubmatrix, operator, idiv));
|
|
287
|
-
for_each_type<
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
289
|
+
for_each_type<RealScalar, int, const Real<double>&,
|
|
290
|
+
nb::DRef<Eigen::MatrixXd>>([&]<typename T> {
|
|
291
|
+
cls.def(
|
|
292
|
+
"__add__",
|
|
293
|
+
[](const RealSubmatrix<RealMatrix<double>>& lhs, T&& rhs) {
|
|
294
|
+
if constexpr (!MatrixLike<T>) {
|
|
295
|
+
return lhs + Real<double>{unwrap_scalar(rhs)};
|
|
296
|
+
} else {
|
|
297
|
+
return lhs + rhs;
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
nb::is_operator(), "rhs"_a);
|
|
301
|
+
cls.def(
|
|
302
|
+
"__radd__",
|
|
303
|
+
[](const RealSubmatrix<RealMatrix<double>>& rhs, T&& lhs) {
|
|
304
|
+
if constexpr (!MatrixLike<T>) {
|
|
305
|
+
return Real<double>{unwrap_scalar(lhs)} + rhs;
|
|
306
|
+
} else {
|
|
307
|
+
return lhs + rhs;
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
nb::is_operator(), "lhs"_a);
|
|
311
|
+
cls.def(
|
|
312
|
+
"__sub__",
|
|
313
|
+
[](const RealSubmatrix<RealMatrix<double>>& lhs, T&& rhs) {
|
|
314
|
+
if constexpr (!MatrixLike<T>) {
|
|
315
|
+
return lhs - Real<double>{unwrap_scalar(rhs)};
|
|
316
|
+
} else {
|
|
317
|
+
return lhs - rhs;
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
nb::is_operator(), "rhs"_a);
|
|
321
|
+
cls.def(
|
|
322
|
+
"__rsub__",
|
|
323
|
+
[](const RealSubmatrix<RealMatrix<double>>& rhs, T&& lhs) {
|
|
324
|
+
if constexpr (!MatrixLike<T>) {
|
|
325
|
+
return Real<double>{unwrap_scalar(lhs)} - rhs;
|
|
326
|
+
} else {
|
|
327
|
+
return lhs - rhs;
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
nb::is_operator(), "lhs"_a);
|
|
331
|
+
});
|
|
330
332
|
|
|
331
333
|
cls.def(
|
|
332
334
|
"__pow__",
|
|
@@ -367,7 +369,8 @@ void bind_real_submatrix(nb::class_<RealSubmatrix<RealMatrix<double>>>& cls) {
|
|
|
367
369
|
DOC(slp, RealSubmatrix, exp));
|
|
368
370
|
|
|
369
371
|
// Comparison operators
|
|
370
|
-
|
|
372
|
+
def_real_scalar_comparisons(cls);
|
|
373
|
+
for_each_type<nb::detail::self_t, int, Real<double>>([&]<typename T> {
|
|
371
374
|
cls.def(nb::self == T(), "rhs"_a, DOC(slp, operator, eq));
|
|
372
375
|
cls.def(nb::self < T(), "rhs"_a, DOC(slp, operator, lt));
|
|
373
376
|
cls.def(nb::self <= T(), "rhs"_a, DOC(slp, operator, le));
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
#include "binders.hpp"
|
|
21
21
|
#include "docstrings.hpp"
|
|
22
22
|
#include "for_each_type.hpp"
|
|
23
|
+
#include "real_scalar.hpp"
|
|
23
24
|
|
|
24
25
|
namespace nb = nanobind;
|
|
25
26
|
|
|
@@ -56,17 +57,22 @@ NB_MODULE(_sleipnir, m) {
|
|
|
56
57
|
optimization, "InequalityConstraints", DOC(slp_InequalityConstraints)};
|
|
57
58
|
|
|
58
59
|
// Bounds function
|
|
59
|
-
for_each_type<
|
|
60
|
+
for_each_type<RealScalar, int, const Real<double>&, const RealMatrix<double>&,
|
|
60
61
|
const RealSubmatrix<RealMatrix<double>>&,
|
|
61
62
|
nb::DRef<Eigen::MatrixXd>>([&]<typename L> {
|
|
62
63
|
for_each_type<const Real<double>&, const RealMatrix<double>&,
|
|
63
64
|
const RealSubmatrix<RealMatrix<double>>&>([&]<typename X> {
|
|
64
|
-
for_each_type<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
for_each_type<
|
|
66
|
+
RealScalar, int, const Real<double>&, const RealMatrix<double>&,
|
|
67
|
+
const RealSubmatrix<RealMatrix<double>>&, nb::DRef<Eigen::MatrixXd>>(
|
|
68
|
+
[&]<typename U> {
|
|
69
|
+
optimization.def(
|
|
70
|
+
"bounds",
|
|
71
|
+
[](L&& l, X&& x, U&& u) {
|
|
72
|
+
return bounds(unwrap_scalar(l), x, unwrap_scalar(u));
|
|
73
|
+
},
|
|
74
|
+
"l"_a, "x"_a, "u"_a, DOC(slp, bounds));
|
|
75
|
+
});
|
|
70
76
|
});
|
|
71
77
|
});
|
|
72
78
|
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
#include "arity.hpp"
|
|
24
24
|
#include "docstrings.hpp"
|
|
25
25
|
#include "for_each_type.hpp"
|
|
26
|
+
#include "real_scalar.hpp"
|
|
26
27
|
#include "text_wrap.hpp"
|
|
27
28
|
|
|
28
29
|
namespace nb = nanobind;
|
|
@@ -145,16 +146,18 @@ void bind_problem(nb::class_<Problem<double>>& cls) {
|
|
|
145
146
|
DOC(slp, Problem, parameter));
|
|
146
147
|
cls.def("parameter", nb::overload_cast<int, int>(&Problem<double>::parameter),
|
|
147
148
|
"rows"_a, "cols"_a = 1, DOC(slp, Problem, parameter, 2));
|
|
148
|
-
for_each_type<
|
|
149
|
+
for_each_type<RealScalar, const Real<double>&, const RealMatrix<double>&>(
|
|
149
150
|
[&]<typename T> {
|
|
150
151
|
cls.def(
|
|
151
152
|
"minimize",
|
|
152
|
-
[](Problem<double>& self, T cost) {
|
|
153
|
+
[](Problem<double>& self, T cost) {
|
|
154
|
+
self.minimize(unwrap_scalar(cost));
|
|
155
|
+
},
|
|
153
156
|
"cost"_a, DOC(slp, Problem, minimize));
|
|
154
157
|
cls.def(
|
|
155
158
|
"maximize",
|
|
156
159
|
[](Problem<double>& self, T objective) {
|
|
157
|
-
self.maximize(objective);
|
|
160
|
+
self.maximize(unwrap_scalar(objective));
|
|
158
161
|
},
|
|
159
162
|
"objective"_a, DOC(slp, Problem, maximize));
|
|
160
163
|
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright (c) Sleipnir contributors
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <nanobind/nanobind.h>
|
|
6
|
+
|
|
7
|
+
#include <stdint.h>
|
|
8
|
+
|
|
9
|
+
namespace nb = nanobind;
|
|
10
|
+
|
|
11
|
+
namespace slp {
|
|
12
|
+
|
|
13
|
+
/// A Python real number.
|
|
14
|
+
///
|
|
15
|
+
/// Unlike double, whose caster converts anything with __float__(), this
|
|
16
|
+
/// rejects complex numbers, complex NumPy scalars, and complex NumPy arrays,
|
|
17
|
+
/// whose __float__() drops the imaginary part.
|
|
18
|
+
struct RealScalar {
|
|
19
|
+
/// The value.
|
|
20
|
+
double value;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/// Returns operands that aren't scalar wrappers unchanged.
|
|
24
|
+
///
|
|
25
|
+
/// @param x The operand.
|
|
26
|
+
/// @return The operand.
|
|
27
|
+
template <typename T>
|
|
28
|
+
const T& unwrap_scalar(const T& x) {
|
|
29
|
+
return x;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// Returns the value of a RealScalar.
|
|
33
|
+
///
|
|
34
|
+
/// @param x The RealScalar.
|
|
35
|
+
/// @return Its value.
|
|
36
|
+
inline const double& unwrap_scalar(const RealScalar& x) {
|
|
37
|
+
return x.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
namespace detail {
|
|
41
|
+
|
|
42
|
+
/// Returns whether the object has a complex NumPy dtype.
|
|
43
|
+
///
|
|
44
|
+
/// @param src The Python object.
|
|
45
|
+
/// @return True if src has a complex NumPy dtype.
|
|
46
|
+
inline bool has_complex_dtype(nb::handle src) noexcept {
|
|
47
|
+
PyObject* dtype = PyObject_GetAttrString(src.ptr(), "dtype");
|
|
48
|
+
if (dtype == nullptr) {
|
|
49
|
+
PyErr_Clear();
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
PyObject* kind = PyObject_GetAttrString(dtype, "kind");
|
|
53
|
+
Py_DECREF(dtype);
|
|
54
|
+
if (kind == nullptr) {
|
|
55
|
+
PyErr_Clear();
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
bool is_complex =
|
|
59
|
+
PyUnicode_Check(kind) && PyUnicode_CompareWithASCIIString(kind, "c") == 0;
|
|
60
|
+
Py_DECREF(kind);
|
|
61
|
+
return is_complex;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
} // namespace detail
|
|
65
|
+
|
|
66
|
+
} // namespace slp
|
|
67
|
+
|
|
68
|
+
namespace nanobind::detail {
|
|
69
|
+
|
|
70
|
+
/// Type caster for RealScalar.
|
|
71
|
+
template <>
|
|
72
|
+
struct type_caster<slp::RealScalar> {
|
|
73
|
+
NB_TYPE_CASTER(slp::RealScalar, const_name("float"))
|
|
74
|
+
|
|
75
|
+
/// Converts a Python real number to a RealScalar.
|
|
76
|
+
///
|
|
77
|
+
/// @param src The Python object.
|
|
78
|
+
/// @param flags Cast flags.
|
|
79
|
+
/// @param cleanup Cleanup list.
|
|
80
|
+
/// @return True if src converts to double and isn't complex.
|
|
81
|
+
bool from_python(handle src, uint32_t flags, cleanup_list* cleanup) noexcept {
|
|
82
|
+
// Without the convert flag, double's caster only accepts Python floats, so
|
|
83
|
+
// only converting casts check for complex numbers. The check comes before
|
|
84
|
+
// the cast because __float__() warns when it drops an imaginary part.
|
|
85
|
+
if ((flags & static_cast<uint8_t>(cast_flags::convert)) &&
|
|
86
|
+
!PyFloat_Check(src.ptr()) && !PyLong_Check(src.ptr()) &&
|
|
87
|
+
(PyComplex_Check(src.ptr()) || slp::detail::has_complex_dtype(src))) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
make_caster<double> caster;
|
|
92
|
+
if (!caster.from_python(src, flags, cleanup)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
value.value = caster.value;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// Converts a RealScalar to a Python float.
|
|
100
|
+
///
|
|
101
|
+
/// @param value The RealScalar.
|
|
102
|
+
/// @return The Python float.
|
|
103
|
+
static handle from_cpp(slp::RealScalar value, rv_policy,
|
|
104
|
+
cleanup_list*) noexcept {
|
|
105
|
+
return PyFloat_FromDouble(value.value);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace nanobind::detail
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Sleipnir contributors
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <nanobind/nanobind.h>
|
|
6
|
+
|
|
7
|
+
#include "docstrings.hpp"
|
|
8
|
+
#include "real_scalar.hpp"
|
|
9
|
+
|
|
10
|
+
namespace nb = nanobind;
|
|
11
|
+
|
|
12
|
+
namespace slp {
|
|
13
|
+
|
|
14
|
+
/// Bind comparison operators between a real autodiff type and Python real
|
|
15
|
+
/// numbers.
|
|
16
|
+
///
|
|
17
|
+
/// RealScalar rejects complex NumPy scalars, so comparing with one behaves like
|
|
18
|
+
/// comparing with a Python complex instead of comparing with its real part.
|
|
19
|
+
/// Python calls the reflected operator when a real number is on the left (e.g.,
|
|
20
|
+
/// 2.0 < x calls x > 2.0), so only the operators with the real number on the
|
|
21
|
+
/// right are bound.
|
|
22
|
+
///
|
|
23
|
+
/// @tparam T The real autodiff type.
|
|
24
|
+
/// @tparam Options nanobind class options.
|
|
25
|
+
/// @param cls The class.
|
|
26
|
+
template <typename T, typename... Options>
|
|
27
|
+
void def_real_scalar_comparisons(nb::class_<T, Options...>& cls) {
|
|
28
|
+
using namespace nb::literals;
|
|
29
|
+
|
|
30
|
+
cls.def(
|
|
31
|
+
"__eq__", [](const T& lhs, RealScalar rhs) { return lhs == rhs.value; },
|
|
32
|
+
nb::is_operator(), "rhs"_a, DOC(slp, operator, eq));
|
|
33
|
+
cls.def(
|
|
34
|
+
"__lt__", [](const T& lhs, RealScalar rhs) { return lhs < rhs.value; },
|
|
35
|
+
nb::is_operator(), "rhs"_a, DOC(slp, operator, lt));
|
|
36
|
+
cls.def(
|
|
37
|
+
"__le__", [](const T& lhs, RealScalar rhs) { return lhs <= rhs.value; },
|
|
38
|
+
nb::is_operator(), "rhs"_a, DOC(slp, operator, le));
|
|
39
|
+
cls.def(
|
|
40
|
+
"__gt__", [](const T& lhs, RealScalar rhs) { return lhs > rhs.value; },
|
|
41
|
+
nb::is_operator(), "rhs"_a, DOC(slp, operator, gt));
|
|
42
|
+
cls.def(
|
|
43
|
+
"__ge__", [](const T& lhs, RealScalar rhs) { return lhs >= rhs.value; },
|
|
44
|
+
nb::is_operator(), "rhs"_a, DOC(slp, operator, ge));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
} // namespace slp
|