Also handle dimension of non-template functions.

The difficulty comes from the fact that even for a function where all input
types and the return type is given, the dimension of the return type and
correctness of the function will vary with the dimensions of input arguments.

The solution chosen here is to treat all user-defined functions as templates.