How to add self defined functions to AD<Base>? #151
-
I am trying to add Gamma function in this way:
How to implement it? Which parts of source codes should I modify? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Does the following work for you ?
|
Beta Was this translation helpful? Give feedback.
-
In fact, there are a lot of 'if-else' branches in the numerical algorithm of Gamma function, see boost's implement https://www.boost.org/doc/libs/1_78_0/boost/math/special_functions/gamma.hpp I am worried about that the code may be non-differentiable. |
Beta Was this translation helpful? Give feedback.
-
The operation sequence will depend on the results of all the if branches in your program; see It is more complicated to create a gamma function where you never have to retape. For an example see the atan2 example It is even more complicated, but more efficient, to create an atomic gamma function; see |
Beta Was this translation helpful? Give feedback.
-
Great, thank you very much. I have to say I need more tutorials about |
Beta Was this translation helpful? Give feedback.
-
The important thing is to only implement the virtual functions that you need. For more examples see; |
Beta Was this translation helpful? Give feedback.
-
Really helpful! And can you tell me what do the args mean, for instance |
Beta Was this translation helpful? Give feedback.
-
See the documentation for the particular function below |
Beta Was this translation helpful? Give feedback.
-
If you are satisfied with this answer, would you please close this issue. |
Beta Was this translation helpful? Give feedback.
The operation sequence will depend on the results of all the if branches in your program; see
https://coin-or.github.io/CppAD/doc/compare_change.htm
It is more complicated to create a gamma function where you never have to retape. For an example see the atan2 example
https://coin-or.github.io/CppAD/doc/condexp.htm#Atan2
It is even more complicated, but more efficient, to create an atomic gamma function; see
https://coin-or.github.io/CppAD/doc/atomic_four_get_started.cpp.htm
Note that to use this in derivative calculations, you will have to define the derivatives of the gamma function.