Cantera  4.0.0a1
Loading...
Searching...
No Matches
Templated Array and Polynomial Operations

These are templates to perform various simple operations on arrays. More...

Collaboration diagram for Templated Array and Polynomial Operations:

Detailed Description

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 >
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 X , class Y >
auto dot4 (const X &x, const Y &y)
 Templated Inner product of two vectors of length 4.
 
template<class X , class Y >
auto dot5 (const X &x, const Y &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 C >
auto poly6 (D x, const C &c)
 Templated evaluation of a polynomial of order 6.
 
template<class D , class C >
auto poly8 (D x, const C &c)
 Templated evaluation of a polynomial of order 8.
 
template<class D , class C >
auto poly5 (D x, const C &c)
 Templated evaluation of a polynomial of order 5.
 
template<class D , class C >
auto poly4 (D x, const C &c)
 Evaluates a polynomial of order 4.
 
template<class D , class C >
auto poly3 (D x, const C &c)
 Templated evaluation of a polynomial of order 3.
 
template<class T , class U = int>
len (const T &container)
 Get the size of a container, cast to a signed integer type.
 

Function Documentation

◆ clip()

template<class T >
T clip ( const T &  value,
const T &  lower,
const T &  upper 
)
inline

Clip value such that lower <= value <= upper.

Definition at line 326 of file global.h.

◆ sign()

template<typename T >
int sign ( x)

Sign of a number.

Returns -1 if x < 0, 1 if x > 0 and 0 if x == 0.

Definition at line 333 of file global.h.

◆ dot4()

template<class X , class Y >
auto dot4 ( const X &  x,
const Y &  y 
)
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.

Parameters
xfirst reference to the templated class V
ysecond reference to the templated class V
Returns
This class returns a hard-coded type, double.

Definition at line 42 of file utilities.h.

◆ dot5()

template<class X , class Y >
auto dot5 ( const X &  x,
const Y &  y 
)
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.

Parameters
xfirst reference to the templated class V
ysecond reference to the templated class V
Returns
This class returns a hard-coded type, double.

Definition at line 63 of file utilities.h.

◆ dot()

template<class InputIter , class InputIter2 >
double dot ( InputIter  x_begin,
InputIter  x_end,
InputIter2  y_begin 
)
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>

double x[8], y[8];
double dsum = dot<double *,double *>(x, &x+7, y);
Parameters
x_beginIterator pointing to the beginning, belonging to the iterator class InputIter.
x_endIterator pointing to the end, belonging to the iterator class InputIter.
y_beginIterator pointing to the beginning of y, belonging to the iterator class InputIter2.
Returns
The return is hard-coded to return a double.

Definition at line 96 of file utilities.h.

◆ scale()

template<class InputIter , class OutputIter , class S >
void scale ( InputIter  begin,
InputIter  end,
OutputIter  out,
scale_factor 
)
inline

Multiply elements of an array by a scale factor.

vector<double> in(8, 1.0), out(8);
scale(in.begin(), in.end(), out.begin(), factor);
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
Definition utilities.h:118
Parameters
beginIterator pointing to the beginning, belonging to the iterator class InputIter.
endIterator pointing to the end, belonging to the iterator class InputIter.
outIterator pointing to the beginning of out, belonging to the iterator class OutputIter. This is the output variable for this routine.
scale_factorinput scale factor belonging to the class S.

Definition at line 118 of file utilities.h.

◆ poly6()

template<class D , class C >
auto poly6 ( x,
const C &  c 
)

Templated evaluation of a polynomial of order 6.

Parameters
xValue of the independent variable - First template parameter
cPointer to the polynomial - Second template parameter

Definition at line 131 of file utilities.h.

◆ poly8()

template<class D , class C >
auto poly8 ( x,
const C &  c 
)

Templated evaluation of a polynomial of order 8.

Parameters
xValue of the independent variable - First template parameter
cPointer to the polynomial - Second template parameter

Definition at line 147 of file utilities.h.

◆ poly5()

template<class D , class C >
auto poly5 ( x,
const C &  c 
)

Templated evaluation of a polynomial of order 5.

Parameters
xValue of the independent variable - First template parameter
cPointer to the polynomial - Second template parameter

Definition at line 163 of file utilities.h.

◆ poly4()

template<class D , class C >
auto poly4 ( x,
const C &  c 
)

Evaluates a polynomial of order 4.

Parameters
xValue of the independent variable.
cPointer to the polynomial coefficient array.

Definition at line 179 of file utilities.h.

◆ poly3()

template<class D , class C >
auto poly3 ( x,
const C &  c 
)

Templated evaluation of a polynomial of order 3.

Parameters
xValue of the independent variable - First template parameter
cPointer to the polynomial - Second template parameter

Definition at line 195 of file utilities.h.

◆ len()

template<class T , class U = int>
U len ( const T &  container)

Get the size of a container, cast to a signed integer type.

Definition at line 231 of file utilities.h.