Cantera  3.1.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 V >
double dot4 (const V &x, const V &y)
 Templated Inner product of two vectors of length 4.
 
template<class V >
double dot5 (const V &x, const V &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 R >
poly6 (D x, R *c)
 Templated evaluation of a polynomial of order 6.
 
template<class D , class R >
poly8 (D x, R *c)
 Templated evaluation of a polynomial of order 8.
 
template<class D , class R >
poly5 (D x, R *c)
 Templated evaluation of a polynomial of order 5.
 
template<class D , class R >
poly4 (D x, R *c)
 Evaluates a polynomial of order 4.
 
template<class D , class R >
poly3 (D x, R *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 329 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 336 of file global.h.

◆ dot4()

template<class V >
double 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()

template<class V >
double 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()

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 82 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: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()

template<class D , class R >
R 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()

template<class D , class R >
R 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()

template<class D , class R >
R 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()

template<class D , class R >
R 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()

template<class D , class R >
R 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()

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 198 of file utilities.h.