C++ main module for emicrom Package  1.0
CORE_Vector.h
Go to the documentation of this file.
1 #ifndef CORE_Vector_H
2 #define CORE_Vector_H
3 #include "CORE_List.h"
4 #include "types.h"
5 #include <vector>
7 #include "CORE_String.h"
8 #include "CORE_Exception.h"
9 
10 using namespace std;
11 
12 
13 
18 template <class T>
19 class CORE_Vector : public CORE_Object, public CORE_List {
20 
21 
22 private:
23  vector<T> mVector;
24 
25 
26  // CONSTRUCTORS
27 public:
30  CORE_Vector();
31 
34  CORE_Vector(const tUIndex& n);
35 
38  CORE_Vector(const CORE_Vector<T>& v);
39 
40 
41 
42 
43 
44  // DESTRUCTORS
45 public:
48  virtual ~CORE_Vector();
49 
50 
51 public:
52  // NEW operators
57  static inline boost::shared_ptr<CORE_Vector<T> > New(const boost::shared_ptr<CORE_Vector<T> >& v ) {
58  boost::shared_ptr<CORE_Vector<T> > p(new CORE_Vector<T>(),CORE_Object::Delete());
59  p->setThis(p);
60  p->copy(v);
61  return p;
62  };
67  static inline boost::shared_ptr<CORE_Vector<T> > New(const CORE_Vector<T>& v ) {
68  boost::shared_ptr<CORE_Vector<T> > p(new CORE_Vector<T>(),CORE_Object::Delete());
69  p->setThis(p);
70  p->copy(v);
71  return p;
72  };
77  static inline boost::shared_ptr<CORE_Vector<T> > New(const CORE_Vector<T>* v ) {
78  boost::shared_ptr<CORE_Vector<T> > p(new CORE_Vector<T>(),CORE_Object::Delete());
79  p->setThis(p);
80  if (v!=null) p->copy(*v);
81  return p;
82  };
86  static inline boost::shared_ptr<CORE_Vector<T> > New() {
87  boost::shared_ptr<CORE_Vector<T> > p(new CORE_Vector<T>(),CORE_Object::Delete());
88  p->setThis(p);
89  return p;
90  };
95  static inline boost::shared_ptr<CORE_Vector<T> > New(const tUIndex& dim) {
96  boost::shared_ptr<CORE_Vector<T> > p(new CORE_Vector<T>(),CORE_Object::Delete());
97  p->setThis(p);
98  p->setSize(dim);
99  return p;
100  };
101  // OPERATORS
102 public:
106  void getSharedPointer(boost::shared_ptr<CORE_Vector<T> >& p){
107  SP::CORE_Object r;
109  p=boost::dynamic_pointer_cast<CORE_Vector<T> >(r);
110  };
114  void getSharedPointer( boost::shared_ptr<const CORE_Vector<T> >& p) const{
115  SPC::CORE_Object r;
117  p=boost::dynamic_pointer_cast<const CORE_Vector<T> >(r);
118  };
119 private:
123  inline boost::shared_ptr<CORE_Vector<T> > getThis() {
124  boost::shared_ptr<CORE_Vector<T> > p;
125  getSharedPointer(p);
126  return p;
127  };
131  inline boost::shared_ptr<const CORE_Vector<T> > getThis() const {
132  boost::shared_ptr<const CORE_Vector<T> > p;
133  getSharedPointer(p);
134  return p;
135  };
136 public:
137 
138  //ACCESSOR Operators
139  //==================
144  inline const T& operator[](const tUIndex& i) const {
145  ASSERT_IN(i<mVector.size());
146  return mVector[i];
147  };
148 
153  inline T& operator[](const tUIndex& i) {
154  ASSERT_IN(i<mVector.size());
155  return mVector[i];
156  };
157 
158  // = Operators
159  //============
160 
165  inline CORE_Vector<T>& operator=(const T& v) {
166  return initValues(v);
167  };
168 
169  // arithmetic operators
170  //=====================
171 
175  inline CORE_Vector& operator+=(const T& v) {
176  typename vector<T>::iterator iterator;
177  for (iterator=mVector.begin();iterator<mVector.end();iterator++)
178  *iterator+=v;
179  return *this;
180  };
184  inline CORE_Vector& operator-=(const T& v) {
185  typename vector<T>::iterator iterator;
186  for (iterator=mVector.begin();iterator<mVector.end();iterator++)
187  *iterator-=v;
188  return *this;
189  };
193  inline CORE_Vector& operator*=(const T& v) {
194  typename vector<T>::iterator iterator;
195  for (iterator=mVector.begin();iterator<mVector.end();iterator++)
196  *iterator*=v;
197  return *this;
198  };
202  inline CORE_Vector& operator/=(const T& v) {
203  if (v==0) throw CORE_Exception("common/core","CORE_Vector/=","division y zero");
204  typename vector<T>::iterator iterator;
205  for (iterator=mVector.begin();iterator<mVector.end();iterator++)
206  *iterator/=v;
207 
208  return *this;
209  };
210 
211  //COPY Methods
212  // ===========
213 
217  template<class Q> void copy(const CORE_Vector<Q>& u) {
218  mVector.resize(u.getSize());
219  typename vector<T>::const_iterator iu=u.begin();
220  typename vector<T>::iterator iterator=mVector.begin();
221  while (iterator!=mVector.end()) {
222  *iterator=(T) (*iu);
223  //next iter
224  iu++;
225  iterator++;
226  }
227  }
231  template<class Q>
232  void copy(const boost::shared_ptr<CORE_Vector<Q> >& array) {
233  copy(array.get());
234  }
235 
239  template<class Q>
240  void copy(const vector<Q>& u) {
241  setValues(u);
242  }
243 
244  // SET Methods
245  //==================
248  inline void clear(){
249  setSize(0);
250  mVector.clear();
251  };
255  inline void setSize(const tUIndex& n){
256  mVector.resize(n);
257  };
261  inline void reserve(const tUIndex& n){
262  mVector.reserve(n);
263  };
264 
268  inline CORE_Vector<T>& initValues(const T& v) {
269  typename vector<T>::iterator iterator;
270  for (iterator=mVector.begin();iterator<mVector.end();iterator++)
271  *iterator=v;
272  return *this;
273  };
274 
279  CORE_Vector<T>& initValues(const tUIndex& from,const tString& v);
280 
281 
286  inline void setValue(const tUIndex& i,const T& v) {
287  (*this)[i]=v;
288  };
293  inline void set(const tUIndex& i,const T& v) {
294  (*this)[i]=v;
295  };
296 
297 
298 
302  template<class Q> void setValues(const vector<Q>& u) {
303  tUIndex n=u.size();
304  typename vector<Q>::const_iterator iu=u.begin();
305  mVector.resize(n);
306  typename vector<T>::iterator iterator;
307  for (iterator=mVector.begin();iterator!=mVector.end();iterator++) {
308  *iterator=(T) (*iu);
309  iu++;
310  }
311  }
316  template<class Q> void setValues(const Q* u,const tUIndex& n) {
317  mVector.resize(n);
318  const Q* iu=u;
319  typename vector<T>::iterator iterator;
320  for (iterator=mVector.begin();iterator!=mVector.end();iterator++) {
321  *iterator=(T) (*iu);
322  iu++;
323  }
324  }
325  // GET methods
326  // ============
327 
328 
331  typename vector<T>::const_iterator begin() const {
332  return mVector.begin();
333  };
336  typename vector<T>::iterator begin() {
337  return mVector.begin();
338  };
341  typename vector<T>::const_iterator end() const {
342  return mVector.end();
343  };
346  typename vector<T>::iterator end() {
347  return mVector.end();
348  };
349 
350 
351 
355  inline T& getLastElement() {
356  ASSERT_IN(mVector.size()>0);
357  return mVector[mVector.size()-1];
358  };
362  inline const T& getLastElement() const {
363  ASSERT_IN(mVector.size()>0);
364  return mVector[mVector.size()-1];
365  };
366 
370  inline const T& getValue(const tUIndex& i) const {return (*this)[i];};
371 
376  inline const T& get(const tUIndex& i) const {
377  return (*this)[i];
378  };
379 
384  inline T& get(const tUIndex& i) {
385  return (*this)[i];
386  };
387 
391  inline tUIndex getSize() const {return mVector.size();};
392 
396  inline tUIndex size() const {return mVector.size();};
397 
398 
402  inline const vector<T>& getValues() const {return mVector;};
406  inline vector<T>& getValues() {return mVector;};
407 
410  inline vector<T>& getVector() {
411  return mVector;
412  };
415  inline const vector<T>& getVector() const{
416  return mVector;
417  };
418 
419  //ARITHMETHIC Methods
420  //===================
424  inline void divideBy(const tReal& v) {
425  (*this)/=v;
426  }
427 
431  inline void multiplyBy(const tReal& v) {
432  (*this)*=v;
433  }
439  inline void add(const CORE_Vector<T>& u,const CORE_Vector<T>& v) {
440  tUIndex n=mVector.size();
441  tUIndex p=v.getSize();
442  tUIndex i,dim=(n<p)?n:p;
443  typename vector<T>::const_iterator iu=u.begin();
444  typename vector<T>::const_iterator iv=v.begin();
445  typename vector<T>::iterator it=mVector.begin();
446  for (i=0;i<dim;i++) {
447  (*it)=(*iu)+(*iv);
448  it++;
449  iu++;
450  iv++;
451  }
452  };
453 
456  inline void add(const tReal& f,const CORE_Vector<T>& v) {
457  if (f==0) {
458  return;
459  }
460  tUIndex n=mVector.size();
461  tUIndex p=v.getSize();
462  tUIndex i,dim=(n<p)?n:p;
463  typename vector<T>::const_iterator iv=v.begin();
464  typename vector<T>::iterator it=mVector.begin();
465  if (f==1) {
466  for (i=0;i<dim;i++) {
467  (*it)+=(*iv);
468  it++;
469  iv++;
470  }
471  } else {
472  for (i=0;i<dim;i++) {
473  (*it)+=f*(*iv);
474  it++;
475  iv++;
476  }
477  }
478  };
479 
480 
484  inline void add(const CORE_Vector<T>& v) {
485  add(1,v);
486  };
487 
491  inline void sub(const CORE_Vector<T>& v) {
492  sub(-1,v);
493  };
494 
499  inline void sub(const T& f,const CORE_Vector<T>& v) {
500  if (f==0) {
501  return;
502  }
503  tUIndex n=mVector.size();
504  tUIndex p=v.getSize();
505  tUIndex i,dim=(n<p)?n:p;
506  typename vector<T>::const_iterator iv=v.begin();
507  typename vector<T>::iterator it=mVector.begin();
508  if (f==1) {
509  for (i=0;i<dim;i++) {
510  (*it)-=(*iv);
511  it++;
512  iv++;
513  }
514  } else {
515  for (i=0;i<dim;i++) {
516  (*it)-=f*(*iv);
517  it++;
518  iv++;
519  }
520  }
521  };
522 
525  inline void sub(const CORE_Vector<T>& u,const CORE_Vector<T>& v) {
526  tUIndex n=mVector.size();
527  tUIndex p=v.getSize();
528  tUIndex i,dim=(n<p)?n:p;
529  typename vector<T>::const_iterator iu=u.begin();
530  typename vector<T>::const_iterator iv=v.begin();
531  typename vector<T>::iterator it=mVector.begin();
532  for (i=0;i<dim;i++) {
533  (*it)=(*iu)-(*iv);
534  it++;
535  iu++;
536  iv++;
537  }
538  };
539  // OPERATIONS
542  template<class Q>
543  inline tReal distance2(const CORE_Vector<Q>& a) const {
544  tUIndex n=a.getSize();
545  tUIndex m=getSize();
546  tUIndex i,p=(n<m)?n:m;
547  tReal d=0;
548  tReal t=0;
549  typename vector<Q>::const_iterator ia=a.begin();
550  typename vector<T>::const_iterator it=mVector.begin();
551  for (i=0;i<p;i++) {
552  t=((T)(*ia))-(*it);
553  d+=t*t;
554  ia++;
555  it++;
556  }
557  return d;
558  };
561  template<class Q>
562  tReal distance(const CORE_Vector<Q>& a) const {
563  return sqrt(distance2(a));
564  };
567  template<class Q>
569  tUIndex n=u.getSize();
570  tUIndex m=getSize();
571  tUIndex i,p=(n<m)?n:m;
572  tReal d=0;
573  typename vector<Q>::const_iterator iu=u.begin();
574  typename vector<T>::const_iterator it=mVector.begin();
575  for (i=0;i<p;i++) {
576  d+=((T)(*iu))*(*it);
577  iu++;
578  it++;
579  }
580  return d;
581  };
584  template<class Q>
586  if (a!=null) return scalarProduct(*a);
587  else return 0;
588  };
592  template<class Q>
593  inline static void crossProduct(const CORE_Vector<Q>& a,
594  const CORE_Vector<Q>& b,
595  CORE_Vector<Q>& res) {
596  //get size of vector a
597  tUIndex dim_a=a.getSize();
598  //get size of vector b
599  tUIndex dim_b=b.getSize();
600  //take the min size
601  tUIndex dim=(dim_a<dim_b)?dim_a:dim_b;
602  //set the result size
603  res.setSize(dim);
604 
605  //test if the size is null
606  if (dim==0) return;
607 
608  //build iterator
609  //typename vector<Q>::const_iterator ia=a.begin();
610  //typename vector<Q>::const_iterator ib=b.begin();
611  typename vector<T>::iterator it=res.begin();
612 
613  (*it)=a[1]*b[2]-a[2]*b[1];it++;
614  (*it)=a[2]*b[0]-a[0]*b[2];it++;
615  (*it)=a[0]*b[1]-a[1]*b[0];it++;
616 
617 
618 
619  };
622  template<class Q>
623  inline void crossProduct(const CORE_Vector<Q>& a,
624  CORE_Vector<Q>& res) const {
625  crossProduct(*this,a,res);
626  };
627 
632  inline void rotX(const tReal& alpha) {
633  if (getSize()<3) setSize(3);
634  tReal v1= mVector[1]*cos(alpha) + mVector[2]*sin(alpha);
635  mVector[2] = - mVector[1]*sin(alpha) + mVector[2]*cos(alpha);
636  mVector[1] =v1;
637  };
638 
643  inline void rotZ(const tReal& gamma) {
644  if (getSize()<2) setSize(2);
645  tReal v0 = mVector[0]*cos(gamma) + mVector[1]*sin(gamma) ;
646  mVector[1] =-mVector[0]*sin(gamma) + mVector[1]*cos(gamma) ;
647  mVector[0]=v0;
648  }
649 
652  inline tReal norm2() const {
653  typename vector<T>::const_iterator it=mVector.begin();
654  tReal d=0;
655  for (it=mVector.begin();it!=mVector.end();it++) {
656  d+=(*it)*(*it);
657  }
658  return d;
659  };
660 
663  tReal norm() const {
664  return sqrt(norm2());
665  };
666 
669  inline void normalize() {
670  tReal n=norm();
671  if (n>0) divideBy(n);
672  };
673 
674  //LIST METHODS
675  //============
676 
680  tBoolean exists(const T& obj) const;
681 
682 
685  virtual void addInList(const T& obj) {
686  push_back(obj);
687  };
688 
692  void push_back(const T& obj) {
693  mVector.push_back(obj);
694  };
698  void add(const T& obj) {
699  mVector.push_back(obj);
700  };
701 
702 
709  tBoolean insert(const tUIndex& i,const T& obj);
710 
716  tBoolean insertAtIndex(const tUIndex& i,const T& obj) {
717  return insert(i,obj);
718  }
719 
720 
726  inline tUIndex insert(const T& obj){
727  return insertInIncreasingOrder(obj,true);
728  };
729 
737  tUIndex insertInIncreasingOrder(const T& obj,const tBoolean& evenIfEqual);
738 
744  void addAfterIndex(const tUIndex& index,const T& v);
745 
751  void addAfterIndices(boost::shared_ptr<CORE_Vector<tUIndex> >& p_indices,
752  const CORE_SharedPointersList<CORE_Vector<T> >& values);
753 
754 
755 
756 
757 
761  void append(const CORE_Vector<T>& array);
762 
768  tBoolean remove(const T& obj);
769 
775  tBoolean remove(const T* obj) {
776  if (obj!=null) remove(*obj);
777  return false;
778  }
779 
782  tBoolean removeAtIndex(const tUIndex& i);
783 
784 
787  inline tBoolean remove() {
788  if (getSize()==0) return false;
789  return remove(getSize()-1);
790  };
791 
796  inline void sort(const tFlag& order) {
797  sort(mVector,order);
798  };
803  inline void sort() {
804  sort(CORE_List::LT);
805  };
806 
807 
810  static void sort(vector<T>& items,
811  const tFlag& order);
812 
813 
817  static tUIndex search(const vector<T>& values,
818  const T& value,const tFlag& order);
819 
822  tUIndex search(const T& value,const tFlag& order) {
823  return search(mVector,value,order);
824  }
830  void permute(const tUIndex& i,const tUIndex&j);
831 
834  void reverse();
835 
836 
837 
838 
839 
843  virtual tString toString() const {
844  tString ret=getIdentityString()+"(";
845  typename vector<T>::const_iterator it=mVector.begin();
846  for (it=mVector.begin();it!=mVector.end();it++) {
847  ret+=CORE_String::toString(*it)+",";
848  }
849  ret+=")";
850  return ret;
851  }
852 
853 
854 };
855 
856 #include "CORE_Vector.hpp"
857 
869 
870 //share pointer of primitive type vector
882 
883 #endif
void getSharedPointer(boost::shared_ptr< const CORE_Vector< T > > &p) const
get the shared pointer into P
Definition: CORE_Vector.h:114
CORE_Vector< tBoolean > CORE_BooleanVector
Definition: CORE_Vector.h:858
CORE_Vector< T > & operator=(const T &v)
init the vector to v
Definition: CORE_Vector.h:165
static boost::shared_ptr< CORE_Vector< T > > New(const boost::shared_ptr< CORE_Vector< T > > &v)
create a shared pointer of vector which is a copy of vector v
Definition: CORE_Vector.h:57
CORE_Vector< tUInteger > CORE_UIntegerVector
Definition: CORE_Vector.h:867
this class describes an array
Definition: CORE_Vector.h:19
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
tReal distance(const CORE_Vector< Q > &a) const
return the distance of the vector with the a vector
Definition: CORE_Vector.h:562
CORE_Vector< tSInt > CORE_ShortVector
Definition: CORE_Vector.h:864
CORE_Vector & operator+=(const T &v)
do the arithmetic operation This+=v
Definition: CORE_Vector.h:175
void add(const T &obj)
add an element at the end
Definition: CORE_Vector.h:698
T & operator[](const tUIndex &i)
get the i-th element
Definition: CORE_Vector.h:153
tReal distance2(const CORE_Vector< Q > &a) const
return the squared distance of the vector with the a vector
Definition: CORE_Vector.h:543
CORE_Vector< tComplex > CORE_ComplexVector
Definition: CORE_Vector.h:862
const vector< T > & getValues() const
get values as a vector
Definition: CORE_Vector.h:402
void multiplyBy(const tReal &v)
multiplied by value v
Definition: CORE_Vector.h:431
void setValues(const vector< Q > &u)
set the values
Definition: CORE_Vector.h:302
this class describes a list interface
Definition: CORE_List.h:12
void sort()
sort the vector decreasing order < increasing order
Definition: CORE_Vector.h:803
void add(const tReal &f, const CORE_Vector< T > &v)
This+=f*v;.
Definition: CORE_Vector.h:456
void setValue(const tUIndex &i, const T &v)
set value at indx i
Definition: CORE_Vector.h:286
void push_back(const T &obj)
add an element at the end
Definition: CORE_Vector.h:692
tReal norm2() const
return the squared norm of the vector
Definition: CORE_Vector.h:652
void sub(const T &f, const CORE_Vector< T > &v)
This-=f*v;.
Definition: CORE_Vector.h:499
vector< T > mVector
Definition: CORE_Vector.h:23
CORE_Vector & operator/=(const T &v)
do the arithmetic operation This/=v
Definition: CORE_Vector.h:202
#define tBoolean
Definition: types.h:139
CORE_Vector< T > & initValues(const T &v)
init the value to v
Definition: CORE_Vector.h:268
tReal scalarProduct(const CORE_Vector< Q > &u) const
return the scalar product of the vector with the a vector
Definition: CORE_Vector.h:568
tReal scalarProduct(const CORE_Vector< Q > *a) const
return the scalar product of the vector with the a vector
Definition: CORE_Vector.h:585
vector< T >::iterator end()
get iterator
Definition: CORE_Vector.h:346
vector< T > & getValues()
get values
Definition: CORE_Vector.h:406
CORE_Vector< tFlag > CORE_FlagVector
Definition: CORE_Vector.h:863
void add(const CORE_Vector< T > &v)
This+=v.
Definition: CORE_Vector.h:484
virtual tString toString() const
return the string associated to the string
Definition: CORE_String.h:223
CORE_Vector< tInteger > CORE_IntegerVector
Definition: CORE_Vector.h:866
#define null
Definition: types.h:144
void getSharedPointer(boost::shared_ptr< CORE_Vector< T > > &p)
get the shared pointer into P
Definition: CORE_Vector.h:106
void rotZ(const tReal &gamma)
rotate the vector among z-axes with angle gamma
Definition: CORE_Vector.h:643
CORE_Vector< tUIndex > CORE_UIndexVector
Definition: CORE_Vector.h:868
void rotX(const tReal &alpha)
rotate the vector among x-axes with angle alpha
Definition: CORE_Vector.h:632
void sub(const CORE_Vector< T > &v)
This-=v;.
Definition: CORE_Vector.h:491
void setSize(const tUIndex &n)
set the size of the vector
Definition: CORE_Vector.h:255
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
T & getLastElement()
get last element value for writing
Definition: CORE_Vector.h:355
CORE_Vector< tReal > CORE_RealVector
Definition: CORE_Vector.h:861
tUIndex getSize() const
return the size of the vector
Definition: CORE_Vector.h:391
void divideBy(const tReal &v)
divide by value v
Definition: CORE_Vector.h:424
CORE_Vector< tChar > CORE_CharVector
Definition: CORE_Vector.h:859
tUIndex insert(const T &obj)
insert T
Definition: CORE_Vector.h:726
CORE_Vector & operator-=(const T &v)
do the arithmetic operation This-=v
Definition: CORE_Vector.h:184
tBoolean insertAtIndex(const tUIndex &i, const T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_Vector.h:716
void sort(const tFlag &order)
sort the vector decreasing order < increasing order
Definition: CORE_Vector.h:796
void getSharedPointer(SP::CORE_Object &p)
get the shared pointer of this class into p
Definition: CORE_Object.h:97
void add(const CORE_Vector< T > &u, const CORE_Vector< T > &v)
init the value to this=u-v
Definition: CORE_Vector.h:439
void setValues(const Q *u, const tUIndex &n)
set the values
Definition: CORE_Vector.h:316
vector< T >::iterator begin()
get iterator
Definition: CORE_Vector.h:336
#define tUIndex
Definition: types.h:126
void reserve(const tUIndex &n)
set the capacity of the vector
Definition: CORE_Vector.h:261
const T & getLastElement() const
get last element value for reading
Definition: CORE_Vector.h:362
abstract base class for most classes.
Definition: CORE_Object.h:53
static void crossProduct(const CORE_Vector< Q > &a, const CORE_Vector< Q > &b, CORE_Vector< Q > &res)
return the cross product of the vector with the a vector res=a^b
Definition: CORE_Vector.h:593
#define tString
Definition: types.h:135
void copy(const CORE_Vector< Q > &u)
copy
Definition: CORE_Vector.h:217
CORE_Vector< tString > CORE_StringVector
Definition: CORE_Vector.h:865
const vector< T > & getVector() const
get vector
Definition: CORE_Vector.h:415
static boost::shared_ptr< CORE_Vector< T > > New()
create a shared pointer of vector
Definition: CORE_Vector.h:86
static boost::shared_ptr< CORE_Vector< T > > New(const CORE_Vector< T > &v)
create a shared pointer of vector which is a copy of vector v
Definition: CORE_Vector.h:67
tReal norm() const
return the norm of the vector
Definition: CORE_Vector.h:663
tUIndex search(const T &value, const tFlag &order)
search the value in values vector ordered in order
Definition: CORE_Vector.h:822
tUIndex size() const
return the size of the vector
Definition: CORE_Vector.h:396
void crossProduct(const CORE_Vector< Q > &a, CORE_Vector< Q > &res) const
return the cross product of the vector with the a vector
Definition: CORE_Vector.h:623
virtual void addInList(const T &obj)
add a core object
Definition: CORE_Vector.h:685
boost::shared_ptr< const CORE_Vector< T > > getThis() const
get the shared pointer This
Definition: CORE_Vector.h:131
CORE_Vector< tInt > CORE_IntVector
Definition: CORE_Vector.h:860
boost::shared_ptr< CORE_Vector< T > > getThis()
get the shared pointer This
Definition: CORE_Vector.h:123
static boost::shared_ptr< CORE_Vector< T > > New(const tUIndex &dim)
create a shared pointer of vector of size dim
Definition: CORE_Vector.h:95
vector< T > & getVector()
get vector
Definition: CORE_Vector.h:410
void sub(const CORE_Vector< T > &u, const CORE_Vector< T > &v)
init the value to This=u-v
Definition: CORE_Vector.h:525
const T & getValue(const tUIndex &i) const
get value
Definition: CORE_Vector.h:370
static boost::shared_ptr< CORE_Vector< T > > New(const CORE_Vector< T > *v)
create a shared pointer of vector which is a copy of vector v
Definition: CORE_Vector.h:77
vector< T >::const_iterator begin() const
get iterator
Definition: CORE_Vector.h:331
static const tFlag LT
=
Definition: CORE_List.h:23
virtual tString toString() const
return the string representation of the vector
Definition: CORE_Vector.h:843
TYPEDEF_SPTR(CORE_BooleanVector)
void clear()
clear the array
Definition: CORE_Vector.h:248
#define tReal
Definition: types.h:118
const T & operator[](const tUIndex &i) const
get the i-th element
Definition: CORE_Vector.h:144
vector< T >::const_iterator end() const
get iterator
Definition: CORE_Vector.h:341
#define ASSERT_IN(a)
Definition: types.h:196
void normalize()
normalize
Definition: CORE_Vector.h:669
CORE_Vector & operator*=(const T &v)
do the arithmetic operation This*=v
Definition: CORE_Vector.h:193
void copy(const vector< Q > &u)
copy the values
Definition: CORE_Vector.h:240
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
void copy(const boost::shared_ptr< CORE_Vector< Q > > &array)
copy
Definition: CORE_Vector.h:232
#define tFlag
Definition: types.h:74