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

Creating a function f_dargN for each possible N is no longer necessary #100

Closed
efremale opened this issue Oct 9, 2018 · 2 comments
Closed

Comments

@efremale
Copy link
Contributor

efremale commented Oct 9, 2018

Calling clad::differentiate(f, N) for 0 <= N <= M and T f(T x0, ..., T xM) currently would produce M+1 derivative functions f_dargN that are very similar. In fact, they only differ in how the initial derivatives of function parameters are initialized:

T f_dargN(T x0, ..., T xM) {
  ...
  T _d_xN = 1;
  T _d_xI = 0; // for all I != N
  ...
  // common code part here
}

We can perhaps utilize it and create only one function, where initial derivatives are specified by a caller:

T f_darg(T x0, T _d_x0, ..., T xM, T _d_xM)

This would allow the caller to specify the independent variable by passing the required _d_xI equal to 1.
This is also potentially useful for deriving functions with vector inputs as each vector input has its derivative specified by a user and we no longer have to allocate it.

@vaithak
Copy link
Collaborator

vaithak commented Dec 22, 2023

This was fixed in #565 and many subsequent PRs which added the vector forward mode support.

We also have many test cases present with the vector mode interface: https://github.com/vgvassilev/clad/blob/master/test/ForwardMode/VectorMode.C.
Demo example: https://github.com/vgvassilev/clad/blob/master/demos/VectorForwardMode.cpp

@vgvassilev
Copy link
Owner

Thanks @vaithak, let's close the issue now.

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

3 participants