Why won't boost's bessel function compile with a complex input?

自作多情 提交于 2019-12-12 21:13:57

问题


According to the boost documentation, the boost special functions bessel function (specifically the modified bessel function) should be able to accept a complex input.

However, when I attempt to feed it one, I get a compile error complaining that there is no < operator for operand types float and std::complex<float>.

Here is my code:

using namespace boost::math;    
std::complex<float> cpxTerm = std::complex<float>(m_u1 * cos(az), -wbar * cos(sin(lim)));
std::complex<float> besselTerm = cyl_bessel_i(0, cpxTerm);

As you can see, I'm attempting to use boost's modified bessel function implementation for a 0th order, first-kind modified bessel function.

This returns pages of errors, but as far as I can see, all of them are complaining about the lack of a < operator for the input operands.

I have tried explicitly specifying the template arguments as <int, complex>, <double, complex>, and <complex, complex> to no avail.

Here is one example:

boost.1.50.0/include/boost/math/special_functions/detail/bessel_ik.hpp(108): error: no operator "<" matches these operands
     operand types are: float < std::complex<float>
  d = abs(sigma) < tools::epsilon<T>() ?
                 ^
      detected during:

I'm using the Intel 2013 compiler with C++11 enabled.

What am I doing wrong here?

As a side question, looking at the boost documentation for the function, I noticed this troubling bit:

The functions return the result of domain_error whenever the result is undefined or complex.

Does this mean the function will also fail for complex results when given a complex input (where one would conceivably expect the possibility of a complex output)?

Edit: Digging deeper, it appears the problem is that the std::complex type has no > or < operators. This somewhat makes sense, in that it's somewhat ambiguous to question whether one complex number is greater than the other (does one go by the magnitude, the real component, the imaginary? etc...)

Thus it seems that, although the bessel function is defined for complex inputs, boost itself doesn't support complex inputs for the bessel function. It seems the documentation was a bit misleading on this.

来源:https://stackoverflow.com/questions/19981747/why-wont-boosts-bessel-function-compile-with-a-complex-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!