Functions
corbo::util Namespace Reference

Functions

template<class T >
constexpr const T & clamp (const T &v, const T &lo, const T &hi)
 Bound a value to a lower and upper limit if exceeded. More...
 
template<class T >
constexpr const bool is_in_bounds (const T &v, const T &lo, const T &hi)
 Check if a value is inside the interval [lo, hi]. More...
 
template<class T , class Iterator >
const bool is_in_bounds_all (Iterator first, Iterator last, const T &lo, const T &hi)
 Check if all components of a container are inside the interval [lo, hi]. More...
 
double l2_norm_2d (double a, double b)
 Compute the l2 norm of a 2d vector [a,b] as sqrt(a*a+b*b) More...
 
template<typename T , typename... Args>
std::unique_ptr< T > make_unique (Args &&... args)
 Constructs an object of type T and wraps it in a std::unique_ptr. More...
 
double max_approx_continuous (double x, double y, double eps)
 Continuous approximation of the max-operator. More...
 
template<class T >
int sign (T val)
 Signum function. More...
 
template<class ValT , class SignT >
ValT sign (ValT a, SignT b)
 Return value a with sign of value b. More...
 

Function Documentation

◆ clamp()

template<class T >
constexpr const T& corbo::util::clamp ( const T &  v,
const T &  lo,
const T &  hi 
)

Bound a value to a lower and upper limit if exceeded.

Parameters
[in]vvalue
[in]lolower bound
[in]hiupper bound
Template Parameters
Tvalue and bound type which must be less-comparable (<)
Returns
v if lo <= v <= hi, lo if v < lo and hi if v > hi.

Definition at line 49 of file core/include/corbo-core/utilities.h.

◆ is_in_bounds()

template<class T >
constexpr const bool corbo::util::is_in_bounds ( const T &  v,
const T &  lo,
const T &  hi 
)

Check if a value is inside the interval [lo, hi].

Parameters
[in]vvalue
[in]lolower bound
[in]hiupper bound
Template Parameters
Tvalue and bound type which must be comparable (<, >)
Returns
true if lo <= v <= hi, false otherwise.

Definition at line 64 of file core/include/corbo-core/utilities.h.

◆ is_in_bounds_all()

template<class T , class Iterator >
const bool corbo::util::is_in_bounds_all ( Iterator  first,
Iterator  last,
const T &  lo,
const T &  hi 
)
inline

Check if all components of a container are inside the interval [lo, hi].

Parameters
[in]firstiterator pointing to the begin of a container
[in]lastiterator pointing to the end of a container
[in]olower bound
[in]hiupper bound
Template Parameters
Tvalue and bound type which must be comparable (<, >)
IteratorContainer iterator type
Returns
true if lo <= v <= hi, false otherwise.

Definition at line 81 of file core/include/corbo-core/utilities.h.

◆ l2_norm_2d()

double corbo::util::l2_norm_2d ( double  a,
double  b 
)
inline

Compute the l2 norm of a 2d vector [a,b] as sqrt(a*a+b*b)

Definition at line 122 of file core/include/corbo-core/utilities.h.

◆ make_unique()

template<typename T , typename... Args>
std::unique_ptr<T> corbo::util::make_unique ( Args &&...  args)
inline

Constructs an object of type T and wraps it in a std::unique_ptr.

Until C++14 is not widespread, we define our own make_unique.

Parameters
argsArbitrary argument list that is compatible with the constructor list required by type T
Returns
std::unique_ptr of type T constructed with args

Definition at line 135 of file core/include/corbo-core/utilities.h.

◆ max_approx_continuous()

double corbo::util::max_approx_continuous ( double  x,
double  y,
double  eps 
)
inline

Continuous approximation of the max-operator.

Approximates max(x,y).

Parameters
[in]xfirst value
[in]ysecond value
[in]epscoefficient
Returns
approximation of max(x,y)

Definition at line 43 of file numerics/include/corbo-numerics/utilities.h.

◆ sign() [1/2]

template<class T >
int corbo::util::sign ( val)
inline

Signum function.

if val < 0: -1, if val > 0: 1, if val == 0: 0.

Parameters
[in]valvalue of type T
Template Parameters
Tvalue type with T(0) as zero value and the type must support "<".
Returns
integer {-1, 0, 1} according to the rules specified above.

Definition at line 100 of file core/include/corbo-core/utilities.h.

◆ sign() [2/2]

template<class ValT , class SignT >
ValT corbo::util::sign ( ValT  a,
SignT  b 
)
inline

Return value a with sign of value b.

If b > 0 then the result is |a|, else it is -|a|.

Parameters
[in]avalue which is subject to sign of b
[in]bvalue from which the sign is extracted
Template Parameters
ValTType of a
SignTType of b (must support SignT(0))
Returns
|a| with sign of b and type ValT.

Definition at line 116 of file core/include/corbo-core/utilities.h.



control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:08:03