57 static inline boost::shared_ptr<CORE_Vector<T> >
New(
const boost::shared_ptr<
CORE_Vector<T> >& v ) {
80 if (v!=
null) p->copy(*v);
86 static inline boost::shared_ptr<CORE_Vector<T> >
New() {
95 static inline boost::shared_ptr<CORE_Vector<T> >
New(
const tUIndex& dim) {
117 p=boost::dynamic_pointer_cast<
const CORE_Vector<T> >(r);
123 inline boost::shared_ptr<CORE_Vector<T> >
getThis() {
124 boost::shared_ptr<CORE_Vector<T> > p;
131 inline boost::shared_ptr<const CORE_Vector<T> >
getThis()
const {
132 boost::shared_ptr<const CORE_Vector<T> > p;
166 return initValues(v);
176 typename vector<T>::iterator iterator;
177 for (iterator=mVector.begin();iterator<mVector.end();iterator++)
185 typename vector<T>::iterator iterator;
186 for (iterator=mVector.begin();iterator<mVector.end();iterator++)
194 typename vector<T>::iterator iterator;
195 for (iterator=mVector.begin();iterator<mVector.end();iterator++)
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++)
219 typename vector<T>::const_iterator iu=u.
begin();
220 typename vector<T>::iterator iterator=mVector.begin();
221 while (iterator!=mVector.end()) {
240 void copy(
const vector<Q>& u) {
269 typename vector<T>::iterator iterator;
270 for (iterator=mVector.begin();iterator<mVector.end();iterator++)
293 inline void set(
const tUIndex& i,
const T& v) {
304 typename vector<Q>::const_iterator iu=u.begin();
306 typename vector<T>::iterator iterator;
307 for (iterator=mVector.begin();iterator!=mVector.end();iterator++) {
319 typename vector<T>::iterator iterator;
320 for (iterator=mVector.begin();iterator!=mVector.end();iterator++) {
331 typename vector<T>::const_iterator
begin()
const {
332 return mVector.begin();
336 typename vector<T>::iterator
begin() {
337 return mVector.begin();
341 typename vector<T>::const_iterator
end()
const {
342 return mVector.end();
346 typename vector<T>::iterator
end() {
347 return mVector.end();
357 return mVector[mVector.size()-1];
364 return mVector[mVector.size()-1];
402 inline const vector<T>&
getValues()
const {
return mVector;};
439 inline void add(
const CORE_Vector<T>& u,
const CORE_Vector<T>& v) {
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++) {
456 inline void add(
const tReal& f,
const CORE_Vector<T>& v) {
463 typename vector<T>::const_iterator iv=v.
begin();
464 typename vector<T>::iterator it=mVector.begin();
466 for (i=0;i<dim;i++) {
472 for (i=0;i<dim;i++) {
484 inline void add(
const CORE_Vector<T>& v) {
491 inline void sub(
const CORE_Vector<T>& v) {
499 inline void sub(
const T& f,
const CORE_Vector<T>& v) {
506 typename vector<T>::const_iterator iv=v.
begin();
507 typename vector<T>::iterator it=mVector.begin();
509 for (i=0;i<dim;i++) {
515 for (i=0;i<dim;i++) {
525 inline void sub(
const CORE_Vector<T>& u,
const CORE_Vector<T>& v) {
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++) {
549 typename vector<Q>::const_iterator ia=a.
begin();
550 typename vector<T>::const_iterator it=mVector.begin();
563 return sqrt(distance2(a));
573 typename vector<Q>::const_iterator iu=u.
begin();
574 typename vector<T>::const_iterator it=mVector.begin();
586 if (a!=
null)
return scalarProduct(*a);
601 tUIndex dim=(dim_a<dim_b)?dim_a:dim_b;
611 typename vector<T>::iterator it=res.
begin();
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++;
625 crossProduct(*
this,a,res);
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);
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) ;
653 typename vector<T>::const_iterator it=mVector.begin();
655 for (it=mVector.begin();it!=mVector.end();it++) {
664 return sqrt(norm2());
671 if (n>0) divideBy(n);
680 tBoolean exists(
const T& obj)
const;
693 mVector.push_back(obj);
699 mVector.push_back(obj);
717 return insert(i,obj);
727 return insertInIncreasingOrder(obj,
true);
737 tUIndex insertInIncreasingOrder(
const T& obj,
const tBoolean& evenIfEqual);
744 void addAfterIndex(
const tUIndex& index,
const T& v);
761 void append(
const CORE_Vector<T>& array);
776 if (obj!=
null)
remove(*obj);
788 if (getSize()==0)
return false;
789 return remove(getSize()-1);
810 static void sort(vector<T>& items,
817 static tUIndex search(
const vector<T>& values,
818 const T& value,
const tFlag& order);
823 return search(mVector,value,order);
844 tString ret=getIdentityString()+
"(";
845 typename vector<T>::const_iterator it=mVector.begin();
846 for (it=mVector.begin();it!=mVector.end();it++) {
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