vgvassilev / clad

clad -- automatic differentiation for C/C++
GNU Lesser General Public License v3.0
266 stars 113 forks source link

Add support for simple lambda expressions in forward mode #937

Closed gojakuch closed 2 weeks ago

gojakuch commented 3 weeks ago

This commit provides support for the simplest lambda expressions, that is, those with no captures, in forward mode. The original lambda function is copied into the derivative, but the corresponding lambda class gets extended to also have a pushforward method for the call operator overload. Essentially, there's no visiting of lambda expressions yet (this will be implemented later to support captures, I'm working on this), but rather we allow treating simple cases of lambda functions as functors.

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.80%. Comparing base (de8a6f6) to head (3161ee1).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vgvassilev/clad/pull/937/graphs/tree.svg?width=650&height=150&src=pr&token=9f6Q4em8hE&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev)](https://app.codecov.io/gh/vgvassilev/clad/pull/937?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) ```diff @@ Coverage Diff @@ ## master #937 +/- ## ======================================= Coverage 93.79% 93.80% ======================================= Files 55 55 Lines 7815 7827 +12 ======================================= + Hits 7330 7342 +12 Misses 485 485 ``` | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/937?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | Coverage Δ | | |---|---|---| | [lib/Differentiator/BaseForwardModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/937?src=pr&el=tree&filepath=lib%2FDifferentiator%2FBaseForwardModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Jhc2VGb3J3YXJkTW9kZVZpc2l0b3IuY3Bw) | `98.94% <100.00%> (+0.01%)` | :arrow_up: | | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/937?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | Coverage Δ | | |---|---|---| | [lib/Differentiator/BaseForwardModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/937?src=pr&el=tree&filepath=lib%2FDifferentiator%2FBaseForwardModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Jhc2VGb3J3YXJkTW9kZVZpc2l0b3IuY3Bw) | `98.94% <100.00%> (+0.01%)` | :arrow_up: |
github-actions[bot] commented 3 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 3 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"