1 #ifndef TIL_MISC_SCALAR_FUNCTIONS_H_ 2 #define TIL_MISC_SCALAR_FUNCTIONS_H_ 9 template <
typename T >
INLINE const T
square(
const T &a) {
return a*a;}
11 template <
typename T >
INLINE const T
cube(
const T &a) {
return a*a*a;}
13 template <
typename T >
INLINE const T
max(
const T &a,
const T &b) {
return ((a>b)?a:b);}
15 template <
typename T >
INLINE const T
min(
const T &a,
const T &b) {
return ((a<b)?a:b);}
17 template <
typename T >
INLINE const T
max(
const T &a,
const T &b,
const T &c) {
return max(
max(a,b),c);}
19 template <
typename T >
INLINE const T
min(
const T &a,
const T &b,
const T &c) {
return min(
min(a,b),c);}
21 template <
typename T >
INLINE const T
min(
const T &a,
const T &b,
const T &c,
const T &d) {
return min(
min(
min(a,b),c),d);}
23 template <
typename T >
24 inline const T
crop(
const T & x,
const T & a,
const T & b) {
return min(
max(x, a), b); }
26 template <
typename T,
typename TInt >
27 inline const T
rangecrop(
const T & x, TInt dim) {
return crop<T>(x, 0, dim-1); }
32 template <
typename T >
INLINE double norm(
const T &a,
const T &b) {
return std::sqrt(
double(a*a+b*b)); }
34 template <
typename T >
INLINE double norm(
const T &a,
const T &b,
const T &c) {
return std::sqrt(
double(a*a+b*b+c*c)); }
37 template <
typename T >
41 T res = (n%2 ? x : 1);
boost::enable_if< is_Image< TImage >, typename TImage::value_type >::type min(const TImage &im)
void sqrt(const TImage &in, TImage &out)
INLINE double norm(const T &a, const T &b)
< Euclidean norm of 2D vector (a, b)
Belongs to package Box Do not include directly, include til/Box.h instead.
const T rangecrop(const T &x, TInt dim)
Absolute value of a number.
INLINE const T cube(const T &a)
Max of two numbers.
TImage::value_type max(const TImage &im)
Returns the maximum intensity of the input image.
const T crop(const T &x, const T &a, const T &b)
Force x into [0, dim-1].
void square(const TImage &in, TImage &out)
T integer_pow(T x, unsigned int n)