Commit 55f75cef authored by Michael Tesch's avatar Michael Tesch
Browse files

Merge branch 'feature/multidual' into 'master'

Add multivariate forward-mode AD: dual<T, int N=1>

See merge request !49
parents eb6b74dd 5285d7db
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ cover:
    when: manual
    allow_failure: true

# Manual pipeline - generates website with docs and coverage (triggered manually)
# Deploy docs and coverage to GitLab Pages — runs automatically on tagged releases
pages:
  stage: pages
  script:
@@ -92,6 +92,7 @@ pages:
    paths:
    - public/
  rules:
  - if: $CI_COMMIT_TAG
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    when: manual
    allow_failure: true
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
#
cmake_minimum_required (VERSION 3.14)
project (cppduals
  VERSION 0.7.4
  VERSION 0.8.0
  LANGUAGES C CXX
  )
include (GNUInstallDirs)
+223 −294

File changed.

Preview size limit exceeded, changes collapsed.

TODO-multidual.md

0 → 100644
+66 −0
Original line number Diff line number Diff line
# Multivariate Dual — Remaining Work

## Phase 2: Drop-in replacement for `dual<T>`

Merge the `duals/multidual` implementation into `duals/dual` so that the
existing `dual<T>` becomes `dual<T, int N=1>`.  All existing code
compiles unchanged (N=1 default).

1. Replace the `dual<T>` class in `duals/dual` with `dual<T, int N=1>`
   from `duals/multidual`.  Remove `duals/partials` and
   `duals/multidual` as separate headers.

2. Update `duals/dual_eigen` — add `int N` template parameter to
   `NumTraits`, `ScalarBinaryOpTraits`, and the unary functors
   (`rpart`, `dpart`).  Guard SIMD packet specializations to `N=1`.

3. Update `duals/dual_fmt.h` — add `int N` template parameter.
   N=1 formatting unchanged; N>1 shows partials array.

4. Update SIMD headers (`duals/arch/{SSE,AVX,NEON}/Dual.h`,
   `ComplexDual.h`) — specialize for `dual<T,1>` only.

5. Run full existing test suite — must pass unchanged.

6. Update equivalency tests to compile against the unified header.

### Verification gate

```bash
make clangr && make test   # all existing tests pass
make cov                   # coverage report
```

## Phase 3: Eigen integration for N>1

Enable `Eigen::Matrix<dual<T,N>>` for N>1.  This allows multivariate
differentiation of matrix operations (gemm, LU solve, matrix
exponential) in a single evaluation pass.

1. Provide `NumTraits<dual<T,N>>` for arbitrary N.

2. Add `ScalarBinaryOpTraits` for mixed `dual<T,N>` / `T` operations.

3. Add `rpart(MatrixBase)` and `dpart(MatrixBase, int i)` unary
   functors returning component matrices.

4. Benchmark: compare N-pass `padm(Matrix<dual<T>>)` against
   1-pass `padm(Matrix<dual<T,N>>)` for matrix exponential
   derivatives.  This should show the multivariate advantage
   (compute f' once, multiply by N seeds) at the matrix level.

5. No SIMD for N>1 (Eigen falls back to scalar loops).

## Phase 4: Non-x86 vectorization

- CUDA kernel support for `dual<T>` and `dual<T,N>`.
- AltiVec / HIP packet specializations.

## Open questions

- Should `duals/multidual` remain as a convenience header that
  simply includes `duals/dual` after Phase 2?
- I/O format for N>1: `(3+{0,1,0}_e)` vs `(3; 0, 1, 0)`
  settle on a format before Phase 2.
- Whether to add runtime-sized N (e.g. `dual<T, Eigen::Dynamic>`)
  for cases where the number of variables isn't known at compile time.

dev.sh

0 → 100755
+125 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading