Piecewise fix for 0d

I provide a fix for #331. Actually little changes were needed, but I had to carefully think about the assumptions being made by the function. Some additional tests were added and the behavior remains backwards compatible.

Besides, I corrected the documentation because there was an inconsistent bit, see 0d1f7d3.
Excuse me, the status quo now is not undefined, but 0 as a default: that's what I kept in these changes. In fact most of the tests rely on this, see https://github.com/Juanlu001/numpy/blob/292b9ff538ea4950c7380c76cf65d1a5b108b75c/numpy/lib/tests/test_function_base.py#L1466. Either I set this to `nan` or leave it as it is now, but in this case the docs were wrong.