我尝试用 C++ 编写球形贝塞尔函数
#include <boost/math/special_functions/bessel.hpp>
并sph_bessel(v,x)
在我的代码中使用和,但发生错误说这没有在这个范围内声明。我用 g++ test.cpp 编译。请帮助我。
#include <cmath>
#include <iostream>
#include <boost/math/special_functions/bessel.hpp>
using namespace std;
int main()
{
// spot check for n == 1
double x = 1.2345;
cout << "j_1(" << x << ") = " << sph_bessel(1, x) << '\n';
}
编译代码:
g++ test.cpp
并给出这个错误:
error: ‘sph_bessel’ was not declared in this scope
cout << "j_1(" << x << ") = " << sph_bessel(1, x) << '\n';
a.cpp:9:38: note: suggested alternative:
In file included from a.cpp:3:0:
/usr/include/boost/math/special_functions/bessel.hpp:544:79: note: ‘boost::math::sph_bessel’
ename detail::bessel_traits<T, T, policies::policy<> >::result_type sph_bessel(unsigned v, T x)