Updated code taking into account Adam's comments + bugfix

This commit is contained in:
Hombre
2016-02-13 17:54:47 +01:00
parent 4665b88788
commit de7c6d773a
13 changed files with 539 additions and 571 deletions

View File

@@ -80,7 +80,8 @@ inline const _Tp& max(const _Tp& a, const _Tp& b, const _Tp& c, const _Tp& d)
}
template<typename _Tp>
inline const _Tp intp(const _Tp a, const _Tp b, const _Tp c) {
inline const _Tp intp(const _Tp a, const _Tp b, const _Tp c)
{
// calculate a * b + (1 - a) * c
// following is valid:
// intp(a, b+x, c+x) = intp(a, b, c) + x
@@ -88,5 +89,23 @@ inline const _Tp intp(const _Tp a, const _Tp b, const _Tp c) {
return a * (b-c) + c;
}
template<typename T>
T norm1(const T& x, const T& y)
{
return std::abs(x) + std::abs(y);
}
template<typename T>
T norm2(const T& x, const T& y)
{
return std::sqrt(x * x + y * y);
}
template< typename T >
T norminf(const T& x, const T& y)
{
return std::max(std::abs(x), std::abs(y));
}
}
#endif