Cantera  3.1.0a1
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. More...
 
template<typename T >
int sign (T x)
 Sign of a number. More...
 
template<class V >
double dot4 (const V &x, const V &y)
 Templated Inner product of two vectors of length 4. More...
 
template<class V >
double dot5 (const V &x, const V &y)
 Templated Inner product of two vectors of length 5. More...
 
template<class InputIter , class InputIter2 >
double dot (InputIter x_begin, InputIter x_end, InputIter2 y_begin)
 Function that calculates a templated inner product. More...
 
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. More...
 
template<class D , class R >
poly6 (D x, R *c)
 Templated evaluation of a polynomial of order 6. More...
 
template<class D , class R >
poly8 (D x, R *c)
 Templated evaluation of a polynomial of order 8. More...
 
template<class D , class R >
poly5 (D x, R *c)
 Templated evaluation of a polynomial of order 5. More...
 
template<class D , class R >
poly4 (D x, R *c)
 Evaluates a polynomial of order 4. More...
 
template<class D , class R >
poly3 (D x, R *c)
 Templated evaluation of a polynomial of order 3. More...
 
template<class T , class U = int>
len (const T &container)
 Get the size of a container, cast to a signed integer type. More...
 

Function Documentation

◆ clip()

T Cantera::clip ( const T &  value,
const T &  lower,
const T &  upper 
)
inline

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

Definition at line 329 of file global.h.

◆ sign()

int Cantera::sign ( x)

Sign of a number.

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

Definition at line 336 of file global.h.

◆ dot4()

double Cantera::dot4 ( const V &  x,
const V &  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 40 of file utilities.h.

◆ dot5()

double Cantera::dot5 ( const V &  x,
const V &  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 55 of file utilities.h.

◆ dot()

double Cantera::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 82 of file utilities.h.

◆ scale()

void Cantera::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:104
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 104 of file utilities.h.

◆ poly6()

R Cantera::poly6 ( x,
R *  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 117 of file utilities.h.

◆ poly8()

R Cantera::poly8 ( x,
R *  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 129 of file utilities.h.

◆ poly5()

R Cantera::poly5 ( x,
R *  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 141 of file utilities.h.

◆ poly4()

R Cantera::poly4 ( x,
R *  c 
)

Evaluates a polynomial of order 4.

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

Definition at line 153 of file utilities.h.

◆ poly3()

R Cantera::poly3 ( x,
R *  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 165 of file utilities.h.

◆ len()

U Cantera::len ( const T &  container)

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

Definition at line 198 of file utilities.h.