1 #ifndef MATH_Variable_H
2 #define MATH_Variable_H
65 static inline SP::MATH_Variable
New() {
72 static inline SP::MATH_Variable
New(
const int& cap) {
82 inline const double&
operator[](
const int& index)
const {
84 return mValues[index];
90 return mValues[index];
105 mValues=&mAllValues[0];
119 if (mFirstIndex+mSize>=mCapacity)
setSize(mSize);
121 mValues=&mAllValues[index];
126 if (mFirstIndex+mSize>=mCapacity)
setSize(mSize);
128 mValues=&mAllValues[index];
132 inline void setValue(
const int& index,
const double& v) {
148 inline void setValue(
const double* v,
const int& n) {
151 for (
int i=0;i<n;i++) mValues[i]=v[i];
155 inline void setValue(
const long double* v,
const int& n) {
158 for (
int i=0;i<n;i++) mValues[i]=(
double)v[i];
165 mValues[0]=(double)v;
172 for (
int i=0;i<n;i++) mValues[i]=(
double) v[i];
179 mValues[0]=((int)v)%2;
191 for (
int i=0;i<n;i++) v[i]=mValues[i];
197 for (
int i=0;i<n;i++) v[i]=(
int)mValues[i];
201 inline void getValue(
const int& index,
int& v)
const {
208 inline void getValue(
const int& index,
double& v)
const {
226 for (
int i=0;i<mSize;i++) {
227 v[i]=(char) mValues[i];
263 return ((type==REAL)||(type==INTEGER)|| (type==BOOLEAN));
273 return (mType==BOOLEAN);
278 return (mType==INTEGER);
283 return (mType==REAL);
288 return (mType==STRING);
303 return (
int) (round(v));
DEFINE_SVPTR(MATH_Variable)
void setValue(const double *v, const int &n)
set the value
Definition: MATH_Variable.h:148
void getValue(int &v) const
get value
Definition: MATH_Variable.h:219
tBoolean isEqual(const MATH_Variable &var, const tReal &eps) const
return true if the variable are equal
Definition: MATH_Variable.cpp:108
tBoolean isEqual(const MATH_Variable &var) const
return true if the variable are equal
Definition: MATH_Variable.h:296
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
static const tFlag REAL
Definition: MATH_Variable.h:26
static int toInteger(const double &v)
to int
Definition: MATH_Variable.h:302
static SP::MATH_Variable New()
create a node expression
Definition: MATH_Variable.h:65
void setValue(const double &v)
set the value
Definition: MATH_Variable.h:141
tBoolean isString() const
retrun true if the type is string
Definition: MATH_Variable.h:287
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
virtual void copy(const MATH_Variable &v)
copy the variable
Definition: MATH_Variable.cpp:28
tBoolean isReal() const
retrun true if the type is real
Definition: MATH_Variable.h:282
tBoolean isBoolean() const
retrun true if the type is boolean
Definition: MATH_Variable.h:272
void setValue(const long double *v, const int &n)
set the value
Definition: MATH_Variable.h:155
MATH_Variable(const int &cap)
create
Definition: MATH_Variable.cpp:15
#define tBoolean
Definition: types.h:35
double & operator[](const int &index)
operator get for writing
Definition: MATH_Variable.h:88
int getFirstIndex() const
get the first index
Definition: MATH_Variable.h:243
void clear()
clear the variable
Definition: MATH_Variable.h:102
void setType(const tFlag &type)
set the type
Definition: MATH_Variable.h:183
static tBoolean toBoolean(const double &v)
to boolean
Definition: MATH_Variable.h:307
static SP::MATH_Variable New(const int &cap)
create a node expression
Definition: MATH_Variable.h:72
void setValue(const int &v)
set the value
Definition: MATH_Variable.h:162
void getValue(const int &index, int &v) const
get value
Definition: MATH_Variable.h:201
static tBoolean isNumericalType(const tFlag &type)
retrun true if the type is numerical
Definition: MATH_Variable.h:262
static const tFlag BOOLEAN
Definition: MATH_Variable.h:27
void setValue(const int *v, const int &n)
set the value
Definition: MATH_Variable.h:169
void getValue(double &v) const
get value
Definition: MATH_Variable.h:214
int getSize() const
get the size
Definition: MATH_Variable.h:237
virtual tString toString() const
print the environment class in a string
Definition: MATH_Variable.cpp:123
void getValue(int *v, int &n) const
get value: n is the real size of v the max size is the value of n at INPUT
Definition: MATH_Variable.h:195
tBoolean isNumericalType() const
retrun true if the type is numerical
Definition: MATH_Variable.h:267
void getValue(const int &index, double &v) const
get value
Definition: MATH_Variable.h:208
static const tFlag BOUND_SIZE[]
Definition: MATH_Variable.h:22
virtual ~MATH_Variable(void)
destroy
Definition: MATH_Variable.cpp:24
int getStartIndex() const
get the first index
Definition: MATH_Variable.h:248
void setStartIndex(const int &index)
set the start index
Definition: MATH_Variable.h:125
abstract base class for most classes.
Definition: CORE_Object.h:30
const double & operator[](const int &index) const
operator get for reading
Definition: MATH_Variable.h:82
void getValue(tString &v) const
get value
Definition: MATH_Variable.h:224
#define tString
Definition: types.h:36
static const tFlag STRING
Definition: MATH_Variable.h:29
DEFINE_SPTR(MATH_Variable)
void setFirstIndex(const int &index)
set the first index
Definition: MATH_Variable.h:118
void setValue(const int &index, const double &v)
set the value
Definition: MATH_Variable.h:132
void getValue(double *v, int &n) const
get value : n is the real size of v the max size is the value of n at INPUT
Definition: MATH_Variable.h:189
int getCapacity() const
return the capacity of the variable
Definition: MATH_Variable.h:254
static const tFlag BOUND_POINT[]
Definition: MATH_Variable.h:21
tFlag getType() const
get the type
Definition: MATH_Variable.h:232
tBoolean isInteger() const
retrun true if the type is integer
Definition: MATH_Variable.h:277
static const tFlag INTEGER
Definition: MATH_Variable.h:28
#define tReal
Definition: types.h:18
#define ASSERT_IN(a)
Definition: types.h:82
void setValue(const tBoolean &v)
set the value
Definition: MATH_Variable.h:176
static const tFlag UNDEFINED
Definition: MATH_Variable.h:25
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14