Changeset 2598 in Sophya for trunk/SophyaLib/SysTools/rpneval.cc


Ignore:
Timestamp:
Aug 11, 2004, 3:10:25 PM (21 years ago)
Author:
ansari
Message:

Documentation (ajoutee ou completee) pour les classes du module SysTools - Reza 11 Aout 2004

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/rpneval.cc

    r2596 r2598  
    1010
    1111/*!
    12   \class SOPHYA::RPNExpressionEvaluator
     12  \class RPNExpressionEvaluator
    1313  \ingroup SysTools
    1414  Arithmetic expression (double precision float) evaluator
    1515  in Reverse Polish Notation (RPN). This is an HP calculator
    1616  like syntax. Space are used for separating the string
    17   expression into tokens.
     17  expression into tokens. \n
     18  The string parsed by RPNExpressionEvaluator should be
     19  formed by a set of space separated words. Each word may be
     20  a numerical constant or operation or function.
     21  All numeriacl constants are pushed to stack top.
     22  The stack is limited only
     23  by the available memory. The three numbers on the stack top
     24  are referred to as <tt> x y x </tt>. \n
     25  Available operations:
     26  - op= + - * / % : replace (x,y) by x.op.y
     27  - e pi : M_PI , M_E numerical constants
     28  - f= sin cos tan asin acos atan : replace x by f(x)
     29  - f= chs sqrt sq : (x<-f(x)) change-sign , square root and square (x<-x^2) operations
     30  - f= log log10 exp : replace x by f(x)
     31  - f= fabs floor ceiling : replace x by f(x)
     32  - f= deg2rad rad2deg : replace x by f(x)
     33  - f= rand01 randpm1 gaurand : pushes a random number on the stack top ([0 1] [-1 1] Gaussian)
     34  - print x<>y pop push : stack operations
     35  - sum product : Replace the complete stack by the sum / product of the numbers in the stack
     36  - mean sigma : Replace the complete stack by the mean / sigma of the numbers in the stack
     37
     38  \sa CExpressionEvaluator Commander
     39
     40  The following output is produced by the sample code below:
     41  \code
     42  #include "rpneval.h"
     43  ...
     44  RPNExpressionEvaluator rpn1("4 2 print + 3 * ");
     45  cout << "RPN1: 4 2 + 3 * -> rpn1.Value() = " << rpn1.Value() << endl; 
     46  RPNExpressionEvaluator rpn2("1 2 3 4 5 sum");
     47  cout << "RPN2: 1 2 3 4 5 sum -> rpn2.Value() = " << rpn2.Value() << endl;
     48  \endcode
     49
     50  Output:
     51  \verbatim
     52  RPNExpressionEvaluator::PrintStack() Size()= 2
     53      0:  2   (x)
     54      1:  4   (y)
     55  RPN1: 4 2 + 3 * -> rpn1.Value() = 18
     56  RPN2: 1 2 3 4 5 sum -> rpn2.Value() = 15 
     57  \endverbatim
    1858*/
    1959
     60/*!
     61  \brief Parses the string \b sex into words and perform the specified operations on the stack.
     62
     63  Can throw  RPNExprException
     64*/
    2065RPNExpressionEvaluator::RPNExpressionEvaluator(string const & sex)
    2166{
     
    3378}
    3479
     80/*!
     81  \brief Perform the operations specified by \b on the stack, starting from element \b exe[off]. 
     82
     83  Can throw  RPNExprException
     84*/
    3585RPNExpressionEvaluator::RPNExpressionEvaluator(vector<string> & exe, int off)
    3686{
     
    52102/* Operations sur le stack RPN */
    53103/* --Methode-- */
     104//! Return the stack top (x)
    54105double RPNExpressionEvaluator::Evaluate() const
    55106{
Note: See TracChangeset for help on using the changeset viewer.