0

I'm learning CUDA and went to check how some functions worked a little more in depth because googling a specific structure variable gave me nothing. I used to think header files contained all the functions defined but all I saw was that they were declared. I then went to to check if the pow() function in math.h was defined and was surprised to find out it also was never defined, just declared Where can I see how these functions are defined?

Salty
  • 21
  • 5
  • You need to go find the source code for your system's C library. It might be closed source, in which case you can't see it at all. (C libraries can be precompiled, so you can use them even if the source is not available.) – Nate Eldredge Mar 30 '21 at 23:51
  • 3
    You `#include ` and link with `-lm` which refers to the libm.so file. The source for libm.so is not normally included but is available. Have a look at: http://www.gnu.org/software/libc/ Here is a similar question: https://stackoverflow.com/questions/11550140/where-is-gnu-lib-math-libm-source-code – Jerry Jeremiah Mar 30 '21 at 23:54
  • https://sourceware.org/git/?p=glibc.git;a=blob;f=math/s_cpow_template.c;h=71ce0c01126e6f9641a276a9dd4b9b17e1cc8454;hb=HEAD defines `pow(x,c)=exp(c*log(x));` and those two are defined in https://sourceware.org/git/?p=glibc.git;a=blob;f=math/s_cexp_template.c;h=bb6043155dbd5e0516878952fea87145d536dd64;hb=HEAD and https://sourceware.org/git/?p=glibc.git;a=blob;f=math/s_clog_template.c;h=3a723e9303a57d7a681029767fd3797ab18e6fca;hb=HEAD – Jerry Jeremiah Mar 31 '21 at 00:06

0 Answers0