Add multivariate forward-mode AD: dual<T, int N=1>
Summary
- New
dual<T, int N=1>carries N independent partial derivatives, computing the full gradient in a single evaluation pass. WithN=1(default), behavior is identical to the existingdual<T>. - New headers:
duals/partials(lightweightstd::array<T,N>wrapper) andduals/multidual(complete implementation with all ~40 math functions, complex overloads, I/O, type traits). - Equivalency tests verify bit-exact match between
duals/dualandduals/multidualfor N=1. Benchmarks show 1-pass N=3 is ~2.4x faster than 3x N=1 passes for gradient computation. - Updated README with multivariate examples, updated
duals/dualheader docs, GitLab Pages auto-deploys on tagged releases.
Phase 1 of the multivariate plan
This is the standalone multidual header proving the design. Phase 2 (converging into duals/dual as a drop-in replacement) is future work.
Test plan
- CI build passes (C++20 and C++17)
-
test_multidual— correctness for N=1,2,3, gradient verification -
test_multidual_equiv— diff output of old vs new targets (should be empty) -
bench_multidual— verify N=1 performance matches original, N>1 shows expected scaling
Edited by Michael Tesch