1 #ifndef FILE_NGSTD_TEMPLATES
2 #define FILE_NGSTD_TEMPLATES
17 return (a < b) ? a : b;
24 return (a > b) ? a : b;
29 INLINE T
min3 (T a, T b, T c)
31 return (a < b) ? (a < c) ? a : c
37 INLINE T
max3 (T a, T b, T c)
40 return (a > b) ? ((a > c) ? a : c)
49 return (a > 0) ? 1 : ( ( a < 0) ? -1 : 0 );
54 INLINE T
sqr (
const T a)
68 void SaveBin (ostream & ost,
const T & val)
70 const char * cp =
reinterpret_cast<const char*
> (&val);
71 for (
unsigned j = 0; j <
sizeof(T); j++)
77 void LoadBin (istream & ist, T & val)
79 char * cp =
reinterpret_cast<char*
> (&val);
80 for (
unsigned j = 0; j <
sizeof(T); j++)
125 template <
int NUM,
typename FUNC>
126 INLINE
void Iterate (FUNC f)
128 if constexpr (NUM > 1) Iterate<NUM-1> (f);
129 if constexpr (NUM >= 1) f(IC<NUM-1>());
141 template <
typename FUNC>
142 static INLINE
void Do (
size_t nr, FUNC f)
155 template <
typename FUNC>
156 static INLINE
void Do (
size_t , FUNC ) { }
163 template <
typename FUNC>
164 static INLINE
void Do (
size_t , FUNC f)
171 template <
int NUM,
typename FUNC>
172 INLINE
void Switch (
size_t nr, FUNC f)
Definition: templates.hpp:138
INLINE T min2(T a, T b)
min of 2 values
Definition: templates.hpp:15
INLINE T max3(T a, T b, T c)
max of 3 values
Definition: templates.hpp:37
INLINE T max2(T a, T b)
max of 2 values
Definition: templates.hpp:22
INLINE int sgn(T a)
sign of value (+1, 0, -1)
Definition: templates.hpp:47
namespace for standard data types and algorithms.
Definition: ngstd.hpp:55
INLINE T min3(T a, T b, T c)
min of 3 values
Definition: templates.hpp:29
INLINE AutoDiffVec< D, SCAL > sqr(const AutoDiffVec< D, SCAL > &x)
AutoDiffVec times AutoDiffVec.
Definition: autodiff.hpp:251
INLINE T pow3(const T a)
element to the third power
Definition: templates.hpp:61