Skip to content

Instantly share code, notes, and snippets.

@dendisuhubdy
Created May 4, 2017 14:57
Show Gist options
  • Save dendisuhubdy/0ba8899313eb17a7ecc0997310cd581f to your computer and use it in GitHub Desktop.
Save dendisuhubdy/0ba8899313eb17a7ecc0997310cd581f to your computer and use it in GitHub Desktop.
Autodiff Trial Error 1
grok-machine:autodiff dendisuhubdy$ g++ main.cpp -o main
main.cpp:59:13: error: call to 'pow' is ambiguous
::pow(a.Real(), y),
^~~~~
/usr/include/math.h:443:15: note: candidate function
extern double pow(double, double);
^
main.cpp:56:20: note: candidate function
inline CDualNumber pow (const CDualNumber &a, float y)
^
main.cpp:60:28: error: call to 'pow' is ambiguous
y * a.Dual() * ::pow(a.Real(), y - 1.0f)
^~~~~
/usr/include/math.h:443:15: note: candidate function
extern double pow(double, double);
^
main.cpp:56:20: note: candidate function
inline CDualNumber pow (const CDualNumber &a, float y)
^
main.cpp:108:21: error: no matching function for call to 'sin'
CDualNumber y = sin(CDualNumber(x, 1.0f));
^~~
/usr/include/math.h:343:15: note: candidate function not viable: no known conversion from
'CDualNumber' to 'double' for 1st argument
extern double sin(double);
^
3 errors generated.
grok-machine:autodiff dendisuhubdy$
@dendisuhubdy
Copy link
Author

Turns out I needed to use the new C++ standard or give a -std=c++1z

Now it's working fine, with some notes

grok-machine:autodiff dendisuhubdy$ g++-6 main.cpp -o main -std=c++1z
main.cpp: In function 'CDualNumber pow(const CDualNumber&, float)':
main.cpp:60:30: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
::pow(a.Real(), y),
^
In file included from /usr/local/Cellar/gcc/6.3.0_1/include/c++/6.3.0/cmath:45:0,
from main.cpp:2:
/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6/gcc/x86_64-apple-darwin16.3.0/6.3.0/include-fixed/math.h:458:15: note: candidate 1: double pow(double, double)
extern double pow(double, double);
^~~
main.cpp:57:20: note: candidate 2: CDualNumber pow(const CDualNumber&, float)
inline CDualNumber pow (const CDualNumber &a, float y)
^~~
main.cpp:61:52: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
y * a.Dual() * ::pow(a.Real(), y - 1.0f)
^
In file included from /usr/local/Cellar/gcc/6.3.0_1/include/c++/6.3.0/cmath:45:0,
from main.cpp:2:
/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6/gcc/x86_64-apple-darwin16.3.0/6.3.0/include-fixed/math.h:458:15: note: candidate 1: double pow(double, double)
extern double pow(double, double);
^~~
main.cpp:57:20: note: candidate 2: CDualNumber pow(const CDualNumber&, float)
inline CDualNumber pow (const CDualNumber &a, float y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment