Refactoring reducedim and related functions
use ngenerate for mapreducedim
specialized methods to make the initialization for reducedim more efficient for common cases
use `@ngenerate` macro for mapreducedim!
Merge pull request #7106 from JuliaLang/dh/reducedim3

Refactoring reducedim and related functions