Skip to content
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

Add support for std::tie and std::make_tuple in the reverse mode #1096

Open
gojakuch opened this issue Sep 16, 2024 · 1 comment
Open

Add support for std::tie and std::make_tuple in the reverse mode #1096

gojakuch opened this issue Sep 16, 2024 · 1 comment

Comments

@gojakuch
Copy link
Collaborator

gojakuch commented Sep 16, 2024

minimal working example:

#include "clad/Differentiator/Differentiator.h"
#include "clad/Differentiator/STLBuiltins.h"
#include <tuple>
#include <iostream>

double fnTuple(double x, double y) { 
    double u, v = 288*x, w;

    std::tie(u, v, w) = std::make_tuple(x+y, 2*(x+y), 3*(x+y));

    return v;
} // = 2x + 2y

int main(int argc, char* argv[]) {
    double dx = 0, dy = 0;\
    auto df = clad::gradient(fnTuple);
    std::cout << fnTuple(3, 4) << '\n';
    df.execute(3, 4, &dx, &dy);
    std::cout << dx << ' ' << dy << '\n';
}
@gojakuch
Copy link
Collaborator Author

could be partially related to #1065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant