diff --git a/src/utils.hpp b/src/utils.hpp index a86b242..37b546b 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -12,11 +12,24 @@ namespace fmri { typedef float DType; + /** + * Identity function that simply returns whatever is put in. + * + * @tparam T The type of the function + * @param t The value to return. + * @return The original value. + */ template inline T identity(T t) { return t; } + /** + * Read a file into a vector of given type. + * @tparam T The type to read. + * @param filename the file to read + * @return A vector of type T. + */ template inline std::vector read_vector(const std::string& filename) { @@ -31,6 +44,12 @@ namespace fmri return res; } + /** + * String specialisation of read_vector. + * + * @param filename The filename to load. + * @return A vector of the lines in the source file. + */ template<> inline std::vector read_vector(const std::string& filename) { @@ -47,6 +66,15 @@ namespace fmri return res; } + /** + * Create a vector of pairs. + * + * @tparam T The first type + * @tparam U The second type + * @param a First vector + * @param b Second vector + * @return A vector of pair + */ template std::vector> combine(const std::vector& a, const std::vector& b) {