dispatch on mathematical functions

Functions like sum, any, all, sin, cos, isnan, etc... all appear in
several libraries like math, numpy, blaze, builtins, ...

This redefines this functions using dispatch so that they call the
correct sum/min/all depending on the input

cc @kdodia