Skip to content

Feature/autodiff #1413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
81a9917
Update for regex 20 lookbehind test.
MaxSagebaum Jun 23, 2025
eff33c2
Fix for name lookup issues with MSVC.
MaxSagebaum Aug 8, 2025
bb405b6
Add missing files.
MaxSagebaum Aug 8, 2025
5169cbf
Refactor of autodiff with generalized traversal.
MaxSagebaum Aug 9, 2025
97470ba
Handling of expression lists.
MaxSagebaum Aug 9, 2025
965af06
Handling of expresson terms.
MaxSagebaum Aug 9, 2025
b3dc845
Handling of function calls.
MaxSagebaum Aug 11, 2025
358226d
Added special handling of math functions.
MaxSagebaum Aug 11, 2025
8166f0f
Added declarations and statements to simple_traversal.
MaxSagebaum Aug 11, 2025
00be8ff
Handling if/else statements.
MaxSagebaum Aug 11, 2025
dad71ef
Added handling of direct return.
MaxSagebaum Aug 11, 2025
e1ab97b
Stub handling of value declarations.
MaxSagebaum Aug 11, 2025
0c8983d
Added example for non differential variable.
MaxSagebaum Aug 11, 2025
1d23291
Added handling of while and do while loops.
MaxSagebaum Aug 11, 2025
be60ab2
Handling of for loops and added special functions.
MaxSagebaum Aug 12, 2025
f1b5de7
Unified function call handling.
MaxSagebaum Aug 12, 2025
6932cde
Proper handling of initializer expressions.
MaxSagebaum Aug 12, 2025
8548b9b
Fix initializer problem.
MaxSagebaum Aug 12, 2025
093f291
Suffix can now be user defined.
MaxSagebaum Aug 12, 2025
065c3e9
Added second order test.
MaxSagebaum Aug 12, 2025
e95bd0a
Merge remote-tracking branch 'origin/main' into feature/autodiff
MaxSagebaum Aug 13, 2025
93e676f
Remove initialization order workaround.
MaxSagebaum Aug 13, 2025
86f0c7b
Taylor polynomial propagation implementation.
MaxSagebaum Aug 13, 2025
617a089
Basic handling of higher order derivatives and handling of add and mi…
MaxSagebaum Aug 13, 2025
8b5c1e9
Added handling for multiply and division.
MaxSagebaum Aug 13, 2025
05cff29
Higher order handling for special functions.
MaxSagebaum Aug 13, 2025
b930fe7
Remaining tests for higher order derivatives.
MaxSagebaum Aug 13, 2025
364d13f
Declaration lookup and lookup of function return name.
MaxSagebaum Aug 15, 2025
d9ac9e1
Basic changes for adding new things for the differentiation.
MaxSagebaum Aug 15, 2025
92d2407
Moved handling of types and functions to autodiff_declaration_handler.
MaxSagebaum Aug 15, 2025
e83e561
Added handling for differentiation of symbols outside of metafunction…
MaxSagebaum Aug 15, 2025
50d271c
Merge remote-tracking branch 'origin/main' into feature/autodiff
MaxSagebaum Aug 17, 2025
6d2659c
Basic differentation for type and namespace value declarations.
MaxSagebaum Aug 18, 2025
803dfde
Refactor of autodiff_expression_handler.
MaxSagebaum Aug 18, 2025
a286c84
Handling of member access.
MaxSagebaum Aug 18, 2025
bc3597a
Moved assignment handling code to proper traverse function.
MaxSagebaum Aug 18, 2025
247a79d
Added type differentiation for types without member functions.
MaxSagebaum Aug 18, 2025
dd704be
Handling of member function calls.
MaxSagebaum Aug 18, 2025
211b4af
Handling of prefix + and -.
MaxSagebaum Aug 18, 2025
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
20 changes: 10 additions & 10 deletions include/cpp2regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ template<typename CharT, typename Iter, int max_groups> [[nodiscard]] auto make_
#line 184 "cpp2regex.h2"
// Helpers for creating wrappers of the iterators.
//
template <typename Iter> [[nodiscard]] auto make_forward_iterator(Iter const& pos) -> auto;
template <typename Iter> [[nodiscard]] auto make_forward_iterator(std::reverse_iterator<Iter> const& pos) -> auto;
template <typename Iter> [[nodiscard]] auto make_reverse_iterator(Iter const& pos) -> auto;
template<typename Iter> [[nodiscard]] auto make_reverse_iterator(std::reverse_iterator<Iter> const& pos) -> auto;
template <typename Iter> [[nodiscard]] auto cpp2_make_forward_iterator(Iter const& pos) -> auto;
template<typename Iter> [[nodiscard]] auto cpp2_make_forward_iterator(std::reverse_iterator<Iter> const& pos) -> auto;
template <typename Iter> [[nodiscard]] auto cpp2_make_reverse_iterator(Iter const& pos) -> auto;
template<typename Iter> [[nodiscard]] auto cpp2_make_reverse_iterator(std::reverse_iterator<Iter> const& pos) -> auto;

#line 192 "cpp2regex.h2"
// End function that returns a valid match.
Expand Down Expand Up @@ -927,13 +927,13 @@ template<typename CharT, typename Iter, int max_groups> [[nodiscard]] auto make_
}

#line 186 "cpp2regex.h2"
template <typename Iter> [[nodiscard]] auto make_forward_iterator(Iter const& pos) -> auto { return pos; }
template <typename Iter> [[nodiscard]] auto cpp2_make_forward_iterator(Iter const& pos) -> auto { return pos; }
#line 187 "cpp2regex.h2"
template <typename Iter> [[nodiscard]] auto make_forward_iterator(std::reverse_iterator<Iter> const& pos) -> auto { return CPP2_UFCS(base)(pos); }
template<typename Iter> [[nodiscard]] auto cpp2_make_forward_iterator(std::reverse_iterator<Iter> const& pos) -> auto { return CPP2_UFCS(base)(pos); }
#line 188 "cpp2regex.h2"
template <typename Iter> [[nodiscard]] auto make_reverse_iterator(Iter const& pos) -> auto { return std::make_reverse_iterator(pos); }
template <typename Iter> [[nodiscard]] auto cpp2_make_reverse_iterator(Iter const& pos) -> auto { return std::make_reverse_iterator(pos); }
#line 189 "cpp2regex.h2"
template<typename Iter> [[nodiscard]] auto make_reverse_iterator(std::reverse_iterator<Iter> const& pos) -> auto { return pos; }
template<typename Iter> [[nodiscard]] auto cpp2_make_reverse_iterator(std::reverse_iterator<Iter> const& pos) -> auto { return pos; }

#line 196 "cpp2regex.h2"
[[nodiscard]] auto true_end_func::operator()(auto const& cur, auto& ctx) const& -> decltype(auto) { return ctx.pass(cur); }
Expand Down Expand Up @@ -1153,7 +1153,7 @@ template<typename CharT, bool match_new_line> [[nodiscard]] auto line_start_toke
#line 575 "cpp2regex.h2"
template<typename CharT, bool positive> [[nodiscard]] auto lookahead_token_matcher(auto const& cur, auto& ctx, auto const& func) -> bool
{
auto r {func(make_forward_iterator(cur), make_forward_match_context(ctx), true_end_func())};
auto r {func(cpp2_make_forward_iterator(cur), make_forward_match_context(ctx), true_end_func())};
if (!(positive)) {
r.matched = !(r.matched);
}
Expand All @@ -1164,7 +1164,7 @@ template<typename CharT, bool positive> [[nodiscard]] auto lookahead_token_match
#line 589 "cpp2regex.h2"
template<typename CharT, bool positive> [[nodiscard]] auto lookbehind_token_matcher(auto const& cur, auto& ctx, auto const& func) -> bool
{
auto r {func(make_reverse_iterator(cur), make_reverse_match_context(ctx), true_end_func())};
auto r {func(cpp2_make_reverse_iterator(cur), make_reverse_match_context(ctx), true_end_func())};
if (!(positive)) {
r.matched = !(r.matched);
}
Expand Down
12 changes: 6 additions & 6 deletions include/cpp2regex.h2
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ make_reverse_match_context: <CharT, Iter, max_groups: int> (inout ctx: reverse_m

// Helpers for creating wrappers of the iterators.
//
make_forward_iterator: <Iter> (pos: Iter) -> _ = pos;
make_forward_iterator: <Iter> (pos: std::reverse_iterator<Iter>) -> _ = pos.base();
make_reverse_iterator: <Iter> (pos: Iter) -> _ = std::make_reverse_iterator(pos);
make_reverse_iterator: <Iter> (pos: std::reverse_iterator<Iter>) -> _ = pos;
cpp2_make_forward_iterator: <Iter> (pos: Iter) -> _ = pos;
cpp2_make_forward_iterator: <Iter> (pos: std::reverse_iterator<Iter>) -> _ = pos.base();
cpp2_make_reverse_iterator: <Iter> (pos: Iter) -> _ = std::make_reverse_iterator(pos);
cpp2_make_reverse_iterator: <Iter> (pos: std::reverse_iterator<Iter>) -> _ = pos;


// End function that returns a valid match.
Expand Down Expand Up @@ -574,7 +574,7 @@ line_start_token_matcher: <CharT, match_new_line: bool> (cur, inout ctx) -> bool
//
lookahead_token_matcher: <CharT, positive: bool> (cur, inout ctx, func) -> bool =
{
r := func(make_forward_iterator(cur), make_forward_match_context(ctx), true_end_func());
r := func(cpp2_make_forward_iterator(cur), make_forward_match_context(ctx), true_end_func());
if !positive {
r.matched = !r.matched;
}
Expand All @@ -588,7 +588,7 @@ lookahead_token_matcher: <CharT, positive: bool> (cur, inout ctx, func) -> bool
//
lookbehind_token_matcher: <CharT, positive: bool> (cur, inout ctx, func) -> bool =
{
r := func(make_reverse_iterator(cur), make_reverse_match_context(ctx), true_end_func());
r := func(cpp2_make_reverse_iterator(cur), make_reverse_match_context(ctx), true_end_func());
if !positive {
r.matched = !r.matched;
}
Expand Down
Loading
Loading