Refactoring: libmath_func -> header files with templates