简体   繁体   中英

How to compile special mathematical functions with clang?

One can call sph_legendre from tr1 and compile it with gcc-5 or gcc-6

#include<tr1/cmath>

int main()
{
    std::tr1::sph_legendre(1,1,0);
    return 0;
} 

Unfortunately, if I try to compile it with clang++ as:

clang++ -stdlib=libstdc++ legendre.cpp -o legendre

I get

error: no member named 'sph_legendre' in namespace 'std::tr1'

In the section 40.3, The C++PP (4th edition) states:

"There is a separate ISO standard for special mathematical functions [C++Math,2010]. An implementation may add these functions to cmath"

How can I compile these special functions with clang++ ?

As Richard already mentioned, clang does not support std::sph_legendre at the moment.

A possible workaround for you is to use the boost libraries ( http://www.boost.org ) and include header: boost/math/tr1.hpp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM