ENH: Backport scalarmathmodule.h.src from 1.9.0-devel.

This is needed in order to backport npyiter fixes.
BUG: Backport nditer fixes and tests.

This is mostly gh-4466, but other bits had to come with it to
make it work.
DOC: Document backport of gh-4466 in 1.8.1 release notes.