math: Inconsistent error handling
Description
Error handling is not consistent between different mathematical functions. Most primitive functions only call std implementation and return NaN in case of invalid input. Some check for invalid input and throw exceptions.
Example
stan::math::log() directely calls std::log(). So any negative argument results in NaN return value.
stan::math::log1p() checks if its argument is less than -1 and throws std::domain_error if it is.
Expected Output
Consistent error handling.
Current Version:
v3.0.0
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 15 (13 by maintainers)
No idea. This page seems to vaguely claim they are based on standard library.
I think we do not. In most cases Stan programs are run on the same computer they are compiled on, so we could use -march=native. But there might be exceptions? I don’t know.
Even if there are exceptions we could document that in most cases user can add that to make/local and expect improved performance.
Wow. That’s interesting news on the performance of Eigen implementations of exp() and sqrt(). Do they satisfy the IEEE standard or are they taking shortcuts? If they’re accurate enough, we should be able to just plug and play.
There are also ways to turn down compiler implementations of checks and lower precision to get speedups (which is partly what the Intel library does).
Do we not he -march=native turned on in our compilation? If not, should we?