First, rather than taking signum(x) and then using it as
a multiplicand, it's much more effcient to branch in Stan
because branching doesn't add anything to the expression graph.
That's the real reason we don't have it. Branching on
parameters also breaks differentiability and we should be
raising warnings when users try it.
The issue we have with the built-ins is that we can put
warnings in the manual, but users won't see those. We could
have every use of such a function raise a warning and we
might in the future (like warnings on branching on parameters).
We have a bunch of step-like functions which break
differentiability and just have warnings next to them in
the manual. The functions we do supply are the ones that are
in the C++ standard library, and they have C++ signatures like:
double floor(double);
C++ allows double values to be assigned to integers (up to
user to deal with overflow), but Stan doesn't. That's the
built-in limitation in Stan and I did that intentionally so
as to preserve distinct typing.
The function we're seriously missing is the round to integer
function. Most examples we've seen of users who want to use
it would be breaking our samplers, so we're reluctant. We might
just build in some interpolation functions.
- Bob