Changeset 2598 in Sophya for trunk/SophyaLib/SysTools/cexpre.cc
- Timestamp:
- Aug 11, 2004, 3:10:25 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/cexpre.cc
r2593 r2598 68 68 //--------------------------------------------------------- 69 69 //----------- Expression changement de signe ------------- 70 /*! 71 \internal 72 \ingroup SysTools 73 \brief Class for handling change sign expression (-x) 74 \sa CExpressionEvaluator 75 */ 70 76 class CE_ChsExp : public CExprBase { 71 77 public: … … 80 86 81 87 //--------------------------------------------------------- 88 /*! 89 \internal 90 \ingroup SysTools 91 \brief Base class for binary operations on expressions 92 \sa CExpressionEvaluator 93 */ 82 94 class CE_BinExp : public CExprBase { 83 95 public: … … 119 131 120 132 //--------------------------------------------------------- 133 /*! 134 \internal 135 \ingroup SysTools 136 \brief Addition of two CExprBase (binary operation : x+y) 137 \sa CExpressionEvaluator 138 */ 121 139 class CE_AddExp : public CE_BinExp { 122 140 public: … … 125 143 } 126 144 }; 145 /*! 146 \internal 147 \ingroup SysTools 148 \brief Multiplication of two CExprBase (binary operation : x*y) 149 \sa CExpressionEvaluator 150 */ 127 151 class CE_MulExp : public CE_BinExp { 128 152 public: … … 130 154 virtual double Evaluate() const { CheckThrow("CE_MulExp::Evaluate"); return _e1->Evaluate()*_e2->Evaluate(); } 131 155 }; 156 /*! 157 \internal 158 \ingroup SysTools 159 \brief Subtraction of two CExprBase (binary operation : x-y) 160 \sa CExpressionEvaluator 161 */ 132 162 class CE_SubExp : public CE_BinExp { 133 163 public: … … 135 165 virtual double Evaluate() const { CheckThrow("CE_SubExp::Evaluate"); return _e1->Evaluate()-_e2->Evaluate(); } 136 166 }; 167 /*! 168 \internal 169 \ingroup SysTools 170 \brief Division of two CExprBase (binary operation : x/y) 171 \sa CExpressionEvaluator 172 */ 137 173 class CE_DivExp : public CE_BinExp { 138 174 public: … … 149 185 //--------------------------------------------------------- 150 186 #define FMXARG 3 187 /*! 188 \internal 189 \ingroup SysTools 190 \brief Function evaluation on other expression in the form f(), f(x), f(x,y), f(x,y,z) 191 \sa CExpressionEvaluator 192 */ 151 193 class CE_FuncExp : public CExprBase { 152 194 public: … … 169 211 170 212 // Les fonctions de generation de nombre aleatoire 171 double _CE_rand01() { return drand01(); }172 double _CE_randpm1() { return drandpm1(); }173 double _CE_gaurand() { return GauRnd(0., 1.); }213 static double _CE_rand01() { return drand01(); } 214 static double _CE_randpm1() { return drandpm1(); } 215 static double _CE_gaurand() { return GauRnd(0., 1.); } 174 216 //--------------------------------------------------------- 175 217 CE_FuncExp::CE_FuncExp(string const & func) … … 265 307 266 308 //--------------------------------------------------------- 309 /*! 310 \class CExpressionEvaluator 311 \ingroup SysTools 312 \brief Class for evaluation of arithmetic expressions with C-like syntax. 313 314 This classes can handle the parsing of c-like arithmetic 315 expressions containing numerical constants, the four 316 basic operations (addition +, subtraction -, multiplication *, 317 division /) and functions. 318 The numerical constants are also defined <tt> (Pi = M_PI E = M_E) </tt>. 319 The following functions from the standard math library and 320 random generators are available: 321 322 - sqrt fabs floor hypot 323 - exp log log10 pow 324 - sin cos tan asin acos atan atan2 325 - sinh cosh tanh 326 - rand01() : Flat random number generator in the range [0 1] 327 - randpm1() : Flat random number generator in the range [-1 1] 328 - gaurand() : Gaussian random number generator (m=0, sigma=1) 329 330 Usage example : 331 \code 332 #include "cexpre.h" 333 ... 334 string es = "4.+3*(cos(Pi/8.)+1.5)"; 335 CExpressionEvaluator e(es); 336 cout << " Expression: " << e << " = " << e.Evaluate() << endl; 337 \endcode 338 339 Output : \n 340 <tt> Expression: (4+(3*(cos((3.14159/8))+1.5))) = 11.2716 </tt> 341 */ 342 343 /*! 344 Parse the string \c sex and builds an expression. 345 Can throw CExprException exception. 346 */ 267 347 CExpressionEvaluator::CExpressionEvaluator(string const & sex) 268 348 { … … 293 373 294 374 // cette fonction rearrange le stack des operations binaires en attente 295 CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex, CE_BinExp* nbx)375 static CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex, CE_BinExp* nbx) 296 376 { 297 377 while ( !sbx.empty() && (nbx->Priority() <= sbx.top()->Priority()) ) { … … 305 385 306 386 // cette fonction rearrange le stack des operations binaires en attente 307 CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex)387 static CExprBase* Arrange_CE_BinExpStack(stack<CE_BinExp* >& sbx, CExprBase* cex) 308 388 { 309 389 if (sbx.empty()) return cex;
Note:
See TracChangeset
for help on using the changeset viewer.