From 39bdc82fdea38f42c4127aba809dc4352a8279d3 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Mon, 11 Jun 2007 16:23:50 +0000 Subject: [PATCH] Doxygen update documented timesConstant and polynomial routines. --- Cantera/src/base/utilities.h | 133 ++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 41 deletions(-) diff --git a/Cantera/src/base/utilities.h b/Cantera/src/base/utilities.h index 2f0fc2291..240c10c8c 100755 --- a/Cantera/src/base/utilities.h +++ b/Cantera/src/base/utilities.h @@ -16,12 +16,33 @@ #include #endif - +//! Templated unary operator that carries out a multiplication operation +/*! + * Class carries out a multiplication operation ON ITSELF using + * a unary call. It inherits from the STL class, std::unary_function. + * The class contains one template, which is the underlying class. + * Note. This is outside the Cantera namespace ?! + */ template struct timesConstant : public std::unary_function { - timesConstant(T c) : m_c(c) {} - double operator()(T x) {return m_c * x;} - T m_c; + //! Constructor + /*! + * @param c Stores the value of c as the internal constant. + */ + timesConstant(T c) : m_c(c) {} + + //! Parenthesis operator that carries out a unary multiplication + //! and returns a double + /*! + * @param x value of the class which is input + * + * @return + * return m_c * x, which is defined as a double + */ + double operator()(T x) {return m_c * x;} + + //! Internal storred value of the constant + T m_c; }; @@ -572,44 +593,74 @@ namespace Cantera { //#endif } + + //! Templated evaluation of a polynomial of order 6 + /*! + * @param x Value of the independent variable - First template parameter + * @param c Pointer to the polynomial - Second template parameter + */ + template + R poly6(D x, R* c) { + return ((((((c[6]*x + c[5])*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + //! Templated evaluation of a polynomial of order 8 + /*! + * @param x Value of the independent variable - First template parameter + * @param c Pointer to the polynomial - Second template parameter + */ + template + R poly8(D x, R* c) { + return ((((((((c[8]*x + c[7])*x + c[6])*x + c[5])*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + //! Templated evaluation of a polynomial of order 10 + /*! + * @param x Value of the independent variable - First template parameter + * @param c Pointer to the polynomial - Second template parameter + */ + template + R poly10(D x, R* c) { + return ((((((((((c[10]*x + c[9])*x + c[8])*x + c[7])*x + + c[6])*x + c[5])*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + //! Templated evaluation of a polynomial of order 5 + /*! + * @param x Value of the independent variable - First template parameter + * @param c Pointer to the polynomial - Second template parameter + */ + template + R poly5(D x, R* c) { + return (((((c[5]*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + //! Templated evaluation of a polynomial of order 4 + /*! + * @param x Value of the independent variable - First template parameter + * @param c Pointer to the polynomial - Second template parameter + */ + template + R poly4(D x, R* c) { + return ((((c[4]*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + //! Templated evaluation of a polynomial of order 3 + /*! + * @param x Value of the independent variable - First template parameter + * @param c Pointer to the polynomial - Second template parameter + */ + template + R poly3(D x, R* c) { + return (((c[3]*x + c[2])*x + c[1])*x + c[0]); + } + //@} - - template - R poly6(D x, R* c) { - return ((((((c[6]*x + c[5])*x + c[4])*x + c[3])*x + - c[2])*x + c[1])*x + c[0]); - } - - template - R poly8(D x, R* c) { - return ((((((((c[8]*x + c[7])*x + c[6])*x + c[5])*x + c[4])*x + c[3])*x + - c[2])*x + c[1])*x + c[0]); - } - - template - R poly10(D x, R* c) { - return ((((((((((c[10]*x + c[9])*x + c[8])*x + c[7])*x - + c[6])*x + c[5])*x + c[4])*x + c[3])*x - + c[2])*x + c[1])*x + c[0]); - } - - template - R poly5(D x, R* c) { - return (((((c[5]*x + c[4])*x + c[3])*x + - c[2])*x + c[1])*x + c[0]); - } - - template - R poly4(D x, R* c) { - return ((((c[4]*x + c[3])*x + - c[2])*x + c[1])*x + c[0]); - } - - template - R poly3(D x, R* c) { - return (((c[3]*x + c[2])*x + c[1])*x + c[0]); - } - }