C++ main module for emicrom Package  1.0
MATH_ArrayVector.h
Go to the documentation of this file.
1 #ifndef MATH_ArrayVector_H
2 #define MATH_ArrayVector_H
3 
4 #include "MATH_Vector.h"
5 
6 #include "CORE_Array.h"
7 
8 
16 
17 class MATH_ArrayVector : public MATH_Vector {
19 
20 private:
21 
23 
24 public:
28 
29  }
30 
31 
32 
33  // DESTRUCTORS
34 
35 
38  virtual ~MATH_ArrayVector(void) {
39  }
40 
41 public:
45  inline static SP::MATH_ArrayVector New() {
46  SP::MATH_ArrayVector p(new MATH_ArrayVector(),MATH_ArrayVector::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_ArrayVector& operator=(const tReal& v) {
72  init(v);
73  return *this;
74  }
79  add(v);
80  return *this;
81  }
82 
86  inline MATH_ArrayVector& operator*=(const tReal& v) {
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  }
104 
105 
106 
107 
108  //SET Methods
109  //===========
110  /* \brief copy method
111  * @param c: vector to copy
112  */
113  virtual void copy(const MATH_Vector& v) {
114  const MATH_ArrayVector* av=dynamic_cast<const MATH_ArrayVector* >(&v);
115  if (av!=null) {
116  mArray.copy(av->getArray());
117 
118  }
120  }
121 
125  virtual void setSize(const tUIndex& n) {
126  mArray.setSize(n);
127  }
131  virtual void setCapacity(const tUIndex& n) {
132  mArray.setSize(n);
133  }
134 
139  virtual void setValuesByReference(const tUIndex& n,tReal *Vs ) {
140  mArray.setValuesByReference(n,Vs);
141  }
146  virtual void setValues(const tUIndex& n,tReal *Vs ) {
147  mArray.setValues(n,Vs);
148  }
149 
150  //GET Methods
151  //===========
160  virtual tULLInt getMemorySize() const {
161  return mArray.getMemorySize()+MATH_Vector::getMemorySize();
162  }
166  inline const CORE_RealArray& getArray() const {
167  return mArray;
168  }
173  return mArray;
174  }
175 
179  virtual const tReal* getValues() const {
180  return &mArray[0];
181  }
185  virtual tReal* getValues() {
186  return &mArray[0];
187  }
188 
191  virtual tUIndex getSize() const {
192  return mArray.getSize();
193  }
196  virtual tUIndex getCapacity() const {
197  return mArray.getSize();
198  }
199 
200 
201  //to string
205  virtual tString toString() const {
206  return "size:"+CORE_Integer::toString(mArray.getSize())+":"+mArray.toString();
207  }
208 
209 
210 
211 
212 
213 
214 };
215 #endif
const tUIndex & getSize() const
return the size of the array for reading
Definition: CORE_Array.h:1018
virtual const tReal & operator[](const tUIndex &i) const
return the values for element at i
Definition: MATH_ArrayVector.h:101
MATH_ArrayVector & operator=(const MATH_Vector &v)
copy operator
Definition: MATH_ArrayVector.h:64
virtual ~MATH_ArrayVector(void)
destroy a vector
Definition: MATH_ArrayVector.h:38
virtual void setCapacity(const tUIndex &n)
set the size of the vector
Definition: MATH_ArrayVector.h:131
virtual tReal * getValues()
get the values as contigous pointers
Definition: MATH_ArrayVector.h:185
virtual tString toString() const
turn the array into string
Definition: CORE_Array.hpp:301
MATH_ArrayVector & operator=(const tReal &v)
init operator
Definition: MATH_ArrayVector.h:71
virtual void copy(const MATH_Vector &v)
Definition: MATH_ArrayVector.h:113
virtual tUIndex getCapacity() const
get the size of the vector
Definition: MATH_ArrayVector.h:196
void setSize(const tUIndex &n)
set the size
Definition: CORE_Array.h:292
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
#define null
Definition: types.h:144
virtual SP::MATH_Vector NewInstance() const
return a share pointer to a new instance of this
Definition: MATH_ArrayVector.h:53
virtual void copy(const MATH_Vector &v)
Definition: MATH_Vector.h:77
tBoolean setValuesByReference(const tUIndex &n, Q *array)
set the the values by reference
Definition: CORE_Array.h:405
virtual void setValuesByReference(const tUIndex &n, tReal *Vs)
set values by reference
Definition: MATH_ArrayVector.h:139
virtual void init(const tReal &alpha)
init the value to alpha
Definition: MATH_Vector.cpp:12
virtual void setSize(const tUIndex &n)
set the size of the vector
Definition: MATH_ArrayVector.h:125
MATH_ArrayVector & operator+=(const MATH_Vector &v)
add operator
Definition: MATH_ArrayVector.h:78
virtual tReal dot(const MATH_Vector &x) const
s=x^t.T where T is this
Definition: MATH_Vector.cpp:480
virtual tString toString() const
return the string representation of the object
Definition: MATH_ArrayVector.h:205
CORE_RealArray & getArray()
get the array for writing
Definition: MATH_ArrayVector.h:172
This class describes a masked vector.
Definition: MATH_Vector.h:16
CORE_RealArray mArray
Definition: MATH_ArrayVector.h:22
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: CORE_Array.h:545
void setValues(const tUIndex &n, const Q *v)
set the values of the array by copying the n first values of pointer v
Definition: CORE_Array.h:445
This class impements the MATH_Vector class thanks to CORE_RealArray data.
Definition: MATH_ArrayVector.h:17
#define tUIndex
Definition: types.h:126
virtual void add(const MATH_Vector &y)
T+=y.
Definition: MATH_Vector.cpp:238
virtual tReal & operator[](const tUIndex &i)
return the values for element at i
Definition: MATH_ArrayVector.h:94
static SP::MATH_ArrayVector New()
return a share pointer of a vector based on CORE_RealArray
Definition: MATH_ArrayVector.h:45
#define tString
Definition: types.h:135
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: MATH_Vector.h:125
virtual tUIndex getSize() const
get the size of the vector
Definition: MATH_ArrayVector.h:191
MATH_ArrayVector & operator*=(const tReal &v)
do operator
Definition: MATH_ArrayVector.h:86
MATH_ArrayVector(void)
create a vector
Definition: MATH_ArrayVector.h:27
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: MATH_ArrayVector.h:160
DEFINE_SPTR(MATH_ArrayVector)
SP_OBJECT(MATH_ArrayVector)
#define tULLInt
Definition: types.h:45
virtual void setValues(const tUIndex &n, tReal *Vs)
set values by reference
Definition: MATH_ArrayVector.h:146
#define tReal
Definition: types.h:118
const CORE_RealArray & getArray() const
get the array for reading
Definition: MATH_ArrayVector.h:166
virtual const tReal * getValues() const
get the values as contigous pointers
Definition: MATH_ArrayVector.h:179
void copy(const CORE_Array< Q > &f)
copy the array
Definition: CORE_Array.hpp:16
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141