Converting expressions to double
#358
Unanswered
vegardjervell
asked this question in
Q&A
Replies: 1 comment
-
|
First, I'd recommend you to define As to convert dual to double, you could use the member function |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've just gotten started with
autodiff, so this may just be me not having learned the ropes yet: I'm finding it surprisingly difficult to convert the result of things I've computed to adouble. The reason I would like to do this is largely because I'm interfacing with other libraries and/or want to provide an interface to my own library that at most relies on stl-containers, while I want to useautodiffinternally for computations that rely on various derivatives.For a dummy example:
My question is: Is there a "canonical" way to convert the results of large expressions to
double, or will I have to neststatic_casts as appropriate wherever I need to do this?Edit:
After some more playing around I've found that it seems like I can get around this by doing
which makes it seem a bit strange to me that
static_cast<double>(x * y)would throw a compilation error? It definitely feels like there's something I'm not understanding about how things are handled internally here, as I'm getting a lot oferror: cannot convert 'autodiff::detail::Dual<double, double>' to 'double' in assignmentand similar compilation errors.Beta Was this translation helpful? Give feedback.
All reactions