45 mIsPrivateAllocated=
false;
54 mIsPrivateAllocated=
false;
64 mIsPrivateAllocated=
false;
96 p=boost::dynamic_pointer_cast<
const CORE_Array<T> >(r);
101 inline boost::shared_ptr<CORE_Array<T> >
getThis() {
102 boost::shared_ptr<CORE_Array<T> > p;
108 inline boost::shared_ptr<const CORE_Array<T> >
getThis()
const {
109 boost::shared_ptr<const CORE_Array<T> > p;
120 static inline boost::shared_ptr<CORE_Array<T> >
New() {
121 boost::shared_ptr<CORE_Array<T> > p(
new CORE_Array<T>(),
210 for (i=0;i<
mSize;i++) {
225 for (i=0;i<
mSize;i++) {
240 for (i=0;i<
mSize;i++) {
254 if (f==0)
throw CORE_Exception(
"common/core",
"CORE_Array/=",
"division by 0");
257 for (i=0;i<
mSize;i++) {
305 mIsPrivateAllocated=
false;
317 if (mSize==0)
return;
318 if ( fabs((T)f) <=CORE_Object::getEpsilon<T>()) {
319 memset(mValues,0,mSize*
sizeof(*mValues));
407 if (
sizeof(T)!=
sizeof(Q))
return false;
413 mIsPrivateAllocated=
false;
426 if (
sizeof(T)!=
sizeof(Q))
return false;
434 mIsPrivateAllocated=
true;
451 if (
sizeof(T)==
sizeof(Q)) {
453 memcpy(Ts,v,n*
sizeof(T));
473 typename vector<Q>::const_iterator cv=v.begin();
504 inline void set(
const tUIndex& i,
const T& v) {
529 (*Ts)=(T) (alpha * (*Ys) );
547 return (mIsPrivateAllocated)?0:mSize*
sizeof(T);
571 return CORE_Object::getTypeName<T>();
615 if (mSize==0)
return;
618 if (q>mSize) q=
mSize;
620 for (j=0;j<
mSize;j+=q) {
623 (*Ts)=(*Ts)*beta+((T) (alpha*(*Ys)));
636 if (alpha==0)
return;
643 if (mSize==0)
return;
646 if (q>mSize) q=
mSize;
648 for (j=0;j<
mSize;j+=q) {
651 (*Ts)+=(T) (alpha*(*Ys));
664 if (mSize==0)
return;
667 if (q>mSize) q=
mSize;
669 for (j=0;j<
mSize;j+=q) {
696 if (mSize==0)
return;
699 if (q>mSize) q=
mSize;
702 for (i=0;i<
mSize;i+=q) {
721 if (mSize==0)
return;
724 if (q>mSize) q=
mSize;
727 for (i=0;i<
mSize;i+=q) {
744 const T* p=&mValues[0];
760 const T* p=&mValues[0];
762 s+=(
tReal)((*p)*(*p));
772 const T* p=&mValues[0];
794 const T* px=&mValues[0];
797 for (i=0;i<
mSize;i++) {
809 return sqrt(
norm2());
821 if (mSize==0)
return y.
norm2();
822 if (q==0)
return norm2();
823 const T* px=&mValues[0];
825 if (q>mSize) q=
mSize;
826 for (i=0;i<
mSize;i+=q) {
853 if (mSize==0)
return y.
max(k);
856 if (q==0)
return max(k);
866 if (q>mSize) q=
mSize;
868 for (i=0;i<
mSize;i+=q) {
915 if (mSize==0)
throw CORE_Exception(
"common/core",
"CORE_Array::getLastElement()",
"no element in array");
916 return mValues[mSize-1];
922 if (mSize==0)
throw CORE_Exception(
"common/core",
"CORE_Array::getLastElement()",
"no element in array");
923 return mValues[mSize-1];
979 T* vf=&mValues[mSize-1];
992 inline void swap(CORE_Array<T>& f) {
998 "CORE_Array::swap()",
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