Closed gray-heron closed 5 years ago
The problem is that you use "auto", but the return type of the division operation is not adept::aReal, but some weird internal division object whose contents are not guaranteed to be preserved when other things happen in the program. If you replace auto with adept::aReal it will work. Best to avoid "auto" for the return type of an active statement.
Got it, it works now, thank you.
However, using auto is not uncommon practice, so it would be nice if Adept C++ Software Library: User Guide warned about it (especially since adept uses C++11 features).
You're right, I'll add something to the documentation. This is a problem with many expression template libraries, e.g.: https://eigen.tuxfamily.org/dox/TopicPitfalls.html
Thanks, Robin.
Hello, I have another problem. The following program prints {{0, 0}}, which is not correct: https://gist.github.com/acriaer/e1fc3a637148a47a49ecefda9c5310a2
Please take a look at division by 1.0 at line 15 and call to Function at line 17. Both of those should not affect the gradient. However, if I remove either one of them (or both), the program prints correct {{0.707107, 0.707107}}.
This is the furthest I could simplify the case from my application. If I make it simpler, the problem disappears.
Happens every time on GCC 5.4.0, GCC 7.3.0 and Clang 6.0. Adept is compiled with -O3.