Global Utility Functions

Classes

class  clockWC
 The class provides the wall clock timer in seconds. More...
class  LogPrintCtrl
 This class provides some printing and cropping utilities for writing to the logfile. More...
class  PrintCtrl
 This class provides some printing and cropping utilities. More...

Functions

template<class T , class S >
max (T i, S j)
 Maximum of two templated quantities, i and j.
template<class T , class S >
min (T i, S j)
 Minimum of two templated quantities, i and j.
template<class V >
doublereal dot4 (const V &x, const V &y)
 Templated Inner product of two vectors of length 4.
template<class V >
doublereal dot5 (const V &x, const V &y)
 Tempalted Inner product of two vectors of length 5.
template<class V >
doublereal dot6 (const V &x, const V &y)
 Tempalted Inner product of two vectors of length 6.
template<class InputIter , class InputIter2 >
doublereal 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 InputIter , class OutputIter , class S >
void increment_scale (InputIter begin, InputIter end, OutputIter out, S scale_factor)
template<class InputIter , class OutputIter >
void multiply_each (OutputIter x_begin, OutputIter x_end, InputIter y_begin)
 Multiply each entry in x by the corresponding entry in y.
template<class InputIter >
void resize_each (int m, InputIter begin, InputIter end)
 Invoke method 'resize' with argument m for a sequence of objects (templated version).
template<class InputIter >
doublereal absmax (InputIter begin, InputIter end)
 The maximum absolute value (templated version).
template<class InputIter , class OutputIter >
void normalize (InputIter begin, InputIter end, OutputIter out)
 Normalize the values in a sequence, such that they sum to 1.0 (templated version).
template<class InputIter , class OutputIter >
void divide_each (OutputIter x_begin, OutputIter x_end, InputIter y_begin)
 Templated divide of each element of x by the corresponding element of y.
template<class InputIter , class OutputIter >
void sum_each (OutputIter x_begin, OutputIter x_end, InputIter y_begin)
 Increment each entry in x by the corresponding entry in y.
template<class InputIter , class OutputIter , class IndexIter >
void scatter_copy (InputIter begin, InputIter end, OutputIter result, IndexIter index)
 Copies a contiguous range in a sequence to indexed positions in another sequence.
template<class InputIter , class RandAccessIter , class IndexIter >
void scatter_mult (InputIter mult_begin, InputIter mult_end, RandAccessIter data, IndexIter index)
 Multiply selected elements in an array by a contiguous sequence of multipliers.
template<class InputIter , class OutputIter , class IndexIter >
void scatter_divide (InputIter begin, InputIter end, OutputIter result, IndexIter index)
 Divide selected elements in an array by a contiguous sequence of divisors.
template<class InputIter >
doublereal sum_xlogx (InputIter begin, InputIter end)
 Compute

\[ \sum_k x_k \log x_k. \]

.

template<class InputIter1 , class InputIter2 >
doublereal sum_xlogQ (InputIter1 begin, InputIter1 end, InputIter2 Q_begin)
 Compute

\[ \sum_k x_k \log Q_k. \]

.

template<class OutputIter >
void scale (int N, double alpha, OutputIter x)
 Scale a templated vector by a constant 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 >
poly10 (D x, R *c)
 Templated evaluation of a polynomial of order 10.
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.

Function Documentation

doublereal Cantera::absmax ( InputIter  begin,
InputIter  end 
) [inline]

The maximum absolute value (templated version).

The template arguments are: template<class InputIter>

Simple code Equivalent:

   double x[10] amax = 0.0;
   for (int n = 0; n < 10; n++) {
    if (fabs(x[n]) > amax) amax = fabs(x[10]);
   }
   return amax;

Example of function call usage to implement the simple code example:

   double x[10]
   double amax = absmax(x, x+10);
Parameters:
begin Iterator pointing to the beginning of the x vector, belonging to the iterator class InputIter.
end Iterator pointing to the end of the x vector, belonging to the iterator class InputIter. The difference between end and begin determines the loop length

Definition at line 327 of file utilities.h.

void Cantera::divide_each ( OutputIter  x_begin,
OutputIter  x_end,
InputIter  y_begin 
) [inline]

Templated divide of each element of x by the corresponding element of y.

The template arguments are: template<class InputIter, class OutputIter>

Simple Equivalent:

   double x[10], y[10];
   for (n = 0; n < 10; n++) {
     x[n] /= y[n];
   }

Example of code usage:

   double x[10], y[10];
   divide_each(x, x+10, y);
Parameters:
x_begin Iterator pointing to the beginning of the x vector, belonging to the iterator class OutputIter.
x_end Iterator pointing to the end of the x vector, belonging to the iterator class OutputIter. The difference between end and begin determines the number of inner iterations.
y_begin Iterator pointing to the beginning of the yvector, belonging to the iterator class InputIter.

Definition at line 395 of file utilities.h.

doublereal 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 doublereal.

template<class InputIter, class InputIter2>

     double x[8], y[8];
     doublereal dsum = dot<double *,double *>(x, &x+7, y);
Parameters:
x_begin Iterator pointing to the beginning, belonging to the iterator class InputIter.
x_end Iterator pointing to the end, belonging to the iterator class InputIter.
y_begin Iterator 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 173 of file utilities.h.

Referenced by IdealSolnGasVPSS::calcDensity(), IdealSolidSolnPhase::calcDensity(), State::mean_Y(), State::setMoleFractions(), and State::setMoleFractions_NoNorm().

doublereal 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:
x first reference to the templated class V
y second reference to the templated class V
Returns:
This class returns a hard-coded type, doublereal.

Definition at line 112 of file utilities.h.

doublereal Cantera::dot5 ( const V &  x,
const V &  y 
) [inline]

Tempalted 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:
x first reference to the templated class V
y second reference to the templated class V
Returns:
This class returns a hard-coded type, doublereal.

Definition at line 129 of file utilities.h.

doublereal Cantera::dot6 ( const V &  x,
const V &  y 
) [inline]

Tempalted Inner product of two vectors of length 6.

If either x or y has length greater than 4, only the first 4 elements will be used.

Parameters:
x first reference to the templated class V
y second reference to the templated class V
Returns:
This class returns a hard-coded type, doublereal.

Definition at line 146 of file utilities.h.

void Cantera::increment_scale ( InputIter  begin,
InputIter  end,
OutputIter  out,
scale_factor 
) [inline]

Multiply elements of an array, y, by a scale factor, f and add the result to an existing array, x. This is essentially a templated daxpy_ operation.

The template arguments are: template<class InputIter, class OutputIter, class S>

Simple Code Example of the functionality;

       double x[10], y[10], f;
       for (i = 0; i < n; i++) {
         y[i] += f * x[i]
       }

Example of the function call to implement the simple code example

      double x[10], y[10], f;
      increment_scale(x, x+10, y, f); 

It is templated with three parameters. The first template is the iterator, InputIter, which controls access to y[]. The second template is the iterator OutputIter, which controls access to y[]. The third iterator is S, which is f.

Parameters:
begin InputIter Iterator for beginning of y[]
end inputIter Iterator for end of y[]
out OutputIter Iterator for beginning of x[]
scale_factor Scale Factor to multiply y[i] by

Definition at line 232 of file utilities.h.

T Cantera::max ( i,
j 
) [inline]

Maximum of two templated quantities, i and j.

If i and j have different types, j is converted to the type of i before the comparison.

Parameters:
i first argument, instance of templated class T
j Second argument, instance of templated class S
Returns:
This function returns the maximum of the two values as an instance of templated type T.

Definition at line 79 of file utilities.h.

Referenced by GeneralSpeciesThermo::install(), GeneralSpeciesThermo::install_STIT(), and MolalityVPSSTP::setMolalitiesByName().

T Cantera::min ( i,
j 
) [inline]

Minimum of two templated quantities, i and j.

If i and j have different types, j is converted to the type of i before the comparison.

Parameters:
i first argument, instance of templated class T
j Second argument, instance of templated class S
Returns:
This function returns the minimum of the two values as an instance of templated type T.

Definition at line 95 of file utilities.h.

Referenced by GeneralSpeciesThermo::install(), and GeneralSpeciesThermo::install_STIT().

void Cantera::multiply_each ( OutputIter  x_begin,
OutputIter  x_end,
InputIter  y_begin 
) [inline]

Multiply each entry in x by the corresponding entry in y.

The template arguments are: template<class InputIter, class OutputIter>

Simple code Equivalent:

   double x[10], y[10]
   for (n = 0; n < 10; n++) {
     x[n] *= y[n];
   }

Example of function call usage to implement the simple code example:

     double x[10], y[10]
     multiply_each(x, x+10, y);
Parameters:
x_begin Iterator pointing to the beginning of the vector x, belonging to the iterator class InputIter.
x_end Iterator pointing to the end of the vector x, belonging to the iterator class InputIter. The difference between end and begin determines the loop length
y_begin Iterator pointing to the beginning of the vector y, belonging to the iterator class outputIter.

Definition at line 265 of file utilities.h.

void Cantera::normalize ( InputIter  begin,
InputIter  end,
OutputIter  out 
) [inline]

Normalize the values in a sequence, such that they sum to 1.0 (templated version).

The template arguments are: template<class InputIter, class OutputIter>

Simple Equivalent:

   double x[10], y[10], sum = 0.0;
   for (int n = 0; n < 10; n++) {
    sum += x[10];
   }
   for (int n = 0; n < 10; n++) {
    y[n] = x[n]/sum;
   }

Example of function call usage:

   double x[10], y[10]; 
   normalize(x, x+10, y);
Parameters:
begin Iterator pointing to the beginning of the x vector, belonging to the iterator class InputIter.
end Iterator pointing to the end of the x vector, belonging to the iterator class InputIter. The difference between end and begin determines the loop length
out Iterator pointing to the beginning of the output vector, belonging to the iterator class OutputIter.

Definition at line 363 of file utilities.h.

R Cantera::poly10 ( x,
R *  c 
) [inline]

Templated evaluation of a polynomial of order 10.

Parameters:
x Value of the independent variable - First template parameter
c Pointer to the polynomial - Second template parameter

Definition at line 625 of file utilities.h.

R Cantera::poly3 ( x,
R *  c 
) [inline]

Templated evaluation of a polynomial of order 3.

Parameters:
x Value of the independent variable - First template parameter
c Pointer to the polynomial - Second template parameter

Definition at line 659 of file utilities.h.

R Cantera::poly4 ( x,
R *  c 
) [inline]

Evaluates a polynomial of order 4.

Parameters:
x Value of the independent variable.
c Pointer to the polynomial coefficient array.

Definition at line 648 of file utilities.h.

Referenced by NasaThermo::checkContinuity().

R Cantera::poly5 ( x,
R *  c 
) [inline]

Templated evaluation of a polynomial of order 5.

Parameters:
x Value of the independent variable - First template parameter
c Pointer to the polynomial - Second template parameter

Definition at line 637 of file utilities.h.

R Cantera::poly6 ( x,
R *  c 
) [inline]

Templated evaluation of a polynomial of order 6.

Parameters:
x Value of the independent variable - First template parameter
c Pointer to the polynomial - Second template parameter

Definition at line 603 of file utilities.h.

R Cantera::poly8 ( x,
R *  c 
) [inline]

Templated evaluation of a polynomial of order 8.

Parameters:
x Value of the independent variable - First template parameter
c Pointer to the polynomial - Second template parameter

Definition at line 614 of file utilities.h.

void Cantera::resize_each ( int  m,
InputIter  begin,
InputIter  end 
) [inline]

Invoke method 'resize' with argument m for a sequence of objects (templated version).

The template arguments are: template<class InputIter>

Simple code Equivalent:

   vector<vector<double> *> VV;
   for (n = 0; n < 20; n++) {
     vector<double> *vp = VV[n];
     vp->resize(m);
   }

Example of function call usage to implement the simple code example:

    vector<vector<double> *> VV;
    resize_each(m, &VV[0], &VV[20]);
Parameters:
m Integer specifying the size that each object should be resized to.
begin Iterator pointing to the beginning of the sequence of object, belonging to the iterator class InputIter.
end Iterator pointing to the end of the sequence of objects, belonging to the iterator class InputIter. The difference between end and begin determines the loop length
Note:
This is currently unused.

Definition at line 298 of file utilities.h.

void Cantera::scale ( int  N,
double  alpha,
OutputIter  x 
) [inline]

Scale a templated vector by a constant factor.

The template arguments are: template<class OutputIter>

This function is essentially a wrapper around the stl function scale(). The function is has one template parameter, OutputIter. OutputIter is a templated iterator that points to the vector to be scaled.

Parameters:
N Length of the vector
alpha scale factor - double
x Templated Iterator to the start of the vector to be scaled.

Definition at line 592 of file utilities.h.

References Cantera::scale().

void Cantera::scale ( InputIter  begin,
InputIter  end,
OutputIter  out,
scale_factor 
) [inline]

Multiply elements of an array by a scale factor.

 vector_fp in(8, 1.0), out(8);
 scale(in.begin(), in.end(), out.begin(), factor);
Parameters:
begin Iterator pointing to the beginning, belonging to the iterator class InputIter.
end Iterator pointing to the end, belonging to the iterator class InputIter.
out Iterator pointing to the beginning of out, belonging to the iterator class OutputIter. This is the output variable for this routine.
scale_factor input scale factor belonging to the class S.

Definition at line 195 of file utilities.h.

Referenced by State::getConcentrations(), SurfPhase::getCp_R(), SurfPhase::getEnthalpy_RT(), SurfPhase::getEntropy_R(), VPSSMgr_General::getGibbs_ref(), VPSSMgr::getGibbs_ref(), IdealGasPhase::getGibbs_ref(), SurfPhase::getGibbs_RT(), VPSSMgr_ConstVol::getGibbs_RT_ref(), State::getMoleFractions(), IdealSolnGasVPSS::getPartialMolarCp(), IdealGasPhase::getPartialMolarCp(), IdealSolnGasVPSS::getPartialMolarEnthalpies(), IdealSolidSolnPhase::getPartialMolarEnthalpies(), IdealGasPhase::getPartialMolarEnthalpies(), IdealSolnGasVPSS::getPartialMolarEntropies(), IdealGasPhase::getPartialMolarEntropies(), IdealSolnGasVPSS::getPartialMolarIntEnergies(), IdealGasPhase::getPureGibbs(), ConstDensityThermo::getPureGibbs(), VPSSMgr::getStandardChemPotentials(), IdealGasPhase::getStandardChemPotentials(), Cantera::operator*=(), Cantera::scale(), and State::setMassFractions().

void Cantera::scatter_copy ( InputIter  begin,
InputIter  end,
OutputIter  result,
IndexIter  index 
) [inline]

Copies a contiguous range in a sequence to indexed positions in another sequence.

The template arguments are: template<class InputIter, class OutputIter, class IndexIter>

Example:

  vector<double> x(3), y(20), ;
  vector<int> index(3);
  index[0] = 9;
  index[1] = 2;
  index[3] = 16; 
  scatter_copy(x.begin(), x.end(), y.begin(), index.begin());

This routine is templated 3 times. InputIter is an iterator for the source vector OutputIter is an iterator for the destination vector IndexIter is an iterator for the index into the destination vector.

Parameters:
begin Iterator pointing to the beginning of the source vector, belonging to the iterator class InputIter.
end Iterator pointing to the end of the source vector, belonging to the iterator class InputIter. The difference between end and begin determines the number of inner iterations.
result Iterator pointing to the beginning of the output vector, belonging to the iterator class outputIter.
index Iterator pointing to the beginning of the index vector, belonging to the iterator class IndexIter.

Definition at line 450 of file utilities.h.

void Cantera::scatter_divide ( InputIter  begin,
InputIter  end,
OutputIter  result,
IndexIter  index 
) [inline]

Divide selected elements in an array by a contiguous sequence of divisors.

The template arguments are: template<class InputIter, class OutputIter, class IndexIter>

Example:

 double divisors[] = {8.9, -2.0, 5.6};
 int index[] = {7, 4, 13};
 vector_fp data(20);
 ...
 // divide elements 7, 4, and 13 in data by divisors[7] divisors[4], and divisors[13]
 // respectively
 scatter_divide(divisors, divisors + 3, data.begin(), index);
Parameters:
begin Iterator pointing to the beginning of the source vector, belonging to the iterator class InputIter.
end Iterator pointing to the end of the source vector, belonging to the iterator class InputIter. The difference between end and begin determines the number of inner iterations.
result Iterator pointing to the beginning of the output vector, belonging to the iterator class outputIter.
index Iterator pointing to the beginning of the index vector, belonging to the iterator class IndexIter.

Definition at line 519 of file utilities.h.

void Cantera::scatter_mult ( InputIter  mult_begin,
InputIter  mult_end,
RandAccessIter  data,
IndexIter  index 
) [inline]

Multiply selected elements in an array by a contiguous sequence of multipliers.

The template arguments are: template<class InputIter, class RandAccessIter, class IndexIter>

Example:

 double multipliers[] = {8.9, -2.0, 5.6};
 int index[] = {7, 4, 13};
 vector_fp data(20);
 ...
 // Multiply elements 7, 4, and 13 in data by multipliers[0], multipliers[1],and multipliers[2],
 // respectively
 scatter_mult(multipliers, multipliers + 3, data.begin(), index);
Parameters:
mult_begin Iterator pointing to the beginning of the multiplier vector, belonging to the iterator class InputIter.
mult_end Iterator pointing to the end of the multiplier vector, belonging to the iterator class InputIter. The difference between end and begin determines the number of inner iterations.
data Iterator pointing to the beginning of the output vector, belonging to the iterator class RandAccessIter, that will be selectively multipied.
index Iterator pointing to the beginning of the index vector, belonging to the iterator class IndexIter.

Definition at line 485 of file utilities.h.

void Cantera::sum_each ( OutputIter  x_begin,
OutputIter  x_end,
InputIter  y_begin 
) [inline]

Increment each entry in x by the corresponding entry in y.

The template arguments are: template<class InputIter, class OutputIter>

Parameters:
x_begin Iterator pointing to the beginning of the x vector, belonging to the iterator class OutputIter.
x_end Iterator pointing to the end of the x vector, belonging to the iterator class OutputIter. The difference between end and begin determines the number of inner iterations.
y_begin Iterator pointing to the beginning of the yvector, belonging to the iterator class InputIter.

Definition at line 413 of file utilities.h.

Referenced by Cantera::operator+=().

doublereal Cantera::sum_xlogQ ( InputIter1  begin,
InputIter1  end,
InputIter2  Q_begin 
) [inline]

Compute

\[ \sum_k x_k \log Q_k. \]

.

The template arguments are: template<class InputIter1, class InputIter2>

This class is templated twice. The first template, InputIter1 is the iterator that points to $x_k$. The second iterator InputIter2, point to $Q_k$. A small number (1.0E-20) is added before taking the log.

Parameters:
begin Iterator pointing to the beginning, belonging to the iterator class InputIter1.
end Iterator pointing to the end, belonging to the iterator class InputIter1.
Q_begin Iterator pointing to the beginning of Q_k, belonging to the iterator class InputIter2.
Returns:
The return from this class is hard coded to a doublereal.

Definition at line 568 of file utilities.h.

References Cantera::Tiny.

doublereal Cantera::sum_xlogx ( InputIter  begin,
InputIter  end 
) [inline]

Compute

\[ \sum_k x_k \log x_k. \]

.

The template arguments are: template<class InputIter>

A small number (1.0E-20) is added before taking the log. This templated class does the indicated sun. The template must be an iterator.

Parameters:
begin Iterator pointing to the beginning, belonging to the iterator class InputIter.
end Iterator pointing to the end, belonging to the iterator class InputIter.
Returns:
The return from this class is a double.

Definition at line 541 of file utilities.h.

References Cantera::Tiny.

Generated by  doxygen 1.6.3