siconos.kernel.SiconosVector (Python class)

class siconos.kernel.SiconosVector(*args)[source]

Bases: object

Vectors of double.

(Interface to various types of Boost-Ublas vectors).

Used to handle vectors of double.

Two possible types: Siconos::DENSE (default) and SPARSE.

You can find an overview on how to build and use vectors and matrices in siconos users’ guide .

Generated class (swig), based on C++ header Program listing for file kernel/src/utils/SiconosAlgebra/SiconosVector.hpp.

Constructors

SiconosVector()

Default constructor.

SiconosVector(row, int type=DENSE)

constructor with the type and the dimension of the Boost vector

Parameters:
  • row – the size of the vector
  • type – the type of vector
SiconosVector(row, double val, int type=DENSE)

constructor with the dimension of the Boost vector, a default value and the type.

Parameters:
  • row – the size of the vector
  • val – value for initiliazing the vector
  • type – the type of vector
SiconosVector(vector< double > vec, int type=DENSE)

constructor with a std::vector of the values and the type of the boost vector.

Parameters:
  • vec – a std::vector<double>
  • type – an Siconos::UBLAS_TYPE
SiconosVector(array_like (np.float64, 1D) v)

copy constructor

Parameters:v – SiconosVector
SiconosVector(BlockVector vIn)
SiconosVector(DenseVect v)

constructor with a DenseVect vector (see SiconosAlgebra.hpp for details)

Parameters:v – a DenseVect
SiconosVector(SparseVect v)

constructor with a SparseVect vector (see SiconosAlgebra.hpp for details)

Parameters:v – a SparseVect
SiconosVector(str filename, bool is_ascii)

constructor with an input file

Parameters:
  • filename – a std::string which contain the file path
  • is_ascii – a boolean to indicate if the file is in ascii
SiconosVector(array_like (np.float64, 1D) v1, array_like (np.float64, 1D) v2)

constructor for the concatenation of two vectors

Parameters:
  • v1 – the first vector
  • v2 – the second vector
addBlock(int i, array_like (np.float64, 1D) v) → None[source]

add the input vector to the elements starting from position i.

Parameters:
  • i – an unsigned int
  • v – a SiconosVector
copyData(array_like (np.float64, 1D)data)[source]

copy the data to double* (dense only)

Parameters:data – the memory where to copy the data
Returns:the number of element written (size of the vector)
dense(int pos=0) → DenseVect *[source]

get a pointer to the ublas embedded vector if it’s type is Dense

Parameters:pos – unsigned int: position of the required vector (useless for SiconosVector, default = 0)
Returns:a DenseVect*
display(None) → None[source]

display data on standard output

exp(array_like (np.float64, 1D) input) → None[source]

component-wise exponential of a vector

Parameters:input – vector such that result (this) = exp(input)
exp_in_place() → None[source]

component-wise exponential of a vector, in-place.

this = exp(this)

fill(double a) → None[source]

set all values of the vector component to input value.

Parameters:a – double
getArray() -> array_like (np.float64, 1D)[source]

return the array of double values of the vector

Returns:a pointer to the array
getDense(int pos=0) → DenseVect[source]

get the ublas embedded vector if it’s type is Dense

Parameters:pos – unsigned int: position of the required vector (useless for SiconosVector, default = 0)
Returns:a DenseVect
getSparse(int pos=0) → SparseVect[source]

get the ublas embedded vector if it’s type is Sparse

Parameters:pos – unsigned int: position of the required vector (useless for SiconosVector, default = 0)
Returns:a SparseVect
getValue(int i) → double[source]

get the element at position i in the vector

Parameters:i – an unsigned int
Returns:a double
isBlock() → bool[source]

true if the vector is block else false.

Returns:a bool.
norm2() → double[source]

return the Euclidian norm of the vector

Returns:a double
normInf() → double[source]

compute the infinite norm of the vector

Returns:a double
num() → int[source]

Get the type number of the current vector.

Returns:an unsigned int
resize(int nbcol, bool preserve=True) → None[source]

resize the vector with nbcol columns.

The existing elements of the matrix are preseved when specified.

Parameters:
  • nbcol
  • preserve
  • Exceptions
  • ----------
  • SiconosVectorException
setValue(int i, double value) → None[source]

set the element at position i in the vector.

Parameters:
  • i – an unsigned int
  • value
setVector(int num, array_like (np.float64, 1D) v) → None[source]

set SiconosVector number i (copy) with v (second arg) - Useful only for BlockVector (else equivalent to a single copy)

Parameters:
  • num – unsigned int: block number (0 for SiconosVector)
  • v – a SiconosVector
setVectorPtr(int num, array_like (np.float64, 1D) v) → None[source]

set SiconosVector number i (pointer link) with v (second arg) - Useful only for BlockVector

Parameters:
  • num – unsigned int: block number (0 for SiconosVector)
  • v – a pointer to a SiconosVector
size() → int[source]

get the vector size, ie the total number of (double) elements in the vector

Returns:unsigned int
sparse(int pos=0) → SparseVect *[source]

get a pointer to the ublas embedded vector if it’s type is Sparse

Parameters:pos – unsigned int: position of the required vector (useless for SiconosVector, default = 0)
Returns:a SparseVect*
subBlock(int i, array_like (np.float64, 1D) v) → None[source]

subtract the input vector to the elements starting from position i.

Parameters:
  • i – an unsigned int i
  • v – a SiconosVector
toBlock(array_like (np.float64, 1D) vOut, int sizeB, int startIn, int startOut) → None[source]

copy a part of the vector into another (usefull for converting a SiconosVector into a BlockVector

Parameters:
  • vOut
  • sizeB
  • startIn
  • startOut
toString() → str[source]

put data of the vector into a std::string

Returns:std::string
vector(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

vector(int pos) -> array_like (np.float64, 1D)[source]

return the current object.

This function is really useful only for block vector

Returns:a pointer to a SiconosVector
Parameters:pos
vector(int pos) -> SPC::array_like (np.float64, 1D)[source]

return the current object.

This function is really useful only for block vector

Parameters:pos
Returns:a pointer to a SiconosVector
vector_sum() → double[source]

return the sum of all elements of the vector

Returns:a double
zero() → None[source]

sets all the values of the vector to 0.0