C++ main module for emicrom Package  1.0
CORE_Array.h
Go to the documentation of this file.
1 #ifndef CORE_Array_H
2 #define CORE_Array_H
3 
4 
5 #include "CORE_Object.h"
6 #include "CORE_List.h"
7 #include "CORE_ListPointers.h"
8 #include "CORE_Exception.h"
9 #include "CORE_Integer.h"
10 
11 #include "types.h"
12 #include <vector>
13 
18 template <class T>
19 class CORE_Array : public CORE_Object {
20 
21 
22 private:
23  // values of the array
24  T* mValues;
25 
26  // size of the array
28 
29  // memory size of the array
31 
32 
33  //inidate if the values has been allocated within this class
35 
36 
37  // CONSTRUCTORS
38 public:
42  mCapacity=0;
43  mSize=0;
44  mValues=null;
45  mIsPrivateAllocated=false;
46  }
51  mCapacity=0;
52  mSize=0;
53  mValues=null;
54  mIsPrivateAllocated=false;
55  copy(c);
56  }
60  CORE_Array(const tUIndex& n) {
61  mCapacity=0;
62  mSize=0;
63  mValues=null;
64  mIsPrivateAllocated=false;
65  setSize(n);
66  }
67 
68 
69 
70 
71  // DESTRUCTORS
74  virtual ~CORE_Array() {
75  desallocate();
76  }
77 
78 
79 
80  // -----------------------
81  // shared pointer operator
82  // ------------------------
83 public:
86  void getSharedPointer(boost::shared_ptr<CORE_Array<T> >& p){
87  SP::CORE_Object r;
89  p=boost::dynamic_pointer_cast<CORE_Array<T> >(r);
90  };
93  void getSharedPointer( boost::shared_ptr<const CORE_Array<T> >& p) const{
94  SPC::CORE_Object r;
96  p=boost::dynamic_pointer_cast<const CORE_Array<T> >(r);
97  };
98 private:
101  inline boost::shared_ptr<CORE_Array<T> > getThis() {
102  boost::shared_ptr<CORE_Array<T> > p;
103  getSharedPointer(p);
104  return p;
105  };
108  inline boost::shared_ptr<const CORE_Array<T> > getThis() const {
109  boost::shared_ptr<const CORE_Array<T> > p;
110  getSharedPointer(p);
111  return p;
112  };
113 
114  // ----------------
115  // New constructors
116  // ----------------
117 public:
120  static inline boost::shared_ptr<CORE_Array<T> > New() {
121  boost::shared_ptr<CORE_Array<T> > p(new CORE_Array<T>(),
123  p->setThis(p);
124  return p;
125  };
126 
127 
128  //Builder of array
129  //================
130 private:
131 
134  void desallocate();
135 
140  void allocate(const tUIndex& cap);
141 
142 public:
143 
147  void reserve(const tUIndex& cap) {
148  if (mCapacity<cap) allocate(cap);
149  }
150 
154  virtual void fitToSize();
155 
156  // ---------------------------
157  // Accessor & basic operators
158  // ---------------------------
159 public:
164  inline const T& operator[](const tUIndex& i) const {
165  if (i>=mCapacity)
166  throw CORE_Exception("common/core",
167  "CORE_Array<T>["+CORE_Integer::toString(i)+"]",
168  "index out of bounds [0,"+CORE_Integer::toString(mCapacity)+"[");
169  return mValues[i];
170  };
175  inline T& operator[](const tUIndex& i) {
176  if (i>=mCapacity)
177  throw CORE_Exception("common/core",
178  "CORE_Array<T>["+CORE_Integer::toString(i)+"]",
179  "index out of bounds [0,"+CORE_Integer::toString(mCapacity)+"[");
180  return mValues[i];
181  };
182 
183 
184  //copy operators
185  //===============
186 
187 
190  template<class Q>
191  inline CORE_Array<T>& operator=(const Q& f) {
192  initArray(f);
193  return (*this);
194  };
195 
196 
197 
198  //arithmetic operators
199  //===================
200 
201 
206  template<class Q>
207  inline CORE_Array<T>& operator+=(const Q& f) {
208  tUIndex i;
209  T* Ts=&(*this)[0];
210  for (i=0;i<mSize;i++) {
211  (*Ts)+=(T)f;
212  Ts++;
213 
214  }
215  return (*this);
216  }
221  template<class Q>
222  inline CORE_Array<T>& operator-=(const Q& f) {
223  tUIndex i;
224  T* Ts=&(*this)[0];
225  for (i=0;i<mSize;i++) {
226  (*Ts)-=(T)f;
227  Ts++;
228 
229  }
230  return (*this);
231  }
236  template<class Q>
237  inline CORE_Array<T>& operator*=(const Q& f) {
238  tUIndex i;
239  T* Ts=&(*this)[0];
240  for (i=0;i<mSize;i++) {
241  (*Ts)*=(T)f;
242  Ts++;
243 
244  }
245  return (*this);
246  }
247 
252  template<class Q>
253  inline CORE_Array<T>& operator/=(const Q& f) {
254  if (f==0) throw CORE_Exception("common/core","CORE_Array/=","division by 0");
255  tUIndex i;
256  T* Ts=&(*this)[0];
257  for (i=0;i<mSize;i++) {
258  (*Ts)/=(T)f;
259  Ts++;
260 
261  }
262  return (*this);
263  }
264 
265 
266 
267  // SET Methods
268  // ==================
269 
270 
271 
272 
276  template<class Q>
277  void copy(const CORE_Array<Q>& f);
278 
282  template<class Q>
283  void copy(const CORE_Array<Q>* f) {
284  if (f!=null) copy(*f);
285  }
286 
287 
292  inline void setSize(const tUIndex& n) {
293  if (n>mCapacity) allocate(n);
294  mSize=n;
295  }
296 
297 
300  virtual void clear() {
301  desallocate();
302  mSize=0;
303  mCapacity=0;
304  mValues=null;
305  mIsPrivateAllocated=false;
306  }
307 
308 
309 
310  // set the values
311  //===============
315  template<class Q>
316  inline void initArray(const Q& f) {
317  if (mSize==0) return;
318  if ( fabs((T)f) <=CORE_Object::getEpsilon<T>()) {
319  memset(mValues,0,mSize*sizeof(*mValues));
320  } else {
321  tUIndex i=0;
322  T *Ts=&(*this)[0];
323  while (i<mSize) {
324  *Ts=(T) f;
325  Ts++;
326  i++;
327  }
328  }
329  }
335  template<class Q>
336  void initArray(const tUIndex& p,const Q B[]);
337 
341  template<class Q>
342  inline void initArray(const vector<Q>& B) {
343  setValues(B);
344  }
345 
354  template<class Q>
355  void initArray(const tUIndex& from,const tUIndex& to,const Q& Bx,const Q& By,const Q& Bz);
356 
365  template<class Q>
366  void initArray(const tUIndex& from,const tUIndex& to,const tUIndex& p,const tUSInt& inc,const Q B[]);
367 
375  template<class Q>
376  inline void initArray(const tUIndex& from,const tUIndex& to,const tUIndex& p,const Q B[]) {
377  initArray(from,to,p,1,B);
378  }
379 
386  void initArray(const tUIndex& from,const tString& values);
387 
393  inline void initArray(const tString& values) {
394  initArray(0,values);
395  }
396 
397 
404  template<class Q>
405  inline tBoolean setValuesByReference(const tUIndex& n,Q* array) {
406  //verify Q & T have same size
407  if (sizeof(T)!=sizeof(Q)) return false;
408 
409  desallocate();
410  mValues=(T*) array;
411  mSize=n;
412  mCapacity=n;
413  mIsPrivateAllocated=false;
414  return true;
415  }
423  template<class Q>
425  //verify Q & T have same size
426  if (sizeof(T)!=sizeof(Q)) return false;
427 
428  //desallocate this
429  desallocate();
430  //copy the values of the array by reference into this
431  mValues=array.getValues();
432  mSize=array.getSize();
433  mCapacity=array.getCapacity();
434  mIsPrivateAllocated=true;
435  //disable the desallocation of the values of the array
436  array.mIsPrivateAllocated=false;
437  return true;
438  }
439 
444  template<class Q>
445  inline void setValues(const tUIndex& n,const Q* v) {
446  setSize(n);
447  tUIndex i=0;
448  T *Ts=&(*this)[0];
449  const Q* cv=v;
450 
451  if (sizeof(T)==sizeof(Q)) {
452  //copy a block of memory
453  memcpy(Ts,v,n*sizeof(T));
454  } else {
455  //copy each value
456  while (i<mSize) {
457  *Ts=(T) (*cv);
458  Ts++;
459  cv++;
460  i++;
461  }
462  }
463  }
467  template<class Q>
468  inline void setValues(const vector<Q>& v) {
469  setSize(v.size());
470  if (v.size()!=0) {
471  tUIndex i=0;
472  T *Ts=&(*this)[0];
473  typename vector<Q>::const_iterator cv=v.begin();
474  while (i<mSize) {
475  *Ts=(T) (*cv);
476  Ts++;
477  cv++;
478  i++;
479  }
480 
481  }
482  }
483 
487  template<class Q>
488  inline void setValues(const CORE_Array<Q>& v) {
489  copy(v);
490  }
491 
496  inline void setValue(const tUIndex& i,const T& v) {
497  (*this)[i]=v;
498  }
499 
504  inline void set(const tUIndex& i,const T& v) {
505  (*this)[i]=v;
506  }
511  template<class Q>
512  void set(const tReal& alpha,const CORE_Array<Q>& Y) {
513  if (alpha==0) {
514  initArray(0);
515  return;
516  }
517  if (alpha==1) {
518  copy(Y);
519  return ;
520  }
521  tUIndex i,n=Y.getSize();
522  //set the size to n
523  setSize(n);
524  if (n==0) return;
525 
526  const Q* Ys=&Y[0];
527  T* Ts=&(*this)[0];
528  for (i=0;i<n;i++) {
529  (*Ts)=(T) (alpha * (*Ys) );
530  Ts++;
531  Ys++;
532 
533  }
534 
535 
536  }
545  virtual tULLInt getMemorySize() const {
546 
547  return (mIsPrivateAllocated)?0:mSize*sizeof(T);
548 
549  }
550 
555  inline T& get(const tUIndex& i) {
556  return (*this)[i];
557  }
562  inline const T& get(const tUIndex& i) const {
563  return (*this)[i];
564  }
565 
566 
570  inline tString getTypeToString() const {
571  return CORE_Object::getTypeName<T>();
572  }
573 
574  //mathematical operations
575  //=========================
581  template<class Q>
582  void add(const tReal& alpha,const CORE_Array<Q>& Y,const tReal& beta) {
583  if (alpha==0) {
584  if (beta==0) {
585  initArray(0);
586  return;
587  }
588  if (beta==1) {
589  return;
590  }
591  (*this)*=beta;
592  return;
593  }
594 
595 
596 
597  if (alpha==1){
598  if (beta==0) {
599  initArray(Y);
600  return ;
601  }
602  if (beta==1) {
603  add(Y);
604  return;
605  }
606  }
607 
608  if (beta==1) {
609  add(alpha,Y);
610  return;
611  }
612 
613  tUIndex j,i,q=Y.getSize();
614  if (q==0) return;
615  if (mSize==0) return;
616  const Q* Ys=null;
617  T* Ts=null;
618  if (q>mSize) q=mSize;
619  Ts=&(*this)[0];
620  for (j=0;j<mSize;j+=q) {
621  Ys=&Y[0];
622  for (i=0;i<q;i++) {
623  (*Ts)=(*Ts)*beta+((T) (alpha*(*Ys)));
624  Ts++;
625  Ys++;
626  }
627  }
628  }
629 
634  template<class Q>
635  void add(const tReal& alpha,const CORE_Array<Q>& Y) {
636  if (alpha==0) return;
637  if (alpha==1) {
638  add(Y);
639  return ;
640  }
641  tUIndex j,i,q=Y.getSize();
642  if (q==0) return;
643  if (mSize==0) return;
644  const Q* Ys=null;
645  T* Ts=null;
646  if (q>mSize) q=mSize;
647  Ts=&(*this)[0];
648  for (j=0;j<mSize;j+=q) {
649  Ys=&Y[0];
650  for (i=0;i<q;i++) {
651  (*Ts)+=(T) (alpha*(*Ys));
652  Ts++;
653  Ys++;
654  }
655  }
656  }
660  template<class Q>
661  void add(const CORE_Array<Q>& Y) {
662  tUIndex j,i,q=Y.getSize();
663  if (q==0) return;
664  if (mSize==0) return;
665  const Q* Ys=null;
666  T* Ts=null;
667  if (q>mSize) q=mSize;
668  Ts=&(*this)[0];
669  for (j=0;j<mSize;j+=q) {
670  Ys=&Y[0];
671  for (i=0;i<q;i++) {
672  (*Ts)+=(T) (*Ys);
673  Ts++;
674  Ys++;
675  }
676  }
677 
678  }
679 
684  template<class Q>
685  void sub(const tReal& alpha,const CORE_Array<Q>& Y) {
686  add(-alpha,Y);
687  }
691  template<class Q>
692  void sub(const CORE_Array<Q>& Y) {
693  tUIndex i,j,q=Y.getSize();
694  //get the minimum of size
695  if (q==0) return;
696  if (mSize==0) return;
697  const Q* Ys=null;
698  T* Ts=null;
699  if (q>mSize) q=mSize;
700 
701  Ts=&(*this)[0];
702  for (i=0;i<mSize;i+=q) {
703  Ys=&Y[0];
704  for (j=0;j<q;j++) {
705  (*Ts)-=(T) (*Ys);
706  Ts++;
707  Ys++;
708  }
709  }
710 
711 
712  }
716  template<class Q>
717  void multiply(const CORE_Array<Q>& Y) {
718  tUIndex i,j,q=Y.getSize();
719  //get the minimum of size
720  if (q==0) return;
721  if (mSize==0) return;
722  const Q* Ys=null;
723  T* Ts=null;
724  if (q>mSize) q=mSize;
725 
726  Ts=&(*this)[0];
727  for (i=0;i<mSize;i+=q) {
728  Ys=&Y[0];
729  for (j=0;j<q;j++) {
730  (*Ts)*=(T) (*Ys);
731  Ts++;
732  Ys++;
733  }
734  }
735  }
736 
740  inline tReal max(tUIndex& k) const {
741  tReal s=0;
742  tReal tmp;
743  k=0;
744  const T* p=&mValues[0];
745  for (tUIndex i=0;i<mSize;i++) {
746  tmp=fabs(*p);
747  if (tmp>s) {
748  s=tmp;
749  k=i;
750  }
751  p++;
752  }
753  return s;
754  }
758  inline tReal norm2() const {
759  tReal s=0;
760  const T* p=&mValues[0];
761  for (tUIndex i=0;i<mSize;i++) {
762  s+=(tReal)((*p)*(*p));
763  p++;
764  }
765  return s;
766  }
770  inline tReal sum() const {
771  tReal s=0;
772  const T* p=&mValues[0];
773  for (tUIndex i=0;i<mSize;i++) {
774  s+=(*p);
775  p++;
776  }
777  return s;
778  }
779 
783  template<class Q>
784  inline tReal dot(const CORE_Array<Q>& y) const {
785  tReal s=0;
786  tReal d;
787  tUIndex i,j,q=y.getSize();
788  //get the min of dimension
789  q=(mSize<q)?mSize:q;
790 
791  //min dimension is null
792  if (q==0) return 0;
793 
794  const T* px=&mValues[0];
795  const Q* py=&y[0];
796 
797  for (i=0;i<mSize;i++) {
798  s+=(*px)*(*py);
799  px++;
800  py++;
801  }
802  return s;
803  };
804 
808  inline tReal norm() const{
809  return sqrt(norm2());
810  };
811 
812 
816  template<class Q>
817  inline tReal distance2(const CORE_Array<Q>& y) const {
818  tReal s=0;
819  tReal d;
820  tUIndex i,j,q=y.getSize();
821  if (mSize==0) return y.norm2();
822  if (q==0) return norm2();
823  const T* px=&mValues[0];
824  const Q* py=null;
825  if (q>mSize) q=mSize;
826  for (i=0;i<mSize;i+=q) {
827  py=&y[0];
828  for (j=0;j<q;j++) {
829  d=((tReal)(*px))-((tReal)(*py));
830  s+=d*d;
831  px++;
832  py++;
833  }
834  }
835  return s;
836  };
842  template<class Q>
843  inline tReal distanceMax(const CORE_Array<Q>& y,tUIndex& k) const {
844  //distance of each points
845  tReal d,dmax=0;
846 
847  //index of the max distance
848  k=0;
849  //size of y
850  tUIndex i,j,q=y.getSize();
851 
852  //if this is empty, return the max of y
853  if (mSize==0) return y.max(k);
854 
855  //if y is emptyn return the max of this
856  if (q==0) return max(k);
857 
858  //iteration on values of this
859  const T* px=null;
860  px=&mValues[0];
861 
862  //iteration on values of y
863  const Q* py=null;
864 
865  //compare only the values of this
866  if (q>mSize) q=mSize;
867 
868  for (i=0;i<mSize;i+=q) {//loop on element of This by packs of elements of y for uniform value
869  //pack of y
870  py=&y[0];
871  for (j=0;j<q;j++) {
872  //compute teh distance
873  d=fabs( ((tReal)(*px))-((tReal)(*py)));
874  //take the max
875  if (d>dmax) {
876  dmax=d;
877  k=i*q+j;
878  }
879  //next element of this
880  px++;
881  //next element of y
882  py++;
883  }
884  }
885 
886  return dmax;
887  };
888 
893  template<class Q>
894  inline tReal distanceMax(const CORE_Array<Q>& y) const {
895  tUIndex k;
896  return distanceMax(y,k);
897  }
901  template<class Q>
902  inline tReal distance(const CORE_Array<Q>& y) const{
903  return sqrt(distance2(y));
904  };
905 
906 
907 
908  // GET
909 
910 
914  inline const T& getLastElement() const {
915  if (mSize==0) throw CORE_Exception("common/core","CORE_Array::getLastElement()","no element in array");
916  return mValues[mSize-1];
917  };
921  inline T& getLastElement() {
922  if (mSize==0) throw CORE_Exception("common/core","CORE_Array::getLastElement()","no element in array");
923  return mValues[mSize-1];
924  };
925 
926 
930  inline const T* getValues() const {
931  return mValues;
932  }
933 
937  inline T* getValues() {
938  return mValues;
939  }
944  inline const T* getValues(tUIndex& n) const {
945  n=mSize;
946  return mValues;
947  }
948 
953  inline T* getValues(tUIndex& n) {
954  n=mSize;
955  return mValues;
956  }
961  inline T& getValue(const tUIndex& i) {
962  return (*this)[i];
963  }
968  inline const T& getValue(const tUIndex& i) const {
969  return (*this)[i];
970  }
971 
974  inline void reverse() {
975  tUIndex i,p=mSize/2;
976  if (p==0) return;
977 
978  T* vi=&mValues[0];
979  T* vf=&mValues[mSize-1];
980  for (i=0;i<p;i++) {
981  std::swap(*vi,*vf);
982  vi++;
983  vf--;
984  }
985  }
986 
992  inline void swap(CORE_Array<T>& f) {
993  tUIndex i,p=mSize;
994 
995  if (p==0) return;
996 
997  if (f.getSize()!=p) throw CORE_Exception("common/core",
998  "CORE_Array::swap()",
999  "incompatibe size");
1000 
1001  T* vi=&mValues[0];
1002  T* vf=&f[0];
1003  for (i=0;i<p;i++) {
1004  std::swap(*vi,*vf);
1005  vi++;
1006  vf++;
1007  }
1008  }
1009 protected:
1012  inline const tUIndex& getCapacity() const {return mCapacity;};
1013 
1014 public:
1018  inline const tUIndex& getSize() const {
1019  return mSize;
1020  };
1024  inline tUIndex& getSize() {
1025  return mSize;
1026  };
1027 
1028 
1029 
1030  // -------------
1031  // PRINT Methods
1032  // -------------
1033 public:
1037  virtual tString toString() const;
1038 
1039 
1040 
1041 };
1042 
1043 #include "CORE_Array.hpp"
1044 
1046 
1049 
1053 
1056 
1059 
1062 
1066 
1068 
1069 
1077 
1078 
1080 
1083 
1087 
1090 
1093 
1096 
1100 
1102 
1110 
1111 
1113 
1116 
1120 
1123 
1126 
1129 
1133 
1135 
1143 
1144 
1145 #endif
CORE_Array< T > & operator-=(const Q &f)
This-=f.
Definition: CORE_Array.h:222
T & operator[](const tUIndex &i)
get the i-th element Assert in (i>-1) Assert in (i<size());
Definition: CORE_Array.h:175
void add(const CORE_Array< Q > &Y)
This+=Y.
Definition: CORE_Array.h:661
void copy(const CORE_Array< Q > *f)
copy the array of the pointer
Definition: CORE_Array.h:283
const tUIndex & getSize() const
return the size of the array for reading
Definition: CORE_Array.h:1018
void desallocate()
desallocate the memory
Definition: CORE_Array.hpp:52
virtual void clear()
clear the array : desallocate the array
Definition: CORE_Array.h:300
void getSharedPointer(boost::shared_ptr< CORE_Array< T > > &p)
return the shared pointer corresponding to the class with casting
Definition: CORE_Array.h:86
void initArray(const vector< Q > &B)
init array to vector B
Definition: CORE_Array.h:342
virtual ~CORE_Array()
destroy an array of T*
Definition: CORE_Array.h:74
tString getTypeToString() const
get the type name of the array
Definition: CORE_Array.h:570
void reserve(const tUIndex &cap)
reserve the capacity
Definition: CORE_Array.h:147
static boost::shared_ptr< CORE_Array< T > > New()
return a CORE_Array shared pointer
Definition: CORE_Array.h:120
CORE_Array< tDouble > CORE_DoubleArray
Definition: CORE_Array.h:1064
tBoolean mIsPrivateAllocated
Definition: CORE_Array.h:34
void sub(const CORE_Array< Q > &Y)
This-=Y.
Definition: CORE_Array.h:692
CORE_Array< tUIndex > CORE_UIndexArray
Definition: CORE_Array.h:1073
CORE_Array(const CORE_Array< T > &c)
build an array by a copy of c
Definition: CORE_Array.h:50
CORE_Array(const tUIndex &n)
build an array of size n
Definition: CORE_Array.h:60
CORE_Array< tUInt > CORE_UIntArray
Definition: CORE_Array.h:1055
CORE_Array< tSInt > CORE_SIntArray
Definition: CORE_Array.h:1051
T * getValues()
get the values of the array for writing
Definition: CORE_Array.h:937
void initArray(const tString &values)
init array to values
Definition: CORE_Array.h:393
CORE_Array< tLDouble > CORE_LDoubleArray
Definition: CORE_Array.h:1065
CORE_Array< tFloat > CORE_FloatArray
Definition: CORE_Array.h:1063
virtual tString toString() const
turn the array into string
Definition: CORE_Array.hpp:301
const T & getLastElement() const
get last element for reading
Definition: CORE_Array.h:914
boost::shared_ptr< CORE_Array< T > > getThis()
return the shared pointer this
Definition: CORE_Array.h:101
#define tUSInt
Definition: types.h:28
T & getValue(const tUIndex &i)
get the values of the array for writing
Definition: CORE_Array.h:961
#define tBoolean
Definition: types.h:139
tBoolean transfertValuesByReference(CORE_Array< Q > &array)
transfert the values of the array into this
Definition: CORE_Array.h:424
void sub(const tReal &alpha, const CORE_Array< Q > &Y)
This-=alpha.Y.
Definition: CORE_Array.h:685
void add(const tReal &alpha, const CORE_Array< Q > &Y)
This+=alpha.Y.
Definition: CORE_Array.h:635
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
void reverse()
reverse the array in [0;mSize[
Definition: CORE_Array.h:974
tBoolean setValuesByReference(const tUIndex &n, Q *array)
set the the values by reference
Definition: CORE_Array.h:405
boost::shared_ptr< const CORE_Array< T > > getThis() const
return the shared pointer this
Definition: CORE_Array.h:108
void setValues(const CORE_Array< Q > &v)
copy the the values of v t o this
Definition: CORE_Array.h:488
tUIndex & getSize()
return the size of the array for writing
Definition: CORE_Array.h:1024
void swap(CORE_Array< T > &f)
swap the tow arrays param[in,out] f : the array to swap with
Definition: CORE_Array.h:992
const T & operator[](const tUIndex &i) const
get the i-th element Assert in (i>-1) Assert in (i<size());
Definition: CORE_Array.h:164
void multiply(const CORE_Array< Q > &Y)
This[i]*=Y[i].
Definition: CORE_Array.h:717
CORE_Array< tFlag > CORE_FlagArray
Definition: CORE_Array.h:1070
tUIndex mSize
Definition: CORE_Array.h:27
void setValues(const vector< Q > &v)
set the values of the array by copying the vector
Definition: CORE_Array.h:468
CORE_Array< tDComplex > CORE_DoubleComplexArray
Definition: CORE_Array.h:1067
CORE_Array< T > & operator/=(const Q &f)
This/=f.
Definition: CORE_Array.h:253
CORE_Array< T > & operator=(const Q &f)
operator =
Definition: CORE_Array.h:191
void allocate(const tUIndex &cap)
allocate the memory if the array
Definition: CORE_Array.hpp:64
CORE_Array< tUInteger > CORE_UIntegerArray
Definition: CORE_Array.h:1072
CORE_Array< tUChar > CORE_UCharArray
Definition: CORE_Array.h:1048
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
CORE_Array< tUSInt > CORE_USIntArray
Definition: CORE_Array.h:1052
CORE_Array< tReal > CORE_RealArray
Definition: CORE_Array.h:1075
tReal norm() const
get the norm
Definition: CORE_Array.h:808
CORE_Array< tBoolean > CORE_BooleanArray
Definition: CORE_Array.h:1045
T & getLastElement()
get last element for writing
Definition: CORE_Array.h:921
tReal distanceMax(const CORE_Array< Q > &y, tUIndex &k) const
return the max of distance
Definition: CORE_Array.h:843
CORE_Array< tSInt > CORE_ShortArray
Definition: CORE_Array.h:1050
this class describes an array
Definition: CORE_Array.h:19
CORE_Array< tChar > CORE_CharArray
Definition: CORE_Array.h:1047
const T * getValues() const
get the values of the array for reading
Definition: CORE_Array.h:930
virtual void fitToSize()
fit the array alocation exactly to size fit the allocation of the array to its size ...
Definition: CORE_Array.hpp:128
tReal norm2() const
get the squared norm
Definition: CORE_Array.h:758
void getSharedPointer(SP::CORE_Object &p)
get the shared pointer of this class into p
Definition: CORE_Object.h:97
tReal distanceMax(const CORE_Array< Q > &y) const
return the max of distance
Definition: CORE_Array.h:894
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: CORE_Array.h:545
void add(const tReal &alpha, const CORE_Array< Q > &Y, const tReal &beta)
This=alpha.Y+beta.This.
Definition: CORE_Array.h:582
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
CORE_Array()
build an array of T*
Definition: CORE_Array.h:41
#define tUIndex
Definition: types.h:126
tReal distance(const CORE_Array< Q > &y) const
get the distance
Definition: CORE_Array.h:902
TYPEDEF_SPTR(CORE_BooleanArray)
tUIndex mCapacity
Definition: CORE_Array.h:30
CORE_Array< tInteger > CORE_IntegerArray
Definition: CORE_Array.h:1071
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
void getSharedPointer(boost::shared_ptr< const CORE_Array< T > > &p) const
return the shared pointer corresponding to the class whith casting
Definition: CORE_Array.h:93
CORE_Array< tLInt > CORE_LIntArray
Definition: CORE_Array.h:1057
T * mValues
Definition: CORE_Array.h:24
T * getValues(tUIndex &n)
get the values of the array for writing
Definition: CORE_Array.h:953
void initArray(const tUIndex &from, const tUIndex &to, const tUIndex &p, const Q B[])
init array to vector B with p-dimension
Definition: CORE_Array.h:376
tReal dot(const CORE_Array< Q > &y) const
return s=<x,y>
Definition: CORE_Array.h:784
tReal sum() const
get the sum of all the element
Definition: CORE_Array.h:770
const T * getValues(tUIndex &n) const
get the values of the array for reading
Definition: CORE_Array.h:944
CORE_Array< tComplex > CORE_ComplexArray
Definition: CORE_Array.h:1076
CORE_Array< T > & operator+=(const Q &f)
This+=f.
Definition: CORE_Array.h:207
void setValue(const tUIndex &i, const T &v)
set the value of the array at index i
Definition: CORE_Array.h:496
#define tULLInt
Definition: types.h:45
CORE_Array< tIndex > CORE_IndexArray
Definition: CORE_Array.h:1074
TYPEDEF_SVPTR(CORE_BooleanArray)
CORE_Array< T > & operator*=(const Q &f)
This*=f.
Definition: CORE_Array.h:237
#define tReal
Definition: types.h:118
tReal max(tUIndex &k) const
get the absolute mximum value of this
Definition: CORE_Array.h:740
CORE_Array< tLLInt > CORE_LLIntArray
Definition: CORE_Array.h:1060
CORE_Array< tInt > CORE_IntArray
Definition: CORE_Array.h:1054
CORE_Array< tULInt > CORE_ULIntArray
Definition: CORE_Array.h:1058
const tUIndex & getCapacity() const
get the capacity
Definition: CORE_Array.h:1012
tReal distance2(const CORE_Array< Q > &y) const
return distance squared
Definition: CORE_Array.h:817
void initArray(const Q &f)
init the array to uniform value
Definition: CORE_Array.h:316
void copy(const CORE_Array< Q > &f)
copy the array
Definition: CORE_Array.hpp:16
const T & getValue(const tUIndex &i) const
get the values of the array for reading
Definition: CORE_Array.h:968
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
CORE_Array< tULLInt > CORE_ULLIntArray
Definition: CORE_Array.h:1061