New pattern to reduce code duplication in mixed-type agrad functions

This leans on enable_if and a little template magic to greatly reduce the amount of code needed to implement mixed type function calls.