diff --git a/maths.cpp b/maths.cpp index a65d911e..99b3e30e 100644 --- a/maths.cpp +++ b/maths.cpp @@ -27,7 +27,7 @@ template T pow2 (T value) -{ return value * value; } + { return value * value; } template double pow2(double); template int pow2( int); @@ -36,7 +36,7 @@ template int pow2( int); template double rootsquare (T a, T b) -{ return sqrt (pow2 (a) + pow2 (b)); } + { return sqrt (pow2 (a) + pow2 (b)); } template double rootsquare (double, double); template double rootsquare ( int, int); @@ -44,13 +44,13 @@ template double rootsquare ( int, int); template <> bool -almost_equal (float a, float b) +almost_equal (const float &a, const float &b) { return ieee_single::almost_equal (a, b); } template <> bool -almost_equal (double a, double b) +almost_equal (const double &a, const double &b) { return ieee_double::almost_equal (a, b); } diff --git a/maths.hpp b/maths.hpp index 9c8db6de..2662704e 100644 --- a/maths.hpp +++ b/maths.hpp @@ -20,15 +20,17 @@ #ifndef __MATHS_HPP #define __MATHS_HPP +#include "annotations.hpp" + template T -pow2 (T value); +pow2 (T value) pure; template double -rootsquare (T a, T b); +rootsquare (T a, T b) pure; /** @@ -40,13 +42,13 @@ rootsquare (T a, T b); template bool -almost_equal (T a, T b) +almost_equal (const T &a, const T &b) { return a == b; } template bool -almost_equal (Ta a, Tb b) { +almost_equal (const Ta &a, const Tb &b) { return almost_equal (static_cast(a), static_cast(b)); } @@ -54,19 +56,19 @@ almost_equal (Ta a, Tb b) { template <> bool -almost_equal (float a, float b); +almost_equal (const float &a, const float &b); template <> bool -almost_equal (double a, double b); +almost_equal (const double &a, const double &b); /// Variadic minimum template const T& min (const T &a) - { return a ; } + { return a; } template @@ -79,7 +81,7 @@ min (const T &a , const T &b , const Args &...args ) template const T& max (const T &a) - { return a ; } + { return a; } template @@ -88,5 +90,4 @@ max (const T &a , const T &b , const Args &...args ) { return max ( b > a ? b : a, args...); } - #endif // __MATHS_HPP diff --git a/types.hpp b/types.hpp index e40d07d0..83973cde 100644 --- a/types.hpp +++ b/types.hpp @@ -1,6 +1,7 @@ #ifndef __TYPES_HPP #define __TYPES_HPP +#include "annotations.hpp" #include "enable_if.hpp" #include @@ -124,12 +125,12 @@ size_t elems(T (&)[N]) /// Convert a scalar from host byte order to network byte order template -T hton (T); +T hton (T) pure; /// Convert a scalar from network byte order to host byte order template -T ntoh (T); +T ntoh (T) pure; template