These are templates to perform various simple operations on arrays. More...
These are templates to perform various simple operations on arrays.
Note that the compiler will inline these, so using them carries no performance penalty.
Functions | |
template<class T > | |
T | clip (const T &value, const T &lower, const T &upper) |
Clip value such that lower <= value <= upper. | |
template<typename T > | |
int | sign (T x) |
Sign of a number. | |
template<class V > | |
double | dot4 (const V &x, const V &y) |
Templated Inner product of two vectors of length 4. | |
template<class V > | |
double | dot5 (const V &x, const V &y) |
Templated Inner product of two vectors of length 5. | |
template<class InputIter , class InputIter2 > | |
double | dot (InputIter x_begin, InputIter x_end, InputIter2 y_begin) |
Function that calculates a templated inner product. | |
template<class InputIter , class OutputIter , class S > | |
void | scale (InputIter begin, InputIter end, OutputIter out, S scale_factor) |
Multiply elements of an array by a scale factor. | |
template<class D , class R > | |
R | poly6 (D x, R *c) |
Templated evaluation of a polynomial of order 6. | |
template<class D , class R > | |
R | poly8 (D x, R *c) |
Templated evaluation of a polynomial of order 8. | |
template<class D , class R > | |
R | poly5 (D x, R *c) |
Templated evaluation of a polynomial of order 5. | |
template<class D , class R > | |
R | poly4 (D x, R *c) |
Evaluates a polynomial of order 4. | |
template<class D , class R > | |
R | poly3 (D x, R *c) |
Templated evaluation of a polynomial of order 3. | |
template<class T , class U = int> | |
U | len (const T &container) |
Get the size of a container, cast to a signed integer type. | |
|
inline |
int sign | ( | T | x | ) |
|
inline |
Templated Inner product of two vectors of length 4.
If either x or y has length greater than 4, only the first 4 elements will be used.
x | first reference to the templated class V |
y | second reference to the templated class V |
Definition at line 40 of file utilities.h.
|
inline |
Templated Inner product of two vectors of length 5.
If either x or y has length greater than 4, only the first 4 elements will be used.
x | first reference to the templated class V |
y | second reference to the templated class V |
Definition at line 55 of file utilities.h.
|
inline |
Function that calculates a templated inner product.
This inner product is templated twice. The output variable is hard coded to return a double.
template<class InputIter, class InputIter2>
x_begin | Iterator pointing to the beginning, belonging to the iterator class InputIter. |
x_end | Iterator pointing to the end, belonging to the iterator class InputIter. |
y_begin | Iterator pointing to the beginning of y, belonging to the iterator class InputIter2. |
Definition at line 82 of file utilities.h.
|
inline |
Multiply elements of an array by a scale factor.
begin | Iterator pointing to the beginning, belonging to the iterator class InputIter. |
end | Iterator pointing to the end, belonging to the iterator class InputIter. |
out | Iterator pointing to the beginning of out, belonging to the iterator class OutputIter. This is the output variable for this routine. |
scale_factor | input scale factor belonging to the class S. |
Definition at line 104 of file utilities.h.
R poly6 | ( | D | x, |
R * | c | ||
) |
Templated evaluation of a polynomial of order 6.
x | Value of the independent variable - First template parameter |
c | Pointer to the polynomial - Second template parameter |
Definition at line 117 of file utilities.h.
R poly8 | ( | D | x, |
R * | c | ||
) |
Templated evaluation of a polynomial of order 8.
x | Value of the independent variable - First template parameter |
c | Pointer to the polynomial - Second template parameter |
Definition at line 129 of file utilities.h.
R poly5 | ( | D | x, |
R * | c | ||
) |
Templated evaluation of a polynomial of order 5.
x | Value of the independent variable - First template parameter |
c | Pointer to the polynomial - Second template parameter |
Definition at line 141 of file utilities.h.
R poly4 | ( | D | x, |
R * | c | ||
) |
Evaluates a polynomial of order 4.
x | Value of the independent variable. |
c | Pointer to the polynomial coefficient array. |
Definition at line 153 of file utilities.h.
R poly3 | ( | D | x, |
R * | c | ||
) |
Templated evaluation of a polynomial of order 3.
x | Value of the independent variable - First template parameter |
c | Pointer to the polynomial - Second template parameter |
Definition at line 165 of file utilities.h.
U len | ( | const T & | container | ) |
Get the size of a container, cast to a signed integer type.
Definition at line 198 of file utilities.h.