1 #ifndef TIL_MISCTOOLS_H 2 #define TIL_MISCTOOLS_H 20 template <
typename T >
24 for (res = 0; res == v1 || res == v2; ++res) {}
31 template <
typename T >
35 for (res = 0; res == v1 || res == v2 || res == v3; ++res) {}
42 template <
typename T >
46 for (res = 0; res == v1 || res == v2 || res == v3 || res == v4; ++res) {}
53 template <
typename T >
57 for (res = 0; res == v1 || res == v2 || res == v3 || res == v4 || res == v5; ++res) {}
66 template <
typename TFrom,
typename TTo >
73 return TTo(value - TFrom(0.5));
77 return TTo(value + TFrom(0.5));
81 template <
typename TFrom,
typename TTo >
89 template <
typename TFrom,
typename TTo >
96 return castValue_impl<TFrom,TTo>(value, test_type());
133 template <
typename T >
136 return std::numeric_limits<T>::is_integer?
145 template <
typename T >
157 template <
typename T >
171 template <
typename T >
185 T solve(T n, std::size_t N);
192 template <
typename T >
199 template <
typename T >
200 inline void sort(T & a, T & b, T & c);
212 template <
typename T >
214 {
if (maxx < x) maxx = x; }
219 template <
typename T >
221 {
if (minx > x) minx = x; }
225 template <
typename TPIterator,
typename TSIterator >
226 inline std::size_t
pos2offset(TPIterator pbegin, TPIterator pend, TSIterator sbegin)
228 std::size_t res = *pbegin;
229 while (++pbegin != pend)
240 template < std::
size_t D >
244 std::size_t res = pos[i];
void min_helper(T &minx, T x)
Little helper for something often used when looking for a minimum.
Compute the N-root of an integer.
T integer_root(T i, std::size_t n)
Return the n-th root of integer i.
boost::enable_if< is_Image< TImage >, typename TImage::value_type >::type min(const TImage &im)
Belongs to package Box Do not include directly, include til/Box.h instead.
void sort(T &a, T &b, T &c)
Sort a, b, c in decreasing order (a>=b>=c).
T type_min()
Returns the min of a type.
numeric_array< T, D > size(const Box< T, D > &box)
Return the size of a box.
TTo castValue(TFrom value)
TImage::value_type max(const TImage &im)
Returns the maximum intensity of the input image.
std::size_t pos2offset(TPIterator pbegin, TPIterator pend, TSIterator sbegin)
TIL_API char * mySprintf(const char *format,...)
T findValueOtherThan(T v1, T v2)
Returns a number (a positive integer) with a different value than the input numbers.
void max_helper(T &maxx, T x)
Little helper for something often used when looking for a maximum.
A label corresponding to a positive answer of a specific is_a test.
T operator()(T n, std::size_t N)
Return an N-root of integer n, that is, the integer i so that i^N = n.
void shift_right(T a, T &b, T &c)
Shifts value to the right, i.e c = b, b = a.
A label corresponding to a negative answer of a specific is_a test.
TIL_API ImageAxis operator++(ImageAxis &axis)