Class BlockVector¶
Defined in Program listing for file kernel/src/utils/SiconosAlgebra/BlockVector.hpp
-
class BlockVector¶
“Block” vector : container (list) of SiconosVector
A block vector is a stl vector that handles pointers to SiconosVector.
Insertion of nullptr SP::SiconosVector is not allowed.
Public Functions
-
BlockVector()¶
default contructor
-
BlockVector(const BlockVector &v)¶
copy contructor
- Parameters
v – BlockVector&
-
BlockVector(SP::SiconosVector v1, SP::SiconosVector v2)¶
contructor with 2 SiconosVectors
- Parameters
v1 – first vector
v2 – second vector
-
BlockVector(unsigned int numberOfBlocks, unsigned int dim)¶
contructor with a BlockVector of n (numberOfBlocks) blocks of the same size (dim) filled with a new vector
- Parameters
numberOfBlocks – number of blocks
dim – dimension of the vector
-
BlockVector(unsigned int numberOfBlocks)¶
contructor with a BlockVector of n (numberOfBlocks) blocks that point on nullptr
- Parameters
numberOfBlocks – number of blocks
-
inline ~BlockVector()¶
destructor
-
void setBlock(const SiconosVector &input, unsigned int size_block, unsigned int start_in, unsigned int start_out)¶
Set a subblock of the current vector with the content (copy) of a SiconosVector.
- Parameters
input – the vector to be copied
size_block – size of the block to be copied
start_in – starting position in input vector of the block to be copied
start_out – starting position in current vector of the block to be filled in.
-
inline unsigned int size() const¶
- Returns
the size of the vector (sum of the sizes of all its blocks)
-
inline VectorOfVectors::iterator begin()¶
- Returns
an iterator pointing to the first block in the container.
-
inline VectorOfVectors::iterator end()¶
- Returns
an iterator referring to the past-the-end element in the container.
-
inline VectorOfVectors::const_iterator begin() const¶
- Returns
an iterator pointing to the first block in the container.
-
inline VectorOfVectors::const_iterator end() const¶
- Returns
an iterator referring to the past-the-end element in the container.
-
inline VectorOfVectors getAllVect() const¶
- Returns
the complete stl container
-
inline Index::size_type numberOfBlocks() const¶
- Returns
the number of SiconosVectors in the container
-
bool isDense() const¶
- Returns
true if all SiconosVector in the container are dense
-
void zero()¶
sets all the values of the vector to 0.0
-
void fill(double a)¶
set all values of the vector component to value.
- Parameters
a – double
-
void display(void) const¶
display data on standard output
-
std::string toString() const¶
put data of the vector into a std::string
- Returns
std::string
-
double getValue(unsigned int i) const¶
Get a component of the vector.
- Parameters
i – index of the required component
- Returns
the component value
-
void setValue(unsigned int i, double value)¶
set a component of the vector
- Parameters
i – index of the required component
value – of the component
-
double &operator()(unsigned int i)¶
get a component of the vector
- Parameters
i – index of the required component
- Returns
value of the component
-
double operator()(unsigned int i) const¶
get a component of the vector
- Parameters
i – index of the required component
- Returns
value of the component
-
inline SP::SiconosVector vector(unsigned int pos)¶
get a block (SiconosVector) of the vector
- Parameters
pos – index of the required block
- Returns
the expected block
-
inline SPC::SiconosVector vector(unsigned int pos) const¶
gets a block (SiconosVector) of the vector
- Parameters
pos – index of the required block
- Returns
the expected block
-
void setVector(unsigned int pos, const SiconosVector &v)¶
set a block with a given vector (copy!)
- Parameters
pos – index of the block to set
v – source vector to be copied at position i
-
void setVectorPtr(unsigned int pos, SP::SiconosVector v)¶
set a block with a given vector (pointer link!)
- Parameters
pos – index of the block to set
v – source vector to be inserted at position i
-
void setAllVect(VectorOfVectors &v)¶
Fill the container with a list of SiconosVector.
Warning: pointer links, no copy
- Parameters
v – the vectors to be inserted
-
unsigned int getNumVectorAtPos(unsigned int pos) const¶
get the number of the vector that handles element at position “pos”
- Parameters
pos – unsigned int, position of the element
- Returns
unsigned int number of the searched vector
-
BlockVector &operator=(const BlockVector &vIn)¶
Assignment operator.
- Parameters
vIn – the vector to be copied
- Returns
-
BlockVector &operator=(const double *data)¶
Assignment operator.
- Parameters
data – data to put in the BlockVector
- Returns
-
BlockVector &operator=(const SiconosVector &vIn)¶
Assignment operator.
- Parameters
vIn – the vector to be copied
- Returns
-
BlockVector &operator-=(const BlockVector &vIn)¶
Subtract in place operator.
- Parameters
vIn – rhs of the operator
- Returns
-
BlockVector &operator+=(const BlockVector&)¶
Add in place operator.
- Parameters
vIn – rhs of the operator
- Returns
-
BlockVector &operator+=(const SiconosVector &vIn)¶
Add in place operator.
- Parameters
vIn – rhs of the operator
- Returns
-
BlockVector &operator-=(const SiconosVector &vIn)¶
Subtract in place operator.
- Parameters
vIn – rhs of the operator
- Returns
-
BlockVector &operator*=(double s)¶
multiply by a scalar, result in place
- Parameters
s – the scalar factor
- Returns
-
BlockVector &operator/=(double s)¶
divide by a scalar, result in place
- Parameters
s – the scalar factor
- Returns
-
void insertPtr(SP::SiconosVector v)¶
Insert a new block (no allocation and nor copy)
- Parameters
v – the vector to be inserted
-
double norm2() const¶
- Returns
the Euclidian norm of the vector
-
double normInf() const¶
- Returns
the infinite norm of the vector
-
SP::SiconosVector prepareVectorForPlugin() const¶
Tranform a BlockVector into a SiconosVector.
Required for plugins, that need contiguous memory for their parameters.
- Returns
a vector (the result depends on the number of blocks in input. 1 block : link to first component of the container, more : copy of all components into a SiconosVector)
Friends
-
friend std::ostream &operator<<(std::ostream &os, const BlockVector &bv)¶
offstream operator
- Parameters
os – An output stream
bv – a BlockVector
- Returns
The same output stream
-
BlockVector()¶