51 mIsVectorReference=
false;
66 if (!mIsVectorReference) {
98 inline boost::shared_ptr<LAP_Vector<T> > getThis() {
99 boost::shared_ptr<LAP_Vector<T> > p;
105 inline boost::shared_ptr<const LAP_Vector<T> > getThis()
const {
106 boost::shared_ptr<const LAP_Vector<T> > p;
166 inline void sub(
const T& s) {
190 *ts=(T) 1./((*ts)*(*ts));
195 *ts=(T) ((*ts)*(*ts));
212 "incompatible vector dimension");
229 "incompatible vector dimension");
250 virtual void copy(
const vector<T>& s) {
264 mIsVectorReference=isReferenced;
280 mIsVectorReference=isReferenced;
306 }
catch (std::exception e) {
307 throw LAP_Exception(
"math/linalg/core",
"LAP_Vector<T>::setValues()",
310 if (mValues==
null)
throw LAP_Exception(
"math/linalg/core",
"LAP_Vector<T>::setValues()",
314 T *pValues=&mValues[0];
324 mIsVectorReference=
false;
336 return setView(v->getStart(),v->getEnd(),v->getIncrement());
343 if (increment==0)
return false;
344 if (end<start)
return false;
345 if (end-increment>=mCapacity)
return false;
346 mView.
setView(start,end,increment);
380 newVector=
new T[n+1];
381 if (newVector==
null)
throw LAP_Exception(
"math/linalg/core",
"LAP_Vector<T>::resize()",
383 }
catch(std::exception e) {
384 throw LAP_Exception(
"math/linalg/core",
"LAP_Vector<T>::resize()",
395 for (k=0;k<dim;k++) {
396 newVector[k]=mValues[i];
399 for (i=dim;i<=n;i++) {
407 mIsVectorReference=
false;
427 for (i=mView.
getStart();i<n;i+=inc) (*
this)[i]=v;
440 int nElementsToErase=n;
441 int maxElementsToErase=s-index;
442 if ( ((
int)n)>maxElementsToErase) nElementsToErase=maxElementsToErase;
443 if (nElementsToErase==0)
return;
458 while (i1<mCapacity) {
555 const T *ptr_x=&x(0);
557 for (i=0;i<dim;i++) {
558 *ptr_y=(*ptr_x>*ptr_y)?*ptr_x:*ptr_y;
621 if (order==DESCENT) {
tLVectorIndex getCapacity() const
get the capacity
Definition: LAP_Vector.h:524
this class describes the exceptions raised for LAP package
Definition: LAP_Exception.h:14
tBoolean setView(SP::LAP_View v)
set the view
Definition: LAP_Vector.h:335
void setIsValuesReferenced(const tBoolean &isReferenced)
deferenced the values the values is unreferenced : so it is not destroyed with this class is desctroy...
Definition: LAP_Vector.h:263
This class is a view of a pointer.
Definition: LAP_View.h:14
static const tFlag DESCENT
Definition: LAP_Vector.h:22
const T & operator()(const tLVectorIndex &i) const
get the value for reading only
Definition: LAP_Vector.h:144
void sub(const T &s)
sub operator
Definition: LAP_Vector.h:166
const tLVectorIndex & getStart() const
get the start of the vector
Definition: LAP_Vector.h:534
static void max(const LAP_Vector< T > &x, LAP_Vector< T > &y)
y=max(x,y);
Definition: LAP_Vector.h:543
const T & operator[](const tLVectorIndex &i) const
get the value for reading only
Definition: LAP_Vector.h:118
void set(const tLVectorIndex &i, const T &v)
set element at index i taking into account the view
Definition: LAP_Vector.h:472
T sum() const
compute the sum of the elements
Definition: LAP_Vector.hpp:170
T maxValue(tLVectorIndex &i) const
return the max value of the vector and the corresponding index
Definition: LAP_Vector.hpp:15
#define tBoolean
Definition: types.h:48
T & operator[](const tLVectorIndex &i)
get the value for reading & writing
Definition: LAP_Vector.h:127
void fit()
fit the vector
Definition: LAP_Vector.h:417
const tLVectorIndex & getStart() const
get the start index of the first element in [start,end[
Definition: LAP_View.h:130
void setView(const tLVectorIndex &start, const tLVectorIndex &end, const tLVectorIndex &inc)
set the the view the element considered are in [start,end[ with increment inc
Definition: LAP_View.h:88
#define null
Definition: types.h:13
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
virtual void add(const tLVectorIndex &i, const T &v)
add v to element at index i taking into account the view
Definition: LAP_Vector.h:479
void max(LAP_Vector< T > &y)
y=max(this,y);
Definition: LAP_Vector.h:566
virtual T * getValues()
get the values for writing
Definition: LAP_Vector.h:503
const tLVectorIncrement & getIncrement() const
get increment
Definition: LAP_View.h:125
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_Vector.h:519
tReal distance2(const LAP_Vector< T > &a) const
compute the distance between this and a
Definition: LAP_Vector.h:583
void getSharedPointer(boost::shared_ptr< const LAP_Vector< T > > &p) const
return the shared pointer corresponding to the class whith casting
Definition: LAP_Vector.h:90
void merge(const T &alpha, const LAP_Vector< T > &x, const T &beta, const LAP_Vector< T > &y)
this is the merging of 2 vectors This = [alpha.x,beta.y]
Definition: LAP_Vector.hpp:96
This class is the base class of all lapack objects.
Definition: LAP_Object.h:17
virtual const T * getValues() const
get the values for reading
Definition: LAP_Vector.h:497
void quickSort()
quit sort the vector in an increasing order
Definition: LAP_Vector.hpp:233
this class describes a vector of double
Definition: LAP_Vector.h:16
void power(const T &s)
power operator
Definition: LAP_Vector.h:178
void reset()
reset
Definition: LAP_View.h:114
T & operator()(const tLVectorIndex &i)
get the value for reading & writing
Definition: LAP_Vector.h:138
void getSharedPointer(SP::CORE_Object &p)
get the shared pointer of this class into p
Definition: CORE_Object.h:65
virtual tLVectorIndex getNullValuesNumber(const tReal &eps) const =0
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:142
virtual void copy(const vector< T > &s)
copy the vector
Definition: LAP_Vector.h:250
LAP_Vector()
build a vector
Definition: LAP_Vector.h:48
LAP_Vector< T > & divideBy(const LAP_Vector< T > &s)
division elementt by elementt vector operator
Definition: LAP_Vector.h:225
#define tLVectorIndex
Definition: lapack_types.h:13
void sort()
sort in ascent order view untaken into account
Definition: LAP_Vector.h:614
void setValues(const tLVectorIndex &n, const tLVectorIncrement &incv, const T *values)
copy the values
Definition: LAP_Vector.h:299
tLVectorIndex indexMin() const
retun the index min of th evector
Definition: LAP_Vector.hpp:56
void multiplyBy(const LAP_Vector< T > &s)
multiplication element by element vector operator
Definition: LAP_Vector.h:208
void setValues(const tLVectorIndex &n, const T *values)
copy the values
Definition: LAP_Vector.h:289
void add(const T &s)
add operator
Definition: LAP_Vector.h:154
tBoolean compare(const T &a, const T &b, const tFlag &order)
compare
Definition: LAP_Vector.h:620
tBoolean setView(const tLVectorIndex &start, const tLVectorIndex &end, const tLVectorIndex &increment)
set the view of the vector
Definition: LAP_Vector.h:342
virtual ~LAP_Vector()
destroy a vector
Definition: LAP_Vector.h:60
void init(const T &v)
init the value to v from the view
Definition: LAP_Vector.h:423
static const tFlag ASCENT
Definition: LAP_Vector.h:21
void setValues(const tLVectorIndex &n, T *&values, const tBoolean &isReferenced)
Definition: LAP_Vector.h:270
#define tLVectorIncrement
Definition: lapack_types.h:16
T minValue(tLVectorIndex &i) const
return the min value of the vector and the corresponding index
Definition: LAP_Vector.hpp:35
void getSharedPointer(boost::shared_ptr< LAP_Vector< T > > &p)
return the shared pointer corresponding to the class with casting
Definition: LAP_Vector.h:83
const tLVectorIndex & getEnd() const
get the end index of the last element in [start,end[
Definition: LAP_View.h:135
#define tReal
Definition: types.h:18
tLVectorIndex getSize() const
Definition: LAP_View.h:141
void removeValues(const tLVectorIndex &index, const tLVectorIndex &n)
remove n values of the array from index if values=[0,1,...,index,...index+n,index+n+,....,size[ the values {index,...index+n-1} are removed values becomes values=[0,...index-1,index+n,...,size-n[
Definition: LAP_Vector.h:435
void resetView()
set the view of the vector to all the values
Definition: LAP_Vector.h:352
void setSize(const tLVectorIndex &n)
set the view to [0,n[ by 1 increment if values is too small, re-alocate it
Definition: LAP_Vector.h:360
void reverse()
reverse the vector
Definition: LAP_Vector.hpp:270
#define tFlag
Definition: types.h:14