Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ hunter_default_version(cpp-statsd-client VERSION 1.0.1-42f02b4-p0)
hunter_default_version(cpp_redis VERSION 3.5.0-h1)
hunter_default_version(cppast VERSION 0.0.0-b155d6a-p0)
hunter_default_version(cppcodec VERSION 0.2-p0)
hunter_default_version(cppduals VERSION 0.9.2)
hunter_default_version(cppfs VERSION 1.3.0)
hunter_default_version(cpr VERSION 1.3.0)
hunter_default_version(cpuinfo VERSION 0.0.0-d5e37ad-p0)
Expand Down
32 changes: 32 additions & 0 deletions cmake/projects/cppduals/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2026, Michael Tesch
# All rights reserved.

# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_cmake_args)
include(hunter_download)
include(hunter_pick_scheme)

hunter_add_version(
PACKAGE_NAME
cppduals
VERSION
0.9.2
URL
"https://gitlab.com/tesch1/cppduals/-/archive/v0.9.2/cppduals-v0.9.2.tar.gz"
SHA1
1478c1fe45269470182f0222056c27ab0e22dda8
)

hunter_cmake_args(
cppduals
CMAKE_ARGS
CPPDUALS_TESTING=OFF
CPPDUALS_BENCHMARK=OFF
)

hunter_pick_scheme(DEFAULT url_sha1_cmake)
hunter_cacheable(cppduals)
hunter_download(PACKAGE_NAME cppduals)
1 change: 1 addition & 0 deletions docs/packages/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Math
- :ref:`pkg.GSL` - GNU Scientific Library
- :ref:`pkg.HastyNoise` - SIMD open source noise generation library with a large collection of different noise algorithms.
- :ref:`pkg.OpenBLAS` - OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version
- :ref:`pkg.cppduals` - header-only dual number library for exact forward-mode automatic differentiation.
- :ref:`pkg.double-conversion` - provides binary-decimal and decimal-binary routines for IEEE doubles.
- :ref:`pkg.gemmlowp` - Low-precision matrix multiplication.
- :ref:`pkg.glm` - header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.
Expand Down
27 changes: 27 additions & 0 deletions docs/packages/pkg/cppduals.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. spelling:word-list::

cppduals
autodiff

.. index:: math ; cppduals

.. _pkg.cppduals:

cppduals
========

- https://gitlab.com/tesch1/cppduals
- `Documentation <https://tesch1.gitlab.io/cppduals/>`__
- Maintainer: https://github.com/tesch1

Header-only dual number library for exact forward-mode automatic
differentiation, with optional Eigen integration.

If you use this in research, please cite
`doi:10.21105/joss.01487 <https://doi.org/10.21105/joss.01487>`__
(Tesch, JOSS 4(43):1487, 2019).

.. literalinclude:: /../examples/cppduals/CMakeLists.txt
:language: cmake
:start-after: # DOCUMENTATION_START {
:end-before: # DOCUMENTATION_END }
20 changes: 20 additions & 0 deletions examples/cppduals/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2026, Michael Tesch
# All rights reserved.

cmake_minimum_required(VERSION 3.10)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-cppduals)

# DOCUMENTATION_START {
hunter_add_package(cppduals)
find_package(cppduals CONFIG REQUIRED)

add_executable(foo foo.cpp)
target_link_libraries(foo cppduals::duals)
# DOCUMENTATION_END }

set_target_properties(foo PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES)
8 changes: 8 additions & 0 deletions examples/cppduals/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <duals/dual> // duals::dual
#include <iostream> // std::cout

int main() {
using namespace duals::literals;
auto y = (2.0 + 1.0_e) * sin(2.0 + 1.0_e);
std::cout << "f(2) = " << rpart(y) << ", f'(2) = " << dpart(y) << std::endl;
}
Loading