RVector. More...

#include <rvector.h>

Inheritance diagram for RVector:
[legend]
Collaboration diagram for RVector:
[legend]

Public Member Functions

int Compare (const RVector &vector) const
 
RNumCursor< double > GetCols (size_t min=0, size_t max=SIZE_MAX) const
 
size_t GetNb (void) const
 
virtual void Init (double val=0.0)
 
bool IsIn (double value) const
 
bool IsSame (const RVector &vector) const
 
RVectoroperator*= (const double arg)
 
RVectoroperator+= (const RVector &vector)
 
RVectoroperator-= (const RVector &vector)
 
RVectoroperator/= (const double arg)
 
RVectoroperator= (const RVector &src)
 
double operator[] (size_t i) const
 
double & operator[] (size_t i)
 
template<class S >
void Print (S &stream, const RString &name, const char *format="%E", size_t colsize=12) const
 
void Randomize (RRandom *rand, size_t nb=0)
 
void ReOrder (void)
 
void ReSize (size_t size, double val=0.0)
 
 RVector (size_t size)
 
 RVector (const RVector &vector)
 
virtual ~RVector (void)
 

Additional Inherited Members

- Private Member Functions inherited from RNumContainer< double, false >
RNumContainer< double, false > & Add (const RNumContainer< double, bOrder1 > &src)
 
void Clear (void)
 
int Compare (const RNumContainer< double, false > &) const
 
void Delete (doubledel)
 
void DeleteAt (size_t pos, bool shift=true)
 
size_t GetIndex (doublenb, bool &find) const
 
const double * GetList (void) const
 
size_t GetNb (void) const
 
void Init (size_t nb, doubleval)
 
size_t Insert (doubleins)
 
void InsertAt (doubleins, size_t pos, bool replace=false)
 
void Inter (const RNumContainer< double, bOrder1 > &src1, const RNumContainer< double, bOrder2 > &src2)
 
bool IsIn (doublevalue) const
 
bool IsSame (const RNumContainer &vi) const
 
RNumContaineroperator= (const RNumContainer< double, bOrder1 > &src)
 
double operator[] (size_t i) const
 
double & operator[] (size_t i)
 
void Randomize (RRandom *rand, size_t nb=0)
 
void ReOrder (void)
 
 RNumContainer (const RNumContainer &vector)
 
 RNumContainer (size_t max)
 
void Union (const RNumContainer< double, bOrder1 > &src1, const RNumContainer< double, bOrder2 > &src2)
 
void Verify (size_t max)
 
 ~RNumContainer (void)
 
- Private Attributes inherited from RNumContainer< double, false >
double * List
 
size_t MaxInt
 
size_t NbInt
 

Detailed Description

RVector.

The RVector class provides a representation for a vector. It is a specialized class inheriting from RNumContainer since a vector is supposed to have a fixed size.

Constructor & Destructor Documentation

RVector ( size_t  size)

Construct a vector.

Parameters
sizeSize of the vector.
RVector ( const RVector vector)

Copy constructor.

Parameters
vectorVector to copy.
virtual ~RVector ( void  )
virtual

Destruct the vector.

Member Function Documentation

int Compare ( const RVector vector) const

Compare method used by RContainer.

Parameters
vectorVector to compare with.
Returns
always -1.
virtual void Init ( double  val = 0.0)
virtual

Initialize all the elements of the vector to a given value.

Parameters
valValue to assign.
void ReSize ( size_t  size,
double  val = 0.0 
)

Resize the size of the vector. If the new size is smaller than the old one, the unused memory space is only released when the vector is destruct,

Parameters
sizeSize of the vector.
valValue to assign to the new elements created.
bool IsSame ( const RVector vector) const

Test if two vectors have exactly the same values.

Parameters
vectorVector used for the comparison.
Returns
True if the vectors are the same.
bool IsIn ( double  value) const

Verify if a value is in the vector.

Parameters
valueValue to test.
Returns
True if the value is in the vector, false else.
void ReOrder ( void  )

Reorder the vector in ascending order.

void Randomize ( RRandom rand,
size_t  nb = 0 
)

Randomize the vector.

Parameters
randRandom number generator to use.
nbNumber of first element to randomize. If null, all values are randomized.
RVector& operator= ( const RVector src)

Assignment operator.

Parameters
srcVector used for the assignment.
RNumCursor<double> GetCols ( size_t  min = 0,
size_t  max = SIZE_MAX 
) const

Get the values corresponding to the vector.

Parameters
minMinimum position of the elements to iterate.
maxMaximum position of the elements to iterate (max included). If SIZE_MAX, iterate until the end of the container.
Returns
Cursor over the numbers.
double operator[] ( size_t  i) const

Return the value at position i. The first value is at position 0.

Parameters
iIndex.
double& operator[] ( size_t  i)

Return the value at position i. The first value is at position 0.

Parameters
iIndex.
size_t GetNb ( void  ) const

Get the number of values in the list.

Returns
size_t
RVector& operator+= ( const RVector vector)

Add a vector to the current one.

Parameters
vectorVector to add.
RVector& operator-= ( const RVector vector)

Subtract a vector from the current one.

Parameters
vectorVector to subtract.
RVector& operator*= ( const double  arg)

Multiply a vector with a given number.

Parameters
argNumber.
RVector& operator/= ( const double  arg)

Divide a vector with a given number.

Parameters
argNumber.
void Print ( S &  stream,
const RString name,
const char *  format = "%E",
size_t  colsize = 12 
) const

Print the content of the vector.

Template Parameters
SStream class that implements the << operator.
Parameters
streamStream.
nameName of the vector.
formatFormat used to print the number. By default, it is "%E".
colsizeSize of a column. By default, it is 12.