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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/include/CLHEP/Evaluator/Evaluator.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Evaluator/Evaluator.h (Version 6.2.p1)


  1 // -*- C++ -*-                                      1 
  2 // -------------------------------------------    
  3                                                   
  4 #ifndef HEP_EVALUATOR_H                           
  5 #define HEP_EVALUATOR_H                           
  6                                                   
  7 #include <string>                                 
  8                                                   
  9 namespace HepTool {                               
 10                                                   
 11 /**                                               
 12  * Evaluator of arithmetic expressions with an    
 13  * Example:                                       
 14  * @code                                          
 15  *   #include "CLHEP/Evaluator/Evaluator.h"       
 16  *   HepTool::Evaluator eval;                     
 17  *   eval.setStdMath();                           
 18  *   double res = eval.evaluate("sin(30*degree    
 19  *   if (eval.status() != HepTool::Evaluator::    
 20  * @endcode                                       
 21  *                                                
 22  * @author Evgeni Chernyaev <Evgueni.Tcherniae    
 23  * @ingroup evaluator                             
 24  */                                               
 25 class Evaluator {                                 
 26  public:                                          
 27                                                   
 28   /**                                             
 29    * List of possible statuses.                   
 30    * Status of the last operation can be obtai    
 31    * In case if status() is an ERROR the corre    
 32    * can be printed with print_error().           
 33    *                                              
 34    * @see status                                  
 35    * @see error_position                          
 36    * @see print_error                             
 37    */                                             
 38   enum {                                          
 39     OK,                         /**< Everythin    
 40     WARNING_EXISTING_VARIABLE,  /**< Redefinit    
 41     WARNING_EXISTING_FUNCTION,  /**< Redefinit    
 42     WARNING_BLANK_STRING,       /**< Empty inp    
 43     ERROR_NOT_A_NAME,           /**< Not allow    
 44     ERROR_SYNTAX_ERROR,         /**< Systax er    
 45     ERROR_UNPAIRED_PARENTHESIS, /**< Unpaired     
 46     ERROR_UNEXPECTED_SYMBOL,    /**< Unexpecte    
 47     ERROR_UNKNOWN_VARIABLE,     /**< Non-exist    
 48     ERROR_UNKNOWN_FUNCTION,     /**< Non-exist    
 49     ERROR_EMPTY_PARAMETER,      /**< Function     
 50     ERROR_CALCULATION_ERROR     /**< Error dur    
 51   };                                              
 52                                                   
 53   /**                                             
 54    * Constructor.                                 
 55    */                                             
 56   Evaluator();                                    
 57                                                   
 58   /**                                             
 59    * Destructor.                                  
 60    */                                             
 61   ~Evaluator();                                   
 62                                                   
 63   /**                                             
 64    * Evaluates the arithmetic expression given    
 65    * The expression may consist of numbers, va    
 66    * separated by arithmetic (+, - , /, *, ^,     
 67    * operators (==, !=, >, >=, <, <=, &&, ||).    
 68    *                                              
 69    * @param  expression input expression.         
 70    * @return result of the evaluation.            
 71    * @see status                                  
 72    * @see error_position                          
 73    * @see print_error                             
 74    */                                             
 75   double evaluate(const char * expression);       
 76                                                   
 77   /**                                             
 78    * Returns status of the last operation with    
 79    */                                             
 80   int status() const;                             
 81                                                   
 82   /**                                             
 83    * Returns position in the input string wher    
 84    */                                             
 85   int error_position() const;                     
 86                                                   
 87   /**                                             
 88    * Prints error message if status() is an ER    
 89    */                                             
 90   void print_error() const;                       
 91   /**                                             
 92    * get a string defining the error name         
 93    */                                             
 94   std::string error_name() const;                 
 95                                                   
 96   /**                                             
 97    * Adds to the dictionary a variable with gi    
 98    * If a variable with such a name already ex    
 99    * then status will be set to WARNING_EXISTI    
100    *                                              
101    * @param name name of the variable.            
102    * @param value value assigned to the variab    
103    */                                             
104   void setVariable(const char * name, double v    
105                                                   
106   /**                                             
107    * Adds to the dictionary a variable with an    
108    * assigned to it.                              
109    * If a variable with such a name already ex    
110    * then status will be set to WARNING_EXISTI    
111    *                                              
112    * @param name name of the variable.            
113    * @param expression arithmetic expression.     
114    */                                             
115   void setVariable(const char * name, const ch    
116                                                   
117   /**                                             
118    * Adds to the dictionary a function without    
119    * If such a function already exist in the d    
120    * then status will be set to WARNING_EXISTI    
121    *                                              
122    * @param name function name.                   
123    * @param fun pointer to the real function i    
124    */                                             
125   void setFunction(const char * name, double (    
126                                                   
127   /**                                             
128    * Adds to the dictionary a function with on    
129    * If such a function already exist in the d    
130    * then status will be set to WARNING_EXISTI    
131    *                                              
132    * @param name function name.                   
133    * @param fun pointer to the real function i    
134    */                                             
135   void setFunction(const char * name, double (    
136                                                   
137   /**                                             
138    * Adds to the dictionary a function with tw    
139    * If such a function already exist in the d    
140    * then status will be set to WARNING_EXISTI    
141    *                                              
142    * @param name function name.                   
143    * @param fun pointer to the real function i    
144    */                                             
145   void setFunction(const char * name, double (    
146                                                   
147   /**                                             
148    * Adds to the dictionary a function with th    
149    * If such a function already exist in the d    
150    * then status will be set to WARNING_EXISTI    
151    *                                              
152    * @param name function name.                   
153    * @param fun pointer to the real function i    
154    */                                             
155   void setFunction(const char * name, double (    
156                                                   
157   /**                                             
158    * Adds to the dictionary a function with fo    
159    * If such a function already exist in the d    
160    * then status will be set to WARNING_EXISTI    
161    *                                              
162    * @param name function name.                   
163    * @param fun pointer to the real function i    
164    */                                             
165   void setFunction(const char * name,             
166        double (*fun)(double,double,double,doub    
167                                                   
168   /**                                             
169    * Adds to the dictionary a function with fi    
170    * If such a function already exist in the d    
171    * then status will be set to WARNING_EXISTI    
172    *                                              
173    * @param name function name.                   
174    * @param fun pointer to the real function i    
175    */                                             
176   void setFunction(const char * name,             
177                    double (*fun)(double,double    
178                                                   
179   /**                                             
180    * Finds the variable in the dictionary.        
181    *                                              
182    * @param  name name of the variable.           
183    * @return true if such a variable exists, f    
184    */                                             
185   bool findVariable(const char * name) const;     
186                                                   
187   /**                                             
188    * Finds the function in the dictionary.        
189    *                                              
190    * @param  name name of the function to be u    
191    * @param  npar number of parameters of the     
192    * @return true if such a function exists, f    
193    */                                             
194   bool findFunction(const char * name, int npa    
195                                                   
196   /**                                             
197    * Removes the variable from the dictionary.    
198    *                                              
199    * @param name name of the variable.            
200    */                                             
201   void removeVariable(const char * name);         
202                                                   
203   /**                                             
204    * Removes the function from the dictionary.    
205    *                                              
206    * @param name name of the function to be un    
207    * @param npar number of parameters of the f    
208    */                                             
209   void removeFunction(const char * name, int n    
210                                                   
211   /**                                             
212    * Clear all settings.                          
213    */                                             
214   void clear();                                   
215                                                   
216   /**                                             
217    * Sets standard mathematical functions and     
218    */                                             
219   void setStdMath();                              
220                                                   
221   /**                                             
222    * Sets system of units. Default is the SI s    
223    * To set the CGS (Centimeter-Gram-Second) s    
224    * one should call:                             
225    *   setSystemOfUnits(100., 1000., 1.0, 1.0,    
226    *                                              
227    * To set system of units accepted in the GE    
228    * one should call:                             
229    * @code                                        
230    *   setSystemOfUnits(1.e+3, 1./1.60217733e-    
231    *                    1.0, 1.0, 1.0);           
232    * @endcode                                     
233    *                                              
234    * The basic units in GEANT4 are:               
235    * @code                                        
236    *   millimeter              (millimeter = 1    
237    *   nanosecond              (nanosecond = 1    
238    *   Mega electron Volt      (MeV        = 1    
239    *   positron charge         (eplus      = 1    
240    *   degree Kelvin           (kelvin     = 1    
241    *   the amount of substance (mole       = 1    
242    *   luminous intensity      (candela    = 1    
243    *   radian                  (radian     = 1    
244    *   steradian               (steradian  = 1    
245    * @endcode                                     
246    */                                             
247   void setSystemOfUnits(double meter    = 1.0,    
248                         double kilogram = 1.0,    
249                         double second   = 1.0,    
250                         double ampere   = 1.0,    
251                         double kelvin   = 1.0,    
252                         double mole     = 1.0,    
253                         double candela  = 1.0)    
254                                                   
255 private:                                          
256   void * p;                                 //    
257   Evaluator(const Evaluator &);             //    
258   Evaluator & operator=(const Evaluator &); //    
259 };                                                
260                                                   
261 } // namespace HepTool                            
262                                                   
263 #endif /* HEP_EVALUATOR_H */                      
264