19 #ifndef CT_UTILITIES_H
20 #define CT_UTILITIES_H
40 inline double dot4(
const V& x,
const V& y)
42 return x[0]*y[0] + x[1]*y[1] + x[2]*y[2] + x[3]*y[3];
55 inline double dot5(
const V& x,
const V& y)
57 return x[0]*y[0] + x[1]*y[1] + x[2]*y[2] + x[3]*y[3] +
81 template<
class InputIter,
class InputIter2>
82 inline double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
84 return std::inner_product(x_begin, x_end, y_begin, 0.0);
103 template<
class InputIter,
class OutputIter,
class S>
104 inline void scale(InputIter begin, InputIter end,
105 OutputIter out, S scale_factor)
107 std::transform(begin, end, out,
108 [scale_factor](
double x) {
return x * scale_factor; });
116 template<
class D,
class R>
119 return ((((((c[6]*x + c[5])*x + c[4])*x + c[3])*x +
120 c[2])*x + c[1])*x + c[0]);
128 template<
class D,
class R>
131 return ((((((((c[8]*x + c[7])*x + c[6])*x + c[5])*x + c[4])*x + c[3])*x +
132 c[2])*x + c[1])*x + c[0]);
140 template<
class D,
class R>
143 return (((((c[5]*x + c[4])*x + c[3])*x +
144 c[2])*x + c[1])*x + c[0]);
152 template<
class D,
class R>
155 return ((((c[4]*x + c[3])*x +
156 c[2])*x + c[1])*x + c[0]);
164 template<
class D,
class R>
167 return (((c[3]*x + c[2])*x + c[1])*x + c[0]);
182 void checkFinite(
const string& name,
double* values,
size_t N);
189 template <
class T,
class U>
190 const U&
getValue(
const map<T, U>& m,
const T& key,
const U& default_val) {
191 typename map<T,U>::const_iterator iter = m.find(key);
192 return (iter == m.end()) ? default_val : iter->second;
197 template <
class T,
class U=
int>
198 U
len(
const T& container) {
199 return static_cast<U
>(container.size());
205 #define CT_DEFINE_HAS_MEMBER(detector_name, func_name) \
206 template<class T, class=void> \
207 struct detector_name : std::false_type {}; \
209 struct detector_name<T, std::void_t<decltype(&T::func_name)>> : std::true_type {};
This file contains definitions of constants, types and terms that are used in internal routines and a...
U len(const T &container)
Get the size of a container, cast to a signed integer type.
double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
double dot5(const V &x, const V &y)
Templated Inner product of two vectors of length 5.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
R poly5(D x, R *c)
Templated evaluation of a polynomial of order 5.
R poly8(D x, R *c)
Templated evaluation of a polynomial of order 8.
R poly3(D x, R *c)
Templated evaluation of a polynomial of order 3.
R poly4(D x, R *c)
Evaluates a polynomial of order 4.
R poly6(D x, R *c)
Templated evaluation of a polynomial of order 6.
double dot4(const V &x, const V &y)
Templated Inner product of two vectors of length 4.
Namespace for the Cantera kernel.
void checkFinite(const double tmp)
Check to see that a number is finite (not NaN, +Inf or -Inf)
const U & getValue(const map< T, U > &m, const T &key, const U &default_val)
Const accessor for a value in a map.