xad 2.2.0__tar.gz → 2.3.0__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.
- {xad-2.2.0 → xad-2.3.0}/CHANGELOG.md +21 -0
- {xad-2.2.0 → xad-2.3.0}/CMakeLists.txt +1 -1
- {xad-2.2.0 → xad-2.3.0}/PKG-INFO +18 -19
- {xad-2.2.0 → xad-2.3.0}/README.md +14 -15
- {xad-2.2.0 → xad-2.3.0}/notebooks/01_quickstart.ipynb +1 -1
- {xad-2.2.0 → xad-2.3.0}/notebooks/02_option_greeks.ipynb +1 -1
- {xad-2.2.0 → xad-2.3.0}/notebooks/03_adjoint_vs_finite_differences.ipynb +1 -1
- {xad-2.2.0 → xad-2.3.0}/pyproject.toml +4 -4
- xad-2.3.0/samples/black_scholes_greeks.py +109 -0
- {xad-2.2.0 → xad-2.3.0}/src/CMakeLists.txt +1 -0
- {xad-2.2.0 → xad-2.3.0}/src/math.hpp +73 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/AGENTS.md +2 -2
- {xad-2.2.0 → xad-2.3.0}/src/xad/CHANGELOG.md +36 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/CITATION.cff +5 -5
- xad-2.3.0/src/xad/CMakeLists.txt +62 -0
- xad-2.3.0/src/xad/README.md +176 -0
- xad-2.3.0/src/xad/VERSION +1 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/cmake/XADConfig.cmake.in +1 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/cmake/XADSetupOptions.cmake +9 -6
- {xad-2.2.0 → xad-2.3.0}/src/xad/cmake/XADSetupVersion.cmake +1 -1
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/CMakeLists.txt +29 -20
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/Tape.cpp +20 -20
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/ABool.hpp +46 -46
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/BinaryExpr.hpp +10 -10
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/BinaryMathFunctors.hpp +16 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/BinaryOperators.hpp +2 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Complex.hpp +3 -3
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Config.hpp.in +2 -4
- xad-2.2.0/src/xad/src/XAD/JITGraph.hpp → xad-2.3.0/src/xad/src/XAD/Graph.hpp +39 -28
- xad-2.2.0/src/xad/src/XAD/JITBackendInterface.hpp → xad-2.3.0/src/xad/src/XAD/GraphBackendInterface.hpp +11 -11
- xad-2.2.0/src/xad/src/XAD/JITExprTraits.hpp → xad-2.3.0/src/xad/src/XAD/GraphExprTraits.hpp +16 -15
- xad-2.2.0/src/xad/src/XAD/JITGraphInterpreter.cpp → xad-2.3.0/src/xad/src/XAD/GraphInterpreter.cpp +175 -149
- xad-2.2.0/src/xad/src/XAD/JITGraphInterpreter.hpp → xad-2.3.0/src/xad/src/XAD/GraphInterpreter.hpp +12 -12
- xad-2.3.0/src/xad/src/XAD/GraphOpCodeTraits.hpp +246 -0
- xad-2.2.0/src/xad/src/XAD/JITCompiler.hpp → xad-2.3.0/src/xad/src/XAD/GraphRecorder.hpp +58 -58
- xad-2.2.0/src/xad/src/XAD/JITCompilerTLS.cpp → xad-2.3.0/src/xad/src/XAD/GraphRecorderTLS.cpp +23 -23
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Literals.hpp +151 -88
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/MathFunctions.hpp +123 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/StdCompatibility.hpp +12 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Tape.hpp +13 -13
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/UnaryExpr.hpp +21 -21
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/UnaryMathFunctors.hpp +8 -10
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/UnaryOperators.hpp +34 -2
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/XAD.hpp +3 -9
- {xad-2.2.0 → xad-2.3.0}/xad/__init__.py +4 -0
- xad-2.3.0/xad/_license_notice.py +76 -0
- {xad-2.2.0 → xad-2.3.0}/xad/math/__init__.py +20 -0
- xad-2.2.0/src/xad/CMakeLists.txt +0 -106
- xad-2.2.0/src/xad/README.md +0 -162
- xad-2.2.0/src/xad/VERSION +0 -1
- xad-2.2.0/src/xad/src/XAD/JITOpCodeTraits.hpp +0 -228
- {xad-2.2.0 → xad-2.3.0}/.clang-format +0 -0
- {xad-2.2.0 → xad-2.3.0}/.flake8 +0 -0
- {xad-2.2.0 → xad-2.3.0}/.gitignore +0 -0
- {xad-2.2.0 → xad-2.3.0}/.gitmodules +0 -0
- {xad-2.2.0 → xad-2.3.0}/.pre-commit-config.yaml +0 -0
- {xad-2.2.0 → xad-2.3.0}/CODE_OF_CONDUCT.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/CONTRIBUTING.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/LICENSE.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/adj_1st.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/checkpointing.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/complex.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/external_function.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/fwd_1st.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/fwd_adj_2nd.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/hessian.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/numpy_arrays.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/samples/swap_pricer.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/array.cpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/array.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/cmath.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/complex.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/double_caster.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/exceptions.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/jacobian_hessian.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/module.cpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.appveyor.yml +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.clang-format +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.clang-tidy +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.cmake-format.yaml +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.codespell-ignore-lines +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.gitattributes +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.gitignore +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.pre-commit-config.yaml +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/.readthedocs.yml +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/AGENTS.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/CMakeLists.txt +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/CMakePresets.json +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/LICENSE +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/README.rst +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/SECURITY.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/attr.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/buffer_info.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/cast.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/chrono.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/common.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/complex.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/conduit/README.txt +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/conduit/pybind11_conduit_v1.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/conduit/pybind11_platform_abi_id.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/conduit/wrap_include_python_h.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/critical_section.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/argument_vector.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/class.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/common.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/cpp_conduit.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/descr.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/exception_translation.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/function_record_pyobject.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/function_ref.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/holder_caster_foreign_helpers.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/init.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/internals.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/native_enum_data.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/pybind11_namespace_macros.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/struct_smart_holder.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/type_caster_base.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/typeid.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/using_smart_holder.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/detail/value_and_holder.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/eigen/common.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/eigen/matrix.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/eigen/tensor.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/eigen.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/embed.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/eval.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/functional.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/gil.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/gil_safe_call_once.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/gil_simple.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/iostream.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/native_enum.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/numpy.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/operators.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/options.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/pybind11.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/pytypes.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/stl/filesystem.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/stl.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/stl_bind.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/subinterpreter.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/trampoline_self_life_support.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/type_caster_pyobject_ptr.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/typing.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/include/pybind11/warnings.h +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/noxfile.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pybind11/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pybind11/__main__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pybind11/_version.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pybind11/commands.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pybind11/py.typed +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pybind11/setup_helpers.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/pyproject.toml +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/FindCatch.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/FindEigen3.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/FindPythonLibsNew.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/JoinPaths.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/check-style.sh +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/cmake_uninstall.cmake.in +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/codespell_ignore_lines_from_errors.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/libsize.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/make_changelog.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/make_global.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/pybind11.pc.in +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/pybind11Common.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/pybind11Config.cmake.in +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/pybind11GuessPythonExtSuffix.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/pybind11NewTools.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/pybind11Tools.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/pybind11/tools/test-pybind11GuessPythonExtSuffix.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/real.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/register_input.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/tape.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/.clang-format +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/.gitignore +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/.lgtm.yml +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/CMakeSettings.json +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/CODE_OF_CONDUCT.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/CONTRIBUTING.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/LICENSE.md +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/XAD.natvis +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/cmake/XADSetupCompiler.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/cmake/XADSetupTesting.cmake +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/context7.json +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/ARealDirect.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/AlignedAllocator.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/BinaryDerivativeImpl.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/BinaryFunctors.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/BinaryOperatorMacros.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/CheckpointCallback.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/ChunkContainer.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Exceptions.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Export.hpp.in +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Expression.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/FRealDirect.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Hessian.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Interface.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Jacobian.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Macros.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/OperationsContainer.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/OperationsContainerPaired.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/RealDirect.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/ReusableRange.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/TapeContainer.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/TapeGapList.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Traits.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/TypeTraits.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/UnaryFunctors.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/UnaryOperatorMacros.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Vec.hpp +0 -0
- {xad-2.2.0 → xad-2.3.0}/src/xad/src/XAD/Version.hpp.in +0 -0
- {xad-2.2.0 → xad-2.3.0}/tests/test_exceptions.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/tests/test_math_functions_derivatives.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/tests/test_package.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/tests/test_real_operations.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/tests/test_tape.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/_real.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/adj_1st/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/cmath/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/exceptions/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/fwd_1st/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/fwd_adj_2nd/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/fwd_fwd_2nd/__init__.py +0 -0
- {xad-2.2.0 → xad-2.3.0}/xad/py.typed +0 -0
|
@@ -8,6 +8,25 @@ The package version follows the [XAD](https://github.com/auto-differentiation/xa
|
|
|
8
8
|
C++ core it is built on.
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
## [2.3.0] - 2026-11-25
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `import xad` prints a short license notice to stderr once per Python environment.
|
|
16
|
+
- Sample `samples/black_scholes_greeks.py`: Black-Scholes delta, vega, rho and theta in one
|
|
17
|
+
adjoint pass, checked against the closed form.
|
|
18
|
+
- `xad.math`: `gamma`, `lgamma`, `digamma`, `rint`, `nearbyint`, `lrint`, `llrint`, `logb`,
|
|
19
|
+
`scalbln` and `fdim`, from XAD 2.3.0, for active and plain values.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Built on XAD 2.3.0.
|
|
24
|
+
- Package links on PyPI: the homepage is the XAD page, and a new link points to the commercial
|
|
25
|
+
license page.
|
|
26
|
+
- PyPI classifiers: the package is listed under the AGPL license only (the proprietary license
|
|
27
|
+
classifier is removed).
|
|
28
|
+
|
|
29
|
+
|
|
11
30
|
## [2.2.0] - 2026-11-12
|
|
12
31
|
|
|
13
32
|
### Added
|
|
@@ -87,6 +106,8 @@ Minor fixes to allow linking against QuantLib-Risks without duplicate symbols.
|
|
|
87
106
|
Initial release of Python bindings for XAD.
|
|
88
107
|
|
|
89
108
|
|
|
109
|
+
[Unreleased]: https://github.com/auto-differentiation/xad-py/compare/v2.3.0...HEAD
|
|
110
|
+
[2.3.0]: https://github.com/auto-differentiation/xad-py/compare/v2.2.0...v2.3.0
|
|
90
111
|
[2.2.0]: https://github.com/auto-differentiation/xad-py/compare/v2.1.0...v2.2.0
|
|
91
112
|
[2.1.0]: https://github.com/auto-differentiation/xad-py/compare/v1.5.2...v2.1.0
|
|
92
113
|
[1.5.2]: https://github.com/auto-differentiation/xad-py/compare/v1.5.1.1...v1.5.2
|
|
@@ -29,7 +29,7 @@ project(
|
|
|
29
29
|
xad-py
|
|
30
30
|
LANGUAGES CXX
|
|
31
31
|
DESCRIPTION "Python bindings for the XAD automatic differentiation library"
|
|
32
|
-
HOMEPAGE_URL "https://
|
|
32
|
+
HOMEPAGE_URL "https://www.xcelerit.com/xad/docs/")
|
|
33
33
|
|
|
34
34
|
set(CMAKE_CXX_STANDARD 17)
|
|
35
35
|
|
{xad-2.2.0 → xad-2.3.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xad
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: High-Performance Automatic Differentiation for Python
|
|
5
5
|
Keywords: automatic-differentiation,derivatives,machine-learning,optimisation,numerical-analysis,scientific-computing,risk-management,computer-graphics,robotics,biotechnology,meteorology,quant-finance
|
|
6
6
|
Author-Email: Auto Differentiation Dev Team <dev@auto-differentiation.com>
|
|
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Education
|
|
|
11
11
|
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
12
12
|
Classifier: Intended Audience :: Science/Research
|
|
13
13
|
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
14
|
-
Classifier: License :: Other/Proprietary License
|
|
15
14
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
15
|
Classifier: Operating System :: Microsoft :: Windows
|
|
17
16
|
Classifier: Operating System :: POSIX :: Linux
|
|
@@ -25,38 +24,38 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
|
25
24
|
Classifier: Topic :: Scientific/Engineering
|
|
26
25
|
Classifier: Topic :: Software Development
|
|
27
26
|
Classifier: Typing :: Typed
|
|
28
|
-
Project-URL: Homepage, https://
|
|
27
|
+
Project-URL: Homepage, https://www.xcelerit.com/xad/?utm_source=pypi
|
|
28
|
+
Project-URL: Commercial licence and support, https://www.xcelerit.com/xad/licensing/?utm_source=pypi
|
|
29
29
|
Project-URL: Repository, https://github.com/auto-differentiation/xad-py
|
|
30
30
|
Project-URL: XAD C++ library, https://github.com/auto-differentiation/xad
|
|
31
|
-
Project-URL: Documentation, https://
|
|
31
|
+
Project-URL: Documentation, https://www.xcelerit.com/xad/docs/tutorials/python
|
|
32
32
|
Project-URL: Download, https://pypi.org/project/xad/#files
|
|
33
33
|
Project-URL: Tracker, https://github.com/auto-differentiation/xad-py/issues
|
|
34
34
|
Project-URL: Release notes, https://github.com/auto-differentiation/xad-py/releases
|
|
35
35
|
Requires-Python: >=3.10
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
|
|
38
|
-
[](https://
|
|
38
|
+
[](https://www.xcelerit.com/xad/docs/tutorials/python)
|
|
39
39
|
|
|
40
40
|
> Part of the [XAD ecosystem](https://github.com/auto-differentiation) — the fastest automatic differentiation library for C++.
|
|
41
41
|
> If this is useful to you, please star the [core XAD repository](https://github.com/auto-differentiation/xad).
|
|
42
42
|
|
|
43
|
-
XAD is a library
|
|
44
|
-
[automatic differentiation](https://
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
the process efficient and straightforward for a wide range of mathematical
|
|
49
|
-
functions, from simple arithmetic to complex calculations, ensuring accurate
|
|
50
|
-
and automatic derivative computations.
|
|
43
|
+
XAD is a library for
|
|
44
|
+
[automatic differentiation](https://www.xcelerit.com/xad/docs/tutorials/aad/):
|
|
45
|
+
it computes accurate derivatives of the functions in your program, from simple
|
|
46
|
+
arithmetic to complex calculations. It is built for production use, with a
|
|
47
|
+
focus on performance and ease of use.
|
|
51
48
|
|
|
52
|
-
The Python bindings
|
|
49
|
+
The Python bindings offer:
|
|
53
50
|
|
|
54
|
-
-
|
|
51
|
+
- Forward and adjoint mode for first-order derivatives, and second-order
|
|
52
|
+
derivatives by nesting them, with Jacobian and Hessian helpers.
|
|
55
53
|
- Strong exception-safety guarantees.
|
|
56
54
|
- High performance, as demonstrated in extensive production use.
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
See the [documentation](https://www.xcelerit.com/xad/docs/tutorials/python) for details.
|
|
57
|
+
|
|
58
|
+
> **Using XAD in your organization?** XAD is open source under the AGPL, to try it, for research and for open-source projects. In practice, the AGPL's terms don't suit most production settings in finance. For production use, XAD is available under an annual subscription: commercial terms, support, updates and code generation. See [XAD licensing](https://www.xcelerit.com/xad/licensing/) for the terms, a quote within one business day, or a free, confidential license check.
|
|
60
59
|
|
|
61
60
|
## Application Areas
|
|
62
61
|
|
|
@@ -249,7 +248,7 @@ itself, `np.asarray(a)` gives the values, and `np.asarray(a, dtype=object)` the
|
|
|
249
248
|
Unsupported NumPy functions raise `TypeError` rather than dropping the derivatives. Arrays need
|
|
250
249
|
NumPy >= 1.25 at runtime; it is not a build or import dependency of the package.
|
|
251
250
|
|
|
252
|
-
For more information, see the [Documentation](https://
|
|
251
|
+
For more information, see the [Documentation](https://www.xcelerit.com/xad/docs/tutorials/python).
|
|
253
252
|
|
|
254
253
|
## Building Extensions Against XAD
|
|
255
254
|
|
|
@@ -272,4 +271,4 @@ Import `xad` before the extension so the library is loaded.
|
|
|
272
271
|
## Related Projects
|
|
273
272
|
|
|
274
273
|
- XAD Comprehensive automatic differentiation in [Python](https://github.com/auto-differentiation/xad-py) and [C++](https://github.com/auto-differentiation/xad)
|
|
275
|
-
-
|
|
274
|
+
- QuantLibAAD: Fast risk evaluations in [Python](https://github.com/auto-differentiation/QuantLibAAD-Py) and [C++](https://github.com/auto-differentiation/QuantLibAAD)
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
[](https://
|
|
1
|
+
[](https://www.xcelerit.com/xad/docs/tutorials/python)
|
|
2
2
|
|
|
3
3
|
> Part of the [XAD ecosystem](https://github.com/auto-differentiation) — the fastest automatic differentiation library for C++.
|
|
4
4
|
> If this is useful to you, please star the [core XAD repository](https://github.com/auto-differentiation/xad).
|
|
5
5
|
|
|
6
|
-
XAD is a library
|
|
7
|
-
[automatic differentiation](https://
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
the process efficient and straightforward for a wide range of mathematical
|
|
12
|
-
functions, from simple arithmetic to complex calculations, ensuring accurate
|
|
13
|
-
and automatic derivative computations.
|
|
6
|
+
XAD is a library for
|
|
7
|
+
[automatic differentiation](https://www.xcelerit.com/xad/docs/tutorials/aad/):
|
|
8
|
+
it computes accurate derivatives of the functions in your program, from simple
|
|
9
|
+
arithmetic to complex calculations. It is built for production use, with a
|
|
10
|
+
focus on performance and ease of use.
|
|
14
11
|
|
|
15
|
-
The Python bindings
|
|
12
|
+
The Python bindings offer:
|
|
16
13
|
|
|
17
|
-
-
|
|
14
|
+
- Forward and adjoint mode for first-order derivatives, and second-order
|
|
15
|
+
derivatives by nesting them, with Jacobian and Hessian helpers.
|
|
18
16
|
- Strong exception-safety guarantees.
|
|
19
17
|
- High performance, as demonstrated in extensive production use.
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
See the [documentation](https://www.xcelerit.com/xad/docs/tutorials/python) for details.
|
|
20
|
+
|
|
21
|
+
> **Using XAD in your organization?** XAD is open source under the AGPL, to try it, for research and for open-source projects. In practice, the AGPL's terms don't suit most production settings in finance. For production use, XAD is available under an annual subscription: commercial terms, support, updates and code generation. See [XAD licensing](https://www.xcelerit.com/xad/licensing/) for the terms, a quote within one business day, or a free, confidential license check.
|
|
23
22
|
|
|
24
23
|
## Application Areas
|
|
25
24
|
|
|
@@ -212,7 +211,7 @@ itself, `np.asarray(a)` gives the values, and `np.asarray(a, dtype=object)` the
|
|
|
212
211
|
Unsupported NumPy functions raise `TypeError` rather than dropping the derivatives. Arrays need
|
|
213
212
|
NumPy >= 1.25 at runtime; it is not a build or import dependency of the package.
|
|
214
213
|
|
|
215
|
-
For more information, see the [Documentation](https://
|
|
214
|
+
For more information, see the [Documentation](https://www.xcelerit.com/xad/docs/tutorials/python).
|
|
216
215
|
|
|
217
216
|
## Building Extensions Against XAD
|
|
218
217
|
|
|
@@ -235,4 +234,4 @@ Import `xad` before the extension so the library is loaded.
|
|
|
235
234
|
## Related Projects
|
|
236
235
|
|
|
237
236
|
- XAD Comprehensive automatic differentiation in [Python](https://github.com/auto-differentiation/xad-py) and [C++](https://github.com/auto-differentiation/xad)
|
|
238
|
-
-
|
|
237
|
+
- QuantLibAAD: Fast risk evaluations in [Python](https://github.com/auto-differentiation/QuantLibAAD-Py) and [C++](https://github.com/auto-differentiation/QuantLibAAD)
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
"\n",
|
|
216
216
|
"- [Black-Scholes and Monte Carlo Greeks](https://colab.research.google.com/github/auto-differentiation/xad-py/blob/main/notebooks/02_option_greeks.ipynb): all sensitivities of an option price in one adjoint pass.\n",
|
|
217
217
|
"- [Adjoint vs finite differences at scale](https://colab.research.google.com/github/auto-differentiation/xad-py/blob/main/notebooks/03_adjoint_vs_finite_differences.ipynb): gradient of a PDE model with hundreds of parameters.\n",
|
|
218
|
-
"- [Python documentation](https://
|
|
218
|
+
"- [Python documentation](https://www.xcelerit.com/xad/docs/tutorials/python) and the [XAD C++ library](https://github.com/auto-differentiation/xad)."
|
|
219
219
|
]
|
|
220
220
|
}
|
|
221
221
|
],
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
"\n",
|
|
269
269
|
"- [Adjoint vs finite differences at scale](https://colab.research.google.com/github/auto-differentiation/xad-py/blob/main/notebooks/03_adjoint_vs_finite_differences.ipynb)\n",
|
|
270
270
|
"- [QuantLib-Risks](https://github.com/auto-differentiation/QuantLib-Risks-Py): QuantLib with XAD for fast risk in Python.\n",
|
|
271
|
-
"- [Python documentation](https://
|
|
271
|
+
"- [Python documentation](https://www.xcelerit.com/xad/docs/tutorials/python) and the [XAD C++ library](https://github.com/auto-differentiation/xad)."
|
|
272
272
|
]
|
|
273
273
|
}
|
|
274
274
|
],
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"## Next steps\n",
|
|
234
234
|
"\n",
|
|
235
235
|
"- [XAD quickstart](https://colab.research.google.com/github/auto-differentiation/xad-py/blob/main/notebooks/01_quickstart.ipynb)\n",
|
|
236
|
-
"- [Python documentation](https://
|
|
236
|
+
"- [Python documentation](https://www.xcelerit.com/xad/docs/tutorials/python) and the [XAD C++ library](https://github.com/auto-differentiation/xad)."
|
|
237
237
|
]
|
|
238
238
|
}
|
|
239
239
|
],
|
|
@@ -28,7 +28,7 @@ build-backend = "scikit_build_core.build"
|
|
|
28
28
|
|
|
29
29
|
[project]
|
|
30
30
|
name = "xad"
|
|
31
|
-
version = "2.
|
|
31
|
+
version = "2.3.0"
|
|
32
32
|
description = "High-Performance Automatic Differentiation for Python"
|
|
33
33
|
readme = "README.md"
|
|
34
34
|
requires-python = ">=3.10"
|
|
@@ -57,7 +57,6 @@ classifiers = [
|
|
|
57
57
|
"Intended Audience :: Financial and Insurance Industry",
|
|
58
58
|
"Intended Audience :: Science/Research",
|
|
59
59
|
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
|
|
60
|
-
"License :: Other/Proprietary License",
|
|
61
60
|
"Operating System :: MacOS :: MacOS X",
|
|
62
61
|
"Operating System :: Microsoft :: Windows",
|
|
63
62
|
"Operating System :: POSIX :: Linux",
|
|
@@ -74,10 +73,11 @@ classifiers = [
|
|
|
74
73
|
]
|
|
75
74
|
|
|
76
75
|
[project.urls]
|
|
77
|
-
Homepage = "https://
|
|
76
|
+
Homepage = "https://www.xcelerit.com/xad/?utm_source=pypi"
|
|
77
|
+
"Commercial licence and support" = "https://www.xcelerit.com/xad/licensing/?utm_source=pypi"
|
|
78
78
|
Repository = "https://github.com/auto-differentiation/xad-py"
|
|
79
79
|
"XAD C++ library" = "https://github.com/auto-differentiation/xad"
|
|
80
|
-
Documentation = "https://
|
|
80
|
+
Documentation = "https://www.xcelerit.com/xad/docs/tutorials/python"
|
|
81
81
|
Download = "https://pypi.org/project/xad/#files"
|
|
82
82
|
Tracker = "https://github.com/auto-differentiation/xad-py/issues"
|
|
83
83
|
"Release notes" = "https://github.com/auto-differentiation/xad-py/releases"
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Sample for option Greeks with first-order adjoint mode in Python
|
|
4
|
+
#
|
|
5
|
+
# Prices a European call with the Black-Scholes formula
|
|
6
|
+
# V = S N(d1) - K exp(-r T) N(d2)
|
|
7
|
+
# and computes delta, vega, rho and theta in a single adjoint pass,
|
|
8
|
+
# checked against the closed-form Greeks.
|
|
9
|
+
#
|
|
10
|
+
# This file is part of XAD's Python bindings, a comprehensive library for
|
|
11
|
+
# automatic differentiation.
|
|
12
|
+
#
|
|
13
|
+
# Copyright (C) 2010-2026 Xcelerit Computing Ltd.
|
|
14
|
+
#
|
|
15
|
+
# This program is free software: you can redistribute it and/or modify
|
|
16
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
17
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
18
|
+
# (at your option) any later version.
|
|
19
|
+
#
|
|
20
|
+
# This program is distributed in the hope that it will be useful,
|
|
21
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
# GNU Affero General Public License for more details.
|
|
24
|
+
#
|
|
25
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
26
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
import math
|
|
30
|
+
|
|
31
|
+
import xad.adj_1st as xadj
|
|
32
|
+
from xad import math as xm
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def norm_cdf(x):
|
|
36
|
+
# standard normal CDF; works for floats and XAD active types alike
|
|
37
|
+
return 0.5 * (1.0 + xm.erf(x / math.sqrt(2.0)))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def black_scholes_call(spot, strike, rate, vol, maturity):
|
|
41
|
+
sqrt_t = xm.sqrt(maturity)
|
|
42
|
+
d1 = (xm.log(spot / strike) + (rate + 0.5 * vol * vol) * maturity) / (vol * sqrt_t)
|
|
43
|
+
d2 = d1 - vol * sqrt_t
|
|
44
|
+
return spot * norm_cdf(d1) - strike * xm.exp(-rate * maturity) * norm_cdf(d2)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# input values
|
|
48
|
+
spot = 100.0
|
|
49
|
+
strike = 105.0
|
|
50
|
+
rate = 0.03 # continuously compounded, per year
|
|
51
|
+
vol = 0.20 # per year
|
|
52
|
+
maturity = 1.0 # in years
|
|
53
|
+
|
|
54
|
+
# set independent variables (the strike stays a plain float)
|
|
55
|
+
spot_ad = xadj.Real(spot)
|
|
56
|
+
vol_ad = xadj.Real(vol)
|
|
57
|
+
rate_ad = xadj.Real(rate)
|
|
58
|
+
maturity_ad = xadj.Real(maturity)
|
|
59
|
+
|
|
60
|
+
with xadj.Tape() as tape:
|
|
61
|
+
# and register them
|
|
62
|
+
tape.registerInput(spot_ad)
|
|
63
|
+
tape.registerInput(vol_ad)
|
|
64
|
+
tape.registerInput(rate_ad)
|
|
65
|
+
tape.registerInput(maturity_ad)
|
|
66
|
+
|
|
67
|
+
# start recording derivatives
|
|
68
|
+
tape.newRecording()
|
|
69
|
+
|
|
70
|
+
# calculate the price
|
|
71
|
+
price = black_scholes_call(spot_ad, strike, rate_ad, vol_ad, maturity_ad)
|
|
72
|
+
|
|
73
|
+
# register and seed adjoint of output
|
|
74
|
+
tape.registerOutput(price)
|
|
75
|
+
price.derivative = 1.0
|
|
76
|
+
|
|
77
|
+
# compute all Greeks in one backward pass
|
|
78
|
+
tape.computeAdjoints()
|
|
79
|
+
|
|
80
|
+
# Theta convention: theta = -dV/dT, the change in value as one year of time
|
|
81
|
+
# passes (maturity shrinks), per year. Divide by 365 for a per-day theta.
|
|
82
|
+
aad = {
|
|
83
|
+
"delta": spot_ad.derivative,
|
|
84
|
+
"vega": vol_ad.derivative,
|
|
85
|
+
"rho": rate_ad.derivative,
|
|
86
|
+
"theta": -maturity_ad.derivative,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# closed-form Black-Scholes Greeks for a European call (no dividends)
|
|
90
|
+
sqrt_t = math.sqrt(maturity)
|
|
91
|
+
d1 = (math.log(spot / strike) + (rate + 0.5 * vol * vol) * maturity) / (vol * sqrt_t)
|
|
92
|
+
d2 = d1 - vol * sqrt_t
|
|
93
|
+
pdf_d1 = math.exp(-0.5 * d1 * d1) / math.sqrt(2.0 * math.pi)
|
|
94
|
+
discount = math.exp(-rate * maturity)
|
|
95
|
+
closed_form = {
|
|
96
|
+
"delta": norm_cdf(d1),
|
|
97
|
+
"vega": spot * pdf_d1 * sqrt_t,
|
|
98
|
+
"rho": strike * maturity * discount * norm_cdf(d2),
|
|
99
|
+
"theta": -spot * pdf_d1 * vol / (2.0 * sqrt_t) - rate * strike * discount * norm_cdf(d2),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# output results
|
|
103
|
+
print(f"call price = {price.value:.6f}\n")
|
|
104
|
+
print(f"{'Greek':8} {'AAD':>14} {'closed form':>14} {'difference':>12}")
|
|
105
|
+
for name in aad:
|
|
106
|
+
diff = aad[name] - closed_form[name]
|
|
107
|
+
print(f"{name:8} {aad[name]:14.10f} {closed_form[name]:14.10f} {diff:12.2e}")
|
|
108
|
+
print("\ntheta = -dV/dT per year (divide by 365 for per day)")
|
|
109
|
+
print("vega and rho are per 1.00 change in vol and rate (divide by 100 for per 1%)")
|
|
@@ -27,14 +27,50 @@
|
|
|
27
27
|
#include <XAD/XAD.hpp>
|
|
28
28
|
#include <pybind11/pybind11.h>
|
|
29
29
|
#include "double_caster.hpp"
|
|
30
|
+
#include <algorithm>
|
|
30
31
|
#include <cmath>
|
|
32
|
+
#include <limits>
|
|
31
33
|
#include <numeric>
|
|
34
|
+
#include <stdexcept>
|
|
32
35
|
|
|
33
36
|
namespace py = pybind11;
|
|
34
37
|
|
|
35
38
|
using AReal = xad::AReal<double>;
|
|
36
39
|
using FReal = xad::FReal<double>;
|
|
37
40
|
|
|
41
|
+
constexpr const char* round_to_int64_doc =
|
|
42
|
+
"rounds to the nearest integer in the current rounding mode, returned as an int in the "
|
|
43
|
+
"64-bit range on every platform; raises ValueError for NaN and OverflowError for inf or "
|
|
44
|
+
"an out-of-range result of a float argument";
|
|
45
|
+
|
|
46
|
+
// lrint/llrint: rounds the passive value in the current rounding mode, without recording
|
|
47
|
+
template <class T>
|
|
48
|
+
long long round_to_int64(const T& x)
|
|
49
|
+
{
|
|
50
|
+
const double r = std::nearbyint(xad::detail::passive_value(x));
|
|
51
|
+
if (std::isnan(r))
|
|
52
|
+
throw py::value_error("cannot convert NaN to integer");
|
|
53
|
+
if (r >= 9223372036854775808.0 || r < -9223372036854775808.0) // [-2^63, 2^63), not +-inf
|
|
54
|
+
throw std::overflow_error("rounded value does not fit a 64-bit integer");
|
|
55
|
+
return static_cast<long long>(r);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// an integer exponent (anything with __index__ (numpy integers too; math.ldexp takes only int))
|
|
59
|
+
// clamped to int, as XAD does, so any n works with a 32-bit long (Windows) too; exact, as the
|
|
60
|
+
// result already saturates
|
|
61
|
+
inline long clamp_exponent(const py::handle& n)
|
|
62
|
+
{
|
|
63
|
+
const auto index = py::reinterpret_steal<py::int_>(PyNumber_Index(n.ptr()));
|
|
64
|
+
if (!index)
|
|
65
|
+
throw py::error_already_set(); // TypeError for a float or other non-integer
|
|
66
|
+
constexpr int lo = std::numeric_limits<int>::min(), hi = std::numeric_limits<int>::max();
|
|
67
|
+
int overflow = 0; // the sign of n when it does not fit a long long
|
|
68
|
+
const long long v = PyLong_AsLongLongAndOverflow(index.ptr(), &overflow);
|
|
69
|
+
if (overflow != 0)
|
|
70
|
+
return overflow > 0 ? hi : lo;
|
|
71
|
+
return static_cast<long>(std::clamp<long long>(v, lo, hi));
|
|
72
|
+
}
|
|
73
|
+
|
|
38
74
|
template <class T>
|
|
39
75
|
void add_math_functions(py::module_& m)
|
|
40
76
|
{
|
|
@@ -117,6 +153,37 @@ void add_math_functions(py::module_& m)
|
|
|
117
153
|
m.def("cbrt", [](const T& d) { return T(xad::cbrt(d)); }, "cubic root");
|
|
118
154
|
m.def("erf", [](const T& d) { return T(xad::erf(d)); }, "error function");
|
|
119
155
|
m.def("erfc", [](const T& d) { return T(xad::erfc(d)); }, "complementary error function");
|
|
156
|
+
m.def("gamma", [](const T& d) { return T(xad::tgamma(d)); }, "gamma function");
|
|
157
|
+
m.def(
|
|
158
|
+
"lgamma", [](const T& d) { return T(xad::lgamma(d)); },
|
|
159
|
+
"natural logarithm of the absolute value of the gamma function");
|
|
160
|
+
m.def(
|
|
161
|
+
"digamma", [](const T& d) { return T(xad::digamma(d)); },
|
|
162
|
+
"digamma function, the derivative of lgamma");
|
|
163
|
+
m.def(
|
|
164
|
+
"rint", [](const T& d) { return T(xad::rint(d)); },
|
|
165
|
+
"rounds to the nearest integer in the current rounding mode");
|
|
166
|
+
m.def(
|
|
167
|
+
"nearbyint", [](const T& d) { return T(xad::nearbyint(d)); },
|
|
168
|
+
"rounds to the nearest integer in the current rounding mode");
|
|
169
|
+
m.def("logb", [](const T& d) { return T(xad::logb(d)); }, "binary exponent of the argument");
|
|
170
|
+
m.def(
|
|
171
|
+
"lrint", [](const T& d) { return round_to_int64(d); },
|
|
172
|
+
round_to_int64_doc);
|
|
173
|
+
m.def(
|
|
174
|
+
"llrint", [](const T& d) { return round_to_int64(d); },
|
|
175
|
+
round_to_int64_doc);
|
|
176
|
+
m.def(
|
|
177
|
+
"fdim", [](const T& d, const T& b) { return T(xad::fdim(d, b)); },
|
|
178
|
+
"x - y if x > y, else +0; NaN if either operand is NaN");
|
|
179
|
+
m.def(
|
|
180
|
+
"scalbln",
|
|
181
|
+
[](const T& d, const py::object& n)
|
|
182
|
+
{
|
|
183
|
+
using std::scalbln;
|
|
184
|
+
return T(scalbln(d, clamp_exponent(n)));
|
|
185
|
+
},
|
|
186
|
+
"multiplies x by 2 to the power of any integer n; saturates to inf or 0");
|
|
120
187
|
m.def(
|
|
121
188
|
"nextafter", [](const T& d, const T& b) { return T(xad::nextafter(d, b)); },
|
|
122
189
|
"next representable value in the given direction");
|
|
@@ -199,6 +266,12 @@ void add_math_functions(py::module_& m)
|
|
|
199
266
|
m.def(
|
|
200
267
|
"remainder", [](const double& d, const T& b) { return T(xad::remainder(d, b)); },
|
|
201
268
|
"signed remainder after integer division");
|
|
269
|
+
m.def(
|
|
270
|
+
"fdim", [](const T& d, const double& b) { return T(xad::fdim(d, b)); },
|
|
271
|
+
"x - y if x > y, else +0; NaN if either operand is NaN");
|
|
272
|
+
m.def(
|
|
273
|
+
"fdim", [](const double& d, const T& b) { return T(xad::fdim(d, b)); },
|
|
274
|
+
"x - y if x > y, else +0; NaN if either operand is NaN");
|
|
202
275
|
}
|
|
203
276
|
};
|
|
204
277
|
|
|
@@ -6,7 +6,7 @@ summarises and which takes precedence.
|
|
|
6
6
|
## What XAD is
|
|
7
7
|
|
|
8
8
|
A C++ library for automatic differentiation: forward and adjoint (reverse) mode, higher orders, vector modes,
|
|
9
|
-
checkpointing and
|
|
9
|
+
checkpointing and graph recording. Most of it is header code in `src/XAD/`; it must build as C++11.
|
|
10
10
|
|
|
11
11
|
## Layout
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ ctest --test-dir build -j8 --output-on-failure
|
|
|
26
26
|
- Run one test or sample: `ctest --test-dir build -R <name>`.
|
|
27
27
|
- Useful options (see `cmake/XADSetupOptions.cmake`): `XAD_ENABLE_TESTS`, `XAD_TAPE_REUSE_SLOTS`,
|
|
28
28
|
`XAD_TAPE_TRACK_LIVE_SLOTS`, `XAD_REDUCED_MEMORY`, `XAD_USE_STRONG_INLINE`,
|
|
29
|
-
`XAD_ENABLE_ADDRESS_SANITIZER
|
|
29
|
+
`XAD_ENABLE_ADDRESS_SANITIZER`, `XAD_ENABLE_GRAPH` (the graph recorder and its tests).
|
|
30
30
|
- Before opening a PR, build and run the tests in both C++11 (`-DCMAKE_CXX_STANDARD=11`) and C++17; CI also
|
|
31
31
|
covers several GCC, Clang, MSVC and macOS versions.
|
|
32
32
|
|
|
@@ -6,6 +6,40 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [2.3.0] - 2026-11-25
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Math functions `tgamma` and `lgamma` for XAD types, with first- and higher-order derivatives, and `xad::digamma` (for `double`, `float` and XAD types), which their derivatives use as the standard library has none
|
|
14
|
+
|
|
15
|
+
- C++20 `std::format` support for `AReal` and `FReal`, including nested active real types, when provided by the standard library
|
|
16
|
+
|
|
17
|
+
- Sample `ImpliedVolatility`: solves Black-Scholes for the implied volatility with Newton's method and computes its sensitivities to the option price, spot and rate via the implicit function theorem (one adjoint sweep at the converged root, without differentiating the solver), validated against closed-form values and finite differences of the full solve
|
|
18
|
+
|
|
19
|
+
- Sample `BlackScholesGreeks`: delta, vega, rho and theta of a European call and put from one templated Black-Scholes pricer, with forward mode (one pass per input) and adjoint mode (one pass for all), checked against the closed-form Greeks to 1e-12
|
|
20
|
+
|
|
21
|
+
- Sample `HeatEquation`: gradient of the final midpoint temperature of an explicit 1D heat equation solver with respect to the whole initial profile in one adjoint pass, using checkpointing to bound the tape memory (about 0.6 MiB instead of 21 MiB for 2,000 time steps), checked against finite differences, with the gradient profile written to CSV
|
|
22
|
+
|
|
23
|
+
- Sample `BasketMonteCarlo`: Monte Carlo price and pathwise delta and vega of all 12 assets of a correlated basket call in adjoint mode, with the paths split across threads, one tape per thread recording one path at a time (constant tape memory), checked against bump-and-revalue with the same random numbers and against a single-threaded run, which gives identical results
|
|
24
|
+
|
|
25
|
+
- Sample `CrossGamma`: full cross-gamma matrix of a multi-asset basket option in forward-over-adjoint mode using closed-form lognormal moment matching, checked for matrix symmetry and validated against central finite differences of first-order adjoint deltas, with benchmark cost comparisons against bumping
|
|
26
|
+
|
|
27
|
+
- Sample `AmericanPDE`: prices an American put option with a Crank-Nicolson finite-difference solver under a local volatility surface and computes sensitivities to all grid points in one adjoint pass; wraps the tridiagonal matrix solve (Thomas algorithm) as an external function with a hand-written adjoint (solving with the transposed matrix), with early exercise handled via `xad::max()`, Rannacher smoothing, and sensitivity validation against bumping
|
|
28
|
+
|
|
29
|
+
- CMake option `XAD_ENABLE_GRAPH` (off by default) to build and install graph recording
|
|
30
|
+
|
|
31
|
+
- Sample `HestonCalibration`: calibrates the five Heston parameters to 35 call prices (5 maturities x 7 strikes) with Levenberg-Marquardt; the semi-analytic pricer (Lewis formula, "little Heston trap" characteristic function, Gauss-Legendre quadrature) runs on `std::complex<xad::AReal<double>>`, the residual Jacobian comes from adjoint mode and is checked against finite differences
|
|
32
|
+
|
|
33
|
+
- `rint`, `nearbyint`, `lrint`, `llrint`, `logb`, `scalbln` and `fdim` for XAD types and expressions: `rint` and `nearbyint` round to the nearest integer in the current rounding mode, with zero first and second derivatives; `lrint` and `llrint` return plain `long` / `long long` without tape recording; `logb` extracts the floating-point exponent, with zero derivatives; `scalbln` multiplies by `FLT_RADIX` raised to a `long` exponent, with derivative `FLT_RADIX^exp` (delegates to `ldexp` with the exponent clamped to `int` range, which is exact since results saturate beyond it); `fdim` computes the positive difference, with derivatives 1 and -1 on the `x > y` branch and 0 otherwise, including at `x == y`, and NaN-propagating derivatives with a NaN operand; tested in first and second order, forward and adjoint mode, including scalar-argument forms of `fdim`, tie and NaN cases, and the `std::` compatibility interface; they can also be recorded in a graph
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Docs: reference pages updated for 2.2 (graph recorder and backend members, tape checkpoints, version macros, max/min derivatives, build options for tape checks and ARM, headers, direct mode types)
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- Graph replay of `pow(x, y)` now gives the same derivative with respect to the exponent as the tape for a zero, negative or NaN base (it gave 0)
|
|
42
|
+
|
|
9
43
|
## [2.2.0] - 2026-11-11
|
|
10
44
|
|
|
11
45
|
### Added
|
|
@@ -347,6 +381,8 @@ This is a patch release to ensure compatibility with QuantLib 1.33.
|
|
|
347
381
|
|
|
348
382
|
Initial open-source release
|
|
349
383
|
|
|
384
|
+
[2.3.0]: https://github.com/auto-differentiation/xad/compare/v2.2.0...v2.3.0
|
|
385
|
+
|
|
350
386
|
[2.2.0]: https://github.com/auto-differentiation/xad/compare/v2.1.0...v2.2.0
|
|
351
387
|
|
|
352
388
|
[2.1.0]: https://github.com/auto-differentiation/xad/compare/v2.0.0...v2.1.0
|
|
@@ -8,20 +8,20 @@ authors:
|
|
|
8
8
|
repository-code: "https://github.com/auto-differentiation/xad"
|
|
9
9
|
url: "https://auto-differentiation.github.io"
|
|
10
10
|
license: AGPL-3.0-or-later
|
|
11
|
-
version: "2.
|
|
12
|
-
date-released: "2026-11-
|
|
11
|
+
version: "2.3.0"
|
|
12
|
+
date-released: "2026-11-25"
|
|
13
13
|
doi: "10.5281/zenodo.7965850"
|
|
14
14
|
identifiers:
|
|
15
15
|
- type: doi
|
|
16
16
|
value: "10.5281/zenodo.7965850"
|
|
17
17
|
description: "All versions (concept DOI)"
|
|
18
18
|
- type: doi
|
|
19
|
-
value: "10.5281/zenodo.
|
|
20
|
-
description: "Version 2.
|
|
19
|
+
value: "10.5281/zenodo.24142852"
|
|
20
|
+
description: "Version 2.2.0"
|
|
21
21
|
keywords:
|
|
22
22
|
- automatic differentiation
|
|
23
23
|
- algorithmic differentiation
|
|
24
24
|
- adjoint
|
|
25
25
|
- C++
|
|
26
26
|
- Python
|
|
27
|
-
abstract: "XAD computes exact derivatives of C++ and Python code in forward, adjoint and higher-order mode via operator overloading, with checkpointing, Eigen support and
|
|
27
|
+
abstract: "XAD computes exact derivatives of C++ and Python code in forward, adjoint and higher-order mode via operator overloading, with checkpointing, Eigen support and graph recording."
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
##############################################################################
|
|
2
|
+
#
|
|
3
|
+
# Main CMake file
|
|
4
|
+
#
|
|
5
|
+
# This file is part of XAD, a comprehensive C++ library for
|
|
6
|
+
# automatic differentiation.
|
|
7
|
+
#
|
|
8
|
+
# Copyright (C) 2010-2026 Xcelerit Computing Ltd.
|
|
9
|
+
#
|
|
10
|
+
# This program is free software: you can redistribute it and/or modify
|
|
11
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
12
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
13
|
+
# (at your option) any later version.
|
|
14
|
+
#
|
|
15
|
+
# This program is distributed in the hope that it will be useful,
|
|
16
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18
|
+
# GNU Affero General Public License for more details.
|
|
19
|
+
#
|
|
20
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
21
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
22
|
+
#
|
|
23
|
+
##############################################################################
|
|
24
|
+
|
|
25
|
+
############## setup ###################
|
|
26
|
+
cmake_minimum_required(VERSION 3.15.2)
|
|
27
|
+
cmake_policy(SET CMP0092 NEW) # avoid setting warning flags by default in Windows
|
|
28
|
+
|
|
29
|
+
project(xad
|
|
30
|
+
LANGUAGES CXX
|
|
31
|
+
DESCRIPTION "Comprehensive C++ library for automatic differentiation."
|
|
32
|
+
HOMEPAGE_URL "https://www.xcelerit.com/xad/docs/"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
|
37
|
+
include(XADSetupVersion)
|
|
38
|
+
|
|
39
|
+
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # allow using solution folders
|
|
40
|
+
include(GNUInstallDirs) # for installation directories
|
|
41
|
+
|
|
42
|
+
include(XADSetupOptions)
|
|
43
|
+
|
|
44
|
+
############# build subdirectories ##########
|
|
45
|
+
|
|
46
|
+
if(NOT XAD_DOCS_ONLY)
|
|
47
|
+
include(XADSetupCompiler)
|
|
48
|
+
if(XAD_ENABLE_TESTS)
|
|
49
|
+
include(XADSetupTesting)
|
|
50
|
+
endif()
|
|
51
|
+
|
|
52
|
+
add_subdirectory(src)
|
|
53
|
+
|
|
54
|
+
if(XAD_ENABLE_TESTS)
|
|
55
|
+
add_subdirectory(test)
|
|
56
|
+
add_subdirectory(samples)
|
|
57
|
+
endif()
|
|
58
|
+
endif()
|
|
59
|
+
|
|
60
|
+
install(FILES CHANGELOG.md LICENSE.md TYPE DOC)
|
|
61
|
+
|
|
62
|
+
|