C++ main module for gpm Package  1.0
MATH_GTOperator.h
Go to the documentation of this file.
1 #ifndef MATH_GTOperator_H
2 #define MATH_GTOperator_H
3 
4 #include "MATH_BinaryOperator.h"
5 
6 #include "MATH_Variable.h"
7 
19  SP_OBJECT(MATH_GTOperator);
20 
21  // ATTRIBUTES
22 
23 
24 protected:
25  // METHODS
26 
27  // CONSTRUCTORS
28 
32  setName(">");
33  setPriority(0);
34  }
35 
36 
37 
38  // DESTRUCTORS
39 
40 
43  virtual ~MATH_GTOperator(void) {
44  }
45 
46 
47 private:
48 
49 public:
52  static inline SP::MATH_GTOperator New() {
53  SP::MATH_GTOperator p(new MATH_GTOperator(),MATH_GTOperator::Delete());
54  p->setThis(p);
55  return p;
56  }
57 
60  virtual SP::MATH_NodeExpression newInstance() const {
61  return New();
62  }
63 
64 
65  // SET methods
66 
67 
68  // GET methods
69 
70 public:
71  // OTHERS methods
72  // OTHERS methods
93  virtual int evaluate(const tFlag& action,MATH_Environment& symbols,MATH_Variable& var) const {
94  SPC::MATH_ChildExpression arg1=getArgument(0);
95  SPC::MATH_ChildExpression arg2=getArgument(1);
96  if ((arg1.get()==null) || (arg2.get()==null)) return NULL_OPERAND;
97  int retCode=0;
98 
99  //tFlag type1;
100 
101 
102  int i1=var.getStartIndex();
103  if (arg1.get()!=null) retCode=arg1->evaluate(ALGEBRIC,symbols,var);
104  //type1=var.getType();
105 
106  int i2=var.getSize();
107  var.setFirstIndex(i1+i2);
108  if (arg2.get()!=null) retCode=arg2->evaluate(ALGEBRIC,symbols,var);
109  int n=var.getSize();
110  var.setFirstIndex(i1);
111  double *var1=&var[0];//size i2
112  const double *var2=&var[i2];//size n
113 
114  //m=min(i2,n)
115  int i,m=(i2<n)?i2:n;
116  tBoolean ok=true;
117  for (i=0;i<m;i++) {
118  if (var1[i]>var2[i]) {
119  ok=true;
120  break;
121  } else if (var1[i]<var[i]) {
122  ok=false;
123  break;
124  }
125  }
126  if ((i==m) && (i2<=n)) ok=false;
127  var1[0]=ok;
128  var.setSize(1);
129 
130 
132 
133  return retCode;
134  }
135 
136 };
137 
138 #endif
virtual ~MATH_GTOperator(void)
destroy
Definition: MATH_GTOperator.h:43
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
tBoolean setSize(const int &n)
set the size of the variable be careful of the used of operator[] : the values may be reallocated whi...
Definition: MATH_Variable.cpp:37
SPC::MATH_ChildExpression getArgument(const int &i) const
get argument at index i for reading
Definition: MATH_ParentExpression.h:124
virtual SP::MATH_NodeExpression newInstance() const
create a node expression
Definition: MATH_GTOperator.h:60
#define tBoolean
Definition: types.h:35
virtual int evaluate(const tFlag &action, MATH_Environment &symbols, MATH_Variable &var) const
void evaluate the expression
Definition: MATH_GTOperator.h:93
This class describes an > operator.
Definition: MATH_GTOperator.h:18
DEFINE_SPTR(MATH_GTOperator)
#define null
Definition: types.h:13
void setPriority(const int &p)
set the priority of the operator
Definition: MATH_BinaryOperator.h:49
void setType(const tFlag &type)
set the type
Definition: MATH_Variable.h:183
static const tFlag BOOLEAN
Definition: MATH_Variable.h:27
static SP::MATH_GTOperator New()
create a node expression
Definition: MATH_GTOperator.h:52
int getSize() const
get the size
Definition: MATH_Variable.h:237
This class decribes a binary operator.
Definition: MATH_BinaryOperator.h:15
int getStartIndex() const
get the first index
Definition: MATH_Variable.h:248
MATH_GTOperator(void)
create
Definition: MATH_GTOperator.h:31
void setFirstIndex(const int &index)
set the first index
Definition: MATH_Variable.h:118
This class decribes an environment class.
Definition: MATH_Environment.h:14
void setName(const tString &n)
set the operator name
Definition: MATH_Operator.h:45
static const int NULL_OPERAND
Definition: MATH_Expression.h:46
static const tFlag ALGEBRIC
Definition: MATH_Expression.h:31
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14