Reach compatibility with gcc 4.4

Replace std::abs with my own function.