C++ main module for emicrom Package  1.0
MATH_Vector.h
Go to the documentation of this file.
1 #ifndef MATH_Vector_H
2 #define MATH_Vector_H
3 
4 #include "CORE_Object.h"
5 
6 
7 
15 
16 class MATH_Vector : public CORE_Object {
18 
19 
20 protected:
23  MATH_Vector(void) {
24 
25  }
26 
27 
28 
29  // DESTRUCTORS
30 
31 
34  virtual ~MATH_Vector(void) {
35  }
36 
37 public:
41  virtual SP::MATH_Vector NewInstance() const=0;
42 
43  //operators
44  //========
45 
46 
47 
51  virtual tReal& operator[](const tUIndex& i)=0;
52 
56  virtual const tReal& operator[](const tUIndex& i) const=0;
57 
61  virtual const tReal& operator()(const tUIndex& i) const {
62  return (*this)[i];
63 
64  }
68  virtual tReal& operator()(const tUIndex& i) {
69  return (*this)[i];
70 
71  }
72  //set methods
73  //===========
74  /* \brief copy method
75  * @param c: vector to copy
76  */
77  virtual void copy(const MATH_Vector& v) {
78  }
79 
80 
84  virtual void setCapacity(const tUIndex& n)=0;
88  virtual void setSize(const tUIndex& n)=0;
89 
93  virtual void init(const tReal& alpha);
94 
99  virtual void init(const tReal& alpha,const MATH_Vector& y);
100 
105  inline void setValue(const tUIndex& i,const tReal& v) {
106  getValues()[i]=v;
107  }
108 
113  virtual void setValuesByReference(const tUIndex& n,tReal *Vs )=0;
114 
115  //get methods
116  //============
125  virtual tULLInt getMemorySize() const {
126  return 0;
127  }
131  virtual const tReal* getValues() const=0;
132 
136  virtual tReal* getValues()=0;
137 
140  virtual tUIndex getSize() const=0;
141 
144  virtual tUIndex getCapacity() const=0;
145 
146 
147 
148 
149  //arithmetic operations
150  //========================
151 
152 
156  virtual void add(const MATH_Vector& y);
157 
162  virtual void divide(const MATH_Vector& x,MATH_Vector& y) const;
166  inline void divide(const MATH_Vector& x) {
167  divide(x,*this);
168  }
169 
174  virtual void add(const tReal& alpha,const MATH_Vector& y);
175 
176 
182  virtual void add(const tReal& beta,const MATH_Vector& x,const tReal& alpha);
183 
190  virtual void add(const tReal& beta,const MATH_Vector& x,const tReal& alpha,MATH_Vector& R);
191 
197  virtual void add(const tReal& beta,const MATH_Vector& x,MATH_Vector& R) {
198  add(beta,x,1,R);
199  }
200 
205  virtual tReal dot(const MATH_Vector& x) const;
206 
210  virtual void dot(const tReal& alpha);
211 
214  inline tReal norm2() const {
215  return dot(*this);
216  }
219  inline tReal norm() const {
220  return sqrt(dot(*this));
221  }
222 
223 
224 
225 
226 
227 };
228 #endif
virtual ~MATH_Vector(void)
destroy a vector
Definition: MATH_Vector.h:34
void divide(const MATH_Vector &x)
This/=x.
Definition: MATH_Vector.h:166
virtual const tReal * getValues() const =0
get the values as contigous pointers
virtual tUIndex getCapacity() const =0
get the capacity of the vector
virtual tReal & operator[](const tUIndex &i)=0
return the values for element at i
virtual void divide(const MATH_Vector &x, MATH_Vector &y) const
y=This/x
Definition: MATH_Vector.cpp:170
virtual SP::MATH_Vector NewInstance() const =0
return a share pointer to a new instance of this
tReal norm2() const
s=tT.T where T is this
Definition: MATH_Vector.h:214
virtual const tReal & operator()(const tUIndex &i) const
return the values for element at i by copiing element
Definition: MATH_Vector.h:61
virtual void setValuesByReference(const tUIndex &n, tReal *Vs)=0
set values by reference
virtual void add(const tReal &beta, const MATH_Vector &x, MATH_Vector &R)
R=T+beta.X.
Definition: MATH_Vector.h:197
virtual void setCapacity(const tUIndex &n)=0
set the capacity of the vector
virtual void copy(const MATH_Vector &v)
Definition: MATH_Vector.h:77
SP_OBJECT(MATH_Vector)
MATH_Vector(void)
create a vector
Definition: MATH_Vector.h:23
virtual void init(const tReal &alpha)
init the value to alpha
Definition: MATH_Vector.cpp:12
DEFINE_SPTR(MATH_Vector)
tReal norm() const
s=sqrt(tT.T) where T is this
Definition: MATH_Vector.h:219
void setValue(const tUIndex &i, const tReal &v)
set the value at index
Definition: MATH_Vector.h:105
virtual tReal dot(const MATH_Vector &x) const
s=x^t.T where T is this
Definition: MATH_Vector.cpp:480
This class describes a masked vector.
Definition: MATH_Vector.h:16
virtual tUIndex getSize() const =0
get the utile size of the vector
#define tUIndex
Definition: types.h:126
virtual void add(const MATH_Vector &y)
T+=y.
Definition: MATH_Vector.cpp:238
virtual void setSize(const tUIndex &n)=0
set the size of the vector
abstract base class for most classes.
Definition: CORE_Object.h:53
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: MATH_Vector.h:125
virtual tReal & operator()(const tUIndex &i)
return the values for element at i by copiing element
Definition: MATH_Vector.h:68
#define tULLInt
Definition: types.h:45
#define tReal
Definition: types.h:118