41template<
class X,
class Y>
42inline auto dot4(
const X& x,
const Y& y)
44 auto x_ = span{std::data(x), std::size(x)};
45 auto y_ = span{std::data(y), std::size(y)};
50 return x_[0]*y_[0] + x_[1]*y_[1] + x_[2]*y_[2] + x_[3]*y_[3];
62template<
class X,
class Y>
63inline auto dot5(
const X& x,
const Y& y)
65 auto x_ = span{std::data(x), std::size(x)};
66 auto y_ = span{std::data(y), std::size(y)};
71 return x_[0]*y_[0] + x_[1]*y_[1] + x_[2]*y_[2] + x_[3]*y_[3] +
95template<
class InputIter,
class InputIter2>
96inline double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
98 return std::inner_product(x_begin, x_end, y_begin, 0.0);
117template<
class InputIter,
class OutputIter,
class S>
118inline void scale(InputIter begin, InputIter end,
119 OutputIter out, S scale_factor)
121 std::transform(begin, end, out,
122 [scale_factor](
double x) {
return x * scale_factor; });
130template<
class D,
class C>
133 auto c_ = span{std::data(c), std::size(c)};
137 return ((((((c_[6]*x + c_[5])*x + c_[4])*x + c_[3])*x +
138 c_[2])*x + c_[1])*x + c_[0]);
146template<
class D,
class C>
149 auto c_ = span{std::data(c), std::size(c)};
153 return ((((((((c_[8]*x + c_[7])*x + c_[6])*x + c_[5])*x + c_[4])*x + c_[3])*x +
154 c_[2])*x + c_[1])*x + c_[0]);
162template<
class D,
class C>
165 auto c_ = span{std::data(c), std::size(c)};
169 return (((((c_[5]*x + c_[4])*x + c_[3])*x +
170 c_[2])*x + c_[1])*x + c_[0]);
178template<
class D,
class C>
181 auto c_ = span{std::data(c), std::size(c)};
185 return ((((c_[4]*x + c_[3])*x +
186 c_[2])*x + c_[1])*x + c_[0]);
194template<
class D,
class C>
197 auto c_ = span{std::data(c), std::size(c)};
201 return (((c_[3]*x + c_[2])*x + c_[1])*x + c_[0]);
215void checkFinite(
const string& name, span<const double> values);
222template <
class T,
class U>
223const U&
getValue(
const map<T, U>& m,
const T& key,
const U& default_val) {
224 typename map<T,U>::const_iterator iter = m.find(key);
225 return (iter == m.end()) ? default_val : iter->second;
230template <
class T,
class U=
int>
231U
len(
const T& container) {
232 return static_cast<U
>(container.size());
238#define CT_DEFINE_HAS_MEMBER(detector_name, func_name) \
239 template<class T, class=void> \
240 struct detector_name : std::false_type {}; \
242 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...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
U len(const T &container)
Get the size of a container, cast to a signed integer type.
auto poly5(D x, const C &c)
Templated evaluation of a polynomial of order 5.
auto dot5(const X &x, const Y &y)
Templated Inner product of two vectors of length 5.
auto poly4(D x, const C &c)
Evaluates a polynomial of order 4.
double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
auto poly3(D x, const C &c)
Templated evaluation of a polynomial of order 3.
auto poly8(D x, const C &c)
Templated evaluation of a polynomial of order 8.
auto poly6(D x, const C &c)
Templated evaluation of a polynomial of order 6.
auto dot4(const X &x, const Y &y)
Templated Inner product of two vectors of length 4.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
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.
void checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.