C++ main module for emicrom Package  1.0
MATH_MaskArrayVector.h
Go to the documentation of this file.
1 #ifndef MATH_MaskArrayVector_H
2 #define MATH_MaskArrayVector_H
3 
4 #include "MATH_MaskVector.h"
5 
6 #include "CORE_Array.h"
7 
8 
16 
19 
20 private:
21 
23 
24 protected:
28 
29  }
30 
31 
32 
33  // DESTRUCTORS
34 
35 
38  virtual ~MATH_MaskArrayVector(void) {
39  }
40 
41 public:
45  inline static SP::MATH_MaskArrayVector New() {
46  SP::MATH_MaskArrayVector p(new MATH_MaskArrayVector(),MATH_MaskArrayVector::Delete());
47  p->setThis(p);
48  return p;
49  }
53  virtual SP::MATH_Vector NewInstance() const {
54  return New();
55  }
56 
57 
58 
59  //operators
60  //==========
65  copy(v);
66  return *this;
67  }
71  inline MATH_MaskArrayVector& operator=(const tReal& v) {
72  init(v);
73  return *this;
74  }
79  add(v);
80  return *this;
81  }
82 
87  dot(v);
88  return *this;
89  }
90 
94  virtual tReal& operator[](const tUIndex& i) {
95  return mArray[i];
96 
97  }
101  virtual const tReal& operator[](const tUIndex& i) const {
102  return mArray[i];
103  }
107  virtual const tReal& operator()(const tUIndex& i) const {
108  return mArray[getStartIndex()+i*getIncrement()];
109 
110  }
114  virtual tReal& operator()(const tUIndex& i) {
115  return mArray[getStartIndex()+i*getIncrement()];
116 
117  }
118 
119 
120  //SET Methods
121  //===========
122  /* \brief copy method
123  * @param c: vector to copy
124  */
125  virtual void copy(const MATH_Vector& v) {
126  const MATH_MaskArrayVector* av=dynamic_cast<const MATH_MaskArrayVector* >(&v);
127  if (av!=null) {
128  mArray.copy(av->getArray());
129 
130  }
132  }
133 
137  virtual tUIndex getSize() const {
138  return mArray.getSize()/getIncrement();
139  }
140 
144  virtual void setSize(const tUIndex& n) {
145 
146  //set the size
147  mArray.setSize( n* getIncrement() );
148  }
152  virtual void setCapacity(const tUIndex& n) {
153  mArray.setSize(n);
154  }
155 
160  virtual void setValuesByReference(const tUIndex& n,tReal *Vs ) {
161  mArray.setValuesByReference(n,Vs);
162  }
163 
164  //GET Methods
165  //===========
174  virtual tULLInt getMemorySize() const {
175  return mArray.getMemorySize()+MATH_Vector::getMemorySize();
176  }
180  inline const CORE_RealArray& getArray() const {
181  return mArray;
182  }
187  return mArray;
188  }
189 
193  virtual const tReal* getValues() const {
194  return &mArray[0];
195  }
199  virtual tReal* getValues() {
200  return &mArray[0];
201  }
202 
203 
206  virtual tUIndex getCapacity() const {
207  return mArray.getSize();
208  }
209 
210 
211  //to string
215  virtual tString toString() const {
216  tString ret="full size:"+CORE_Integer::toString(mArray.getSize())+":"+mArray.toString()+"\n";
217  tUIndex i,n=getSize();
218  ret+="mask size:"+CORE_Integer::toString(n)+":";
219  ret+="[";
220  const tUSInt& inc=getIncrement();
221  const tReal *vs=&getValues()[getStartIndex()];
222  for (i=0;i<n;i++) {
223  ret+=CORE_Real::toString(*vs)+",";
224  vs+=inc;
225  }
226  ret+="]";
227  return ret;
228  }
229 
230 
231 
232 
233 
234 
235 };
236 #endif
const CORE_RealArray & getArray() const
get the array for reading
Definition: MATH_MaskArrayVector.h:180
virtual tReal & operator[](const tUIndex &i)
return the values for element at i
Definition: MATH_MaskArrayVector.h:94
const tUIndex & getSize() const
return the size of the array for reading
Definition: CORE_Array.h:1018
virtual tReal * getValues()
get the values as contigous pointers without taking into account the mask
Definition: MATH_MaskArrayVector.h:199
virtual tReal & operator()(const tUIndex &i)
return the value for element at i when mask is taken into account
Definition: MATH_MaskArrayVector.h:114
static SP::MATH_MaskArrayVector New()
return a share pointer of a vector based on CORE_RealArray
Definition: MATH_MaskArrayVector.h:45
virtual void copy(const MATH_Vector &v)
Definition: MATH_MaskVector.h:77
MATH_MaskArrayVector(void)
create a vector
Definition: MATH_MaskArrayVector.h:27
virtual void setSize(const tUIndex &n)
set the size of the vector to n*inc
Definition: MATH_MaskArrayVector.h:144
virtual tString toString() const
turn the array into string
Definition: CORE_Array.hpp:301
#define tUSInt
Definition: types.h:28
CORE_RealArray & getArray()
get the array for writing
Definition: MATH_MaskArrayVector.h:186
virtual const tReal * getValues() const
get the values as contigous pointers without taking into account the mask
Definition: MATH_MaskArrayVector.h:193
void setSize(const tUIndex &n)
set the size
Definition: CORE_Array.h:292
SP_OBJECT(MATH_MaskArrayVector)
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
Definition: MATH_MaskVector.h:16
#define null
Definition: types.h:144
virtual ~MATH_MaskArrayVector(void)
destroy a vector
Definition: MATH_MaskArrayVector.h:38
tBoolean setValuesByReference(const tUIndex &n, Q *array)
set the the values by reference
Definition: CORE_Array.h:405
virtual tUIndex getSize() const
get the size of the vector
Definition: MATH_MaskArrayVector.h:137
virtual tString toString() const
return the string representation of the object
Definition: MATH_MaskArrayVector.h:215
MATH_MaskArrayVector & operator+=(const MATH_Vector &v)
add operator
Definition: MATH_MaskArrayVector.h:78
This class impements the MATH_MaskVector class thanks to CORE_RealArray data.
Definition: MATH_MaskArrayVector.h:17
virtual void dot(const tReal &alpha)
T*=alpha.
Definition: MATH_MaskVector.cpp:156
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: MATH_MaskArrayVector.h:174
const tUIndex & getStartIndex() const
get the start index of the vector
Definition: MATH_MaskVector.h:125
This class describes a masked vector.
Definition: MATH_Vector.h:16
const tUSInt & getIncrement() const
get the increment of the vector
Definition: MATH_MaskVector.h:119
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: CORE_Array.h:545
virtual tUIndex getCapacity() const
get the size of the vector
Definition: MATH_MaskArrayVector.h:206
#define tUIndex
Definition: types.h:126
#define tString
Definition: types.h:135
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: MATH_Vector.h:125
MATH_MaskArrayVector & operator*=(const tReal &v)
do operator
Definition: MATH_MaskArrayVector.h:86
virtual const tReal & operator[](const tUIndex &i) const
return the values for element at i
Definition: MATH_MaskArrayVector.h:101
tString toString() const
return the string associated to the real
Definition: CORE_Real.h:97
MATH_MaskArrayVector & operator=(const MATH_Vector &v)
copy operator
Definition: MATH_MaskArrayVector.h:64
virtual void add(const MATH_Vector &y)
T+=y.
Definition: MATH_MaskVector.cpp:220
MATH_MaskArrayVector & operator=(const tReal &v)
init operator
Definition: MATH_MaskArrayVector.h:71
#define tULLInt
Definition: types.h:45
DEFINE_SPTR(MATH_MaskArrayVector)
virtual const tReal & operator()(const tUIndex &i) const
return the value for element at i when mask is taken into account
Definition: MATH_MaskArrayVector.h:107
CORE_RealArray mArray
Definition: MATH_MaskArrayVector.h:22
#define tReal
Definition: types.h:118
virtual void copy(const MATH_Vector &v)
Definition: MATH_MaskArrayVector.h:125
virtual void setValuesByReference(const tUIndex &n, tReal *Vs)
set values by reference with taking into account the mask
Definition: MATH_MaskArrayVector.h:160
virtual void init(const tReal &alpha)
init the values from getStartIndex() index with increment getIncrement() to alpha ...
Definition: MATH_MaskVector.cpp:10
void copy(const CORE_Array< Q > &f)
copy the array
Definition: CORE_Array.hpp:16
virtual void setCapacity(const tUIndex &n)
set the capacity of the vector to n
Definition: MATH_MaskArrayVector.h:152
virtual SP::MATH_Vector NewInstance() const
return a share pointer to a new instance of this
Definition: MATH_MaskArrayVector.h:53
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141