Using vectors in TiPi

This section describes the objects used in TiPi to store the variables (but also the data and their weights) of an optimization problem.

Operations involving vector spaces

Vectors can be created by their vector space with either undefined contents of with their components set to given values. For instance, to create a new vector of the vector space vsp:

vsp.create()    // yields a new vector with undefined contents
vsp.create(val) // yields a new vector with all components set to `val`
vsp.one()       // is equivalent to space.create(1)
vsp.zero()      // is equivalent to space.create(0)

To check whether a vector vec belongs to the vector space vsp, the following expressions can be used:

vsp.owns(vec)
vec.belongsTo(vsp)
vec.getOwner() == vsp

The call:

vsp.check(vec)

checks whether vector vec belongs to the vector space vsp and throws an IncorrectSpaceException exception otherwise.

Methods implemented by vectors

Many methods are available to directly manipulate vectors. These methods are sufficient to implement the iterative optimization algorithms provided by TiPi.

The following methods are assumed to be efficient:

Various linear combination of vectors can be formed:

The above methods manipulate vectors globally are supposed to be efficient. Two methods are provided to examine or set individually the components of a vector. These methods are mainly used for debugging or informative purposes and are not meant to be efficient (although it does not hurt if they are!).

where index i is an integer between 0 for the first component and n - 1 for the last component (n being the number of components of the vector).