Using std::pow inside stan::math namespace

One is correct. I couldn’t follow the second bullet point. Three is also correct.

I’m a little confused because defining stan::math::pow(...) isn’t extending the standard library. It’s overloading the function pow.

This all took a sharp turn for Stan with C++11, which defines integer forms of these functions. It was really the integer forms that led us to define our own primitive versions of functions, because they were ambiguous with promotion to double and to autodiff types like stan::math::var.

So I like solution (2) if we can make it work and I like having your example of just bringing in stan::math, also bringing in relevant standard library functions under the stan::mathnamespace. Similarly, we’d just be able to call pow(1.0, 1) in all of our own functions. Getting those includes right has sometimes been painful and it’s always verbose.

std::complex is a bit trickier because the standard library implementations vary between clang++ and g++ in terms of which functions are there for disambiguation.

For ordering, we’d just include the standard functions before any of the Stan code.

1 Like