Scippy

SoPlex

Sequential object-oriented simPlex

SSVectorBase< R > Class Template Reference

Semi sparse vector.This class implements semi-sparse vectors. Such are DVectorBases where the indices of its nonzero elements can be stored in an extra IdxSet. Only elements with absolute value > epsilon are considered to be nonzero. Since really storing the nonzeros is not always convenient, an SSVectorBase provides two different stati: setup and not setup. An SSVectorBase being setup means that the nonzero indices are available, otherwise an SSVectorBase is just an ordinary DVectorBase with an empty IdxSet. Note that due to arithmetic operation, zeros can slip in, i.e., it is only guaranteed that at least every non-zero is in the IdxSet. More...

#include <ssvectorbase.h>

Inheritance diagram for SSVectorBase< R >:

Public Member Functions

Status of an SSVectorBase

An SSVectorBase can be set up or not. In case it is set up, its IdxSet correctly contains all indices of nonzero elements of the SSVectorBase. Otherwise, it does not contain any useful data. Whether or not an SSVectorBase is setup can be determined with the method isSetup().

There are three methods for directly affecting the setup status of an SSVectorBase:

  • unSetup(): This method sets the status to ``not setup''.
  • forceSetup(): This method sets the status to ``setup'' without verifying that the IdxSet correctly contains all nonzero indices. It may be used when the nonzero indices have been computed externally.
R * get_ptr ()
 Only used in slufactor.cpp.
 
getEpsilon () const
 Returns the non-zero epsilon used.
 
void setEpsilon (R eps)
 Changes the non-zero epsilon, invalidating the setup. */.
 
bool isSetup () const
 Returns setup status.
 
void unSetup ()
 Makes SSVectorBase not setup.
 
void setup ()
 Initializes nonzero indices for elements with absolute values above epsilon and sets all other elements to 0.
 
void forceSetup ()
 Forces setup status.
 
Methods for setup SSVectorBases
int index (int n) const
 Returns index of the n 'th nonzero element.
 
value (int n) const
 Returns value of the n 'th nonzero element.
 
int number (int i) const
 Returns the position number of index i, or -1 if i doesn't exist.
 
int size () const
 Returns the number of nonzeros.
 
void add (int i, R x)
 Adds nonzero (i, x) to SSVectorBase.
 
void setValue (int i, R x)
 Sets i 'th element to x.
 
void clearIdx (int i)
 Clears element i.
 
void clearNum (int n)
 Sets n 'th nonzero element to 0 (index n must exist).
 
Methods independent of the Status
operator[] (int i) const
 Returns i 'th value.
 
const int * indexMem () const
 Returns array indices.
 
const R * values () const
 Returns array values.
 
const IdxSetindices () const
 Returns indices.
 
int * altIndexMem ()
 Returns array indices.
 
R * altValues ()
 Returns array values.
 
IdxSetaltIndices ()
 Returns indices.
 
Arithmetic operations
template<class S >
SSVectorBase< R > & operator+= (const VectorBase< S > &vec)
 Addition.
 
template<class S >
SSVectorBase< R > & operator+= (const SVectorBase< S > &vec)
 Addition.
 
template<class S >
SSVectorBase< R > & operator+= (const SSVectorBase< S > &vec)
 Addition.
 
template<class S >
SSVectorBase< R > & operator-= (const VectorBase< S > &vec)
 Subtraction.
 
template<class S >
SSVectorBase< R > & operator-= (const SVectorBase< S > &vec)
 Subtraction.
 
template<class S >
SSVectorBase< R > & operator-= (const SSVectorBase< S > &vec)
 Subtraction.
 
template<class S >
SSVectorBase< R > & operator*= (S x)
 Scaling.
 
template<class S >
operator* (const SSVectorBase< S > &w)
 
template<class S , class T >
SSVectorBase< R > & multAdd (S xx, const SVectorBase< T > &vec)
 Addition of a scaled vector.
 
template<class S , class T >
SSVectorBase< R > & multAdd (S x, const VectorBase< T > &vec)
 Addition of a scaled vector.
 
template<class S , class T >
SSVectorBase< R > & assign2product (const SSVectorBase< S > &x, const SVSetBase< T > &A)
 Assigns $x^T \cdot A$ to SSVectorBase.
 
template<class S , class T >
SSVectorBase< R > & assign2product4setup (const SVSetBase< S > &A, const SSVectorBase< T > &x)
 Assigns SSVectorBase to $A \cdot x$ for a setup x.
 
template<class S , class T >
SSVectorBase< R > & assign2productAndSetup (const SVSetBase< S > &A, SSVectorBase< T > &x)
 Assigns SSVectorBase to $A \cdot x$ thereby setting up x.
 
maxAbs () const
 Maximum absolute value, i.e., infinity norm.
 
length2 () const
 Squared euclidian norm.
 
Real length () const
 Floating point approximation of euclidian norm (without any approximation guarantee).
 
Miscellaneous
int dim () const
 Dimension of VectorBase.
 
void reDim (int newdim)
 Resets dimension to newdim.
 
void setSize (int n)
 Sets number of nonzeros (thereby unSetup SSVectorBase).
 
void reMem (int newsize)
 Resets memory consumption to newsize.
 
void clear ()
 Clears vector.
 
bool isConsistent () const
 consistency check.
 
Constructors / Destructors
 SSVectorBase (int p_dim, R p_eps=Param::epsilon())
 Default constructor.
 
template<class S >
 SSVectorBase (const SSVectorBase< S > &vec)
 Copy constructor.
 
 SSVectorBase (const SSVectorBase< R > &vec)
 Copy constructor.
 
template<class S >
 SSVectorBase (const VectorBase< S > &vec, R eps=Param::epsilon())
 Constructs nonsetup copy of vec.
 
template<class S >
void setup_and_assign (SSVectorBase< S > &rhs)
 Sets up rhs vector, and assigns it.
 
template<class S >
SSVectorBase< R > & assign (const SVectorBase< S > &rhs)
 Assigns only the elements of rhs.
 
template<class S >
SSVectorBase< R > & operator= (const SSVectorBase< S > &rhs)
 Assignment operator.
 
SSVectorBase< R > & operator= (const SSVectorBase< R > &rhs)
 Assignment operator.
 
template<class S >
SSVectorBase< R > & operator= (const SVectorBase< S > &rhs)
 Assignment operator.
 
template<class S >
SSVectorBase< R > & operator= (const VectorBase< S > &rhs)
 Assignment operator.
 
 ~SSVectorBase ()
 destructor
 
- Public Member Functions inherited from DVectorBase< R >
template<>
void reSize (int newsize)
 
 DVectorBase (int d=0)
 Default constructor. d is the initial dimension.
 
template<class S >
 DVectorBase (const VectorBase< S > &old)
 Copy constructor.
 
 DVectorBase (const DVectorBase< R > &old)
 Copy constructor.
 
template<class S >
 DVectorBase (const DVectorBase< S > &old)
 Copy constructor.
 
DVectorBase< R > & operator= (const VectorBase< R > &vec)
 Assignment operator.
 
template<class S >
DVectorBase< R > & operator= (const VectorBase< S > &vec)
 Assignment operator.
 
DVectorBase< R > & operator= (const DVectorBase< R > &vec)
 Assignment operator.
 
template<class S >
DVectorBase< R > & operator= (const DVectorBase< S > &vec)
 Assignment operator.
 
template<class S >
DVectorBase< R > & operator= (const SVectorBase< S > &vec)
 Assignment operator.
 
virtual ~DVectorBase ()
 Destructor.
 
int memSize () const
 Returns DVectorBase's memory size.
 
void reDim (int newdim, const bool setZero=true)
 Resets DVectorBase's dimension to newdim.
 
void reSize (int newsize)
 Resets DVectorBase's memory size to newsize.
 
bool isConsistent () const
 Consistency check.
 
- Public Member Functions inherited from VectorBase< R >
 VectorBase (int p_dimen, R *p_val)
 Constructor.
 
template<class S >
VectorBase< R > & operator= (const VectorBase< S > &vec)
 Assignment operator.
 
VectorBase< R > & operator= (const VectorBase< R > &vec)
 Assignment operator.
 
template<class S >
VectorBase< R > & operator= (const SVectorBase< S > &vec)
 Assignment operator.
 
template<class S >
VectorBase< R > & operator= (const SSVectorBase< S > &vec)
 Assignment operator.
 
template<class S >
VectorBase< R > & assign (const SVectorBase< S > &vec)
 Assign values of vec.
 
template<class S >
VectorBase< R > & assign (const SSVectorBase< S > &vec)
 Assign values of vec.
 
void clear ()
 Set vector to 0.
 
template<class S >
VectorBase< R > & operator+= (const VectorBase< S > &vec)
 Addition.
 
template<class S >
VectorBase< R > & operator+= (const SVectorBase< S > &vec)
 Addition.
 
template<class S >
VectorBase< R > & operator+= (const SSVectorBase< S > &vec)
 Addition.
 
template<class S >
VectorBase< R > & operator-= (const VectorBase< S > &vec)
 Subtraction.
 
template<class S >
VectorBase< R > & operator-= (const SVectorBase< S > &vec)
 Subtraction.
 
template<class S >
VectorBase< R > & operator-= (const SSVectorBase< S > &vec)
 Subtraction.
 
template<class S >
VectorBase< R > & operator*= (const S &x)
 Scaling.
 
template<class S >
VectorBase< R > & operator/= (const S &x)
 Division.
 
operator* (const VectorBase< R > &vec) const
 Inner product.
 
operator* (const SVectorBase< R > &vec) const
 Inner product.
 
operator* (const SSVectorBase< R > &vec) const
 Inner product.
 
maxAbs () const
 Maximum absolute value, i.e., infinity norm.
 
minAbs () const
 Minimum absolute value.
 
Real length () const
 Floating point approximation of euclidian norm (without any approximation guarantee).
 
length2 () const
 Squared norm.
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const VectorBase< T > &vec)
 Addition of scaled vector.
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const SVectorBase< T > &vec)
 Addition of scaled vector.
 
template<class S , class T >
VectorBase< R > & multSub (const S &x, const SVectorBase< T > &vec)
 Subtraction of scaled vector.
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const SSVectorBase< T > &vec)
 Addition of scaled vector.
 
R * get_ptr ()
 Conversion to C-style pointer.
 
const R * get_const_ptr () const
 Conversion to C-style pointer.
 
bool isConsistent () const
 Consistency check.
 
int dim () const
 Dimension of vector.
 
R & operator[] (int n)
 Return n 'th value by reference.
 
const R & operator[] (int n) const
 Return n 'th value.
 

Private Member Functions

Private helpers
template<class S , class T >
SSVectorBase< R > & assign2product1 (const SVSetBase< S > &A, const SSVectorBase< T > &x)
 Assignment helper.
 
template<class S , class T >
SSVectorBase< R > & assign2productShort (const SVSetBase< S > &A, const SSVectorBase< T > &x)
 Assignment helper.
 
template<class S , class T >
SSVectorBase< R > & assign2productFull (const SVSetBase< S > &A, const SSVectorBase< T > &x)
 Assignment helper.
 

Friends

class DVectorBase< R >
 
class VectorBase< R >
 
template<class S >
class DSVectorBase
 

Data

bool setupStatus
 Is the SSVectorBase set up?
 
epsilon
 A value x with |x| < epsilon is considered zero.
 
void setMax (int newmax)
 Allocates enough space to accommodate newmax values.
 

Additional Inherited Members

- Protected Member Functions inherited from IdxSet
 IdxSet (int n, int imem[], int l=0)
 constructor.
 
 IdxSet ()
 default constructor.
 
virtual ~IdxSet ()
 destructor.
 
IdxSetoperator= (const IdxSet &set)
 assignment operator.
 
 IdxSet (const IdxSet &)
 copy constructor.
 
int index (int n) const
 access n 'th index.
 
int size () const
 returns the number of used indices.
 
int max () const
 returns the maximal number of indices which can be stored in IdxSet.
 
int dim () const
 returns the maximal index.
 
int number (int i) const
 returns the position number of index i.
 
void add (int n)
 appends n uninitialized indices.
 
void add (const IdxSet &set)
 appends all indices of set.
 
void add (int n, const int i[])
 appends n indices in i.
 
void addIdx (int i)
 appends index i.
 
void remove (int n, int m)
 removes indices at position numbers n through m.
 
void remove (int n)
 removes n 'th index.
 
void clear ()
 removes all indices.
 
bool isConsistent () const
 consistency check.
 
- Protected Attributes inherited from VectorBase< R >
int dimen
 Dimension of vector.
 
R * val
 Values of vector.
 

Detailed Description

template<class R>
class soplex::SSVectorBase< R >

Semi sparse vector.

This class implements semi-sparse vectors. Such are DVectorBases where the indices of its nonzero elements can be stored in an extra IdxSet. Only elements with absolute value > epsilon are considered to be nonzero. Since really storing the nonzeros is not always convenient, an SSVectorBase provides two different stati: setup and not setup. An SSVectorBase being setup means that the nonzero indices are available, otherwise an SSVectorBase is just an ordinary DVectorBase with an empty IdxSet. Note that due to arithmetic operation, zeros can slip in, i.e., it is only guaranteed that at least every non-zero is in the IdxSet.

Definition at line 46 of file ssvectorbase.h.

Constructor & Destructor Documentation

SSVectorBase ( int  p_dim,
p_eps = Param::epsilon() 
)
explicit

Default constructor.

Definition at line 629 of file ssvectorbase.h.

SSVectorBase ( const SSVectorBase< S > &  vec)

Copy constructor.

Definition at line 644 of file ssvectorbase.h.

SSVectorBase ( const SSVectorBase< R > &  vec)

Copy constructor.

The redundancy with the copy constructor below is necessary since otherwise the compiler doesn't realize that it could use the more general one with S = R and generates a shallow copy constructor.

Definition at line 661 of file ssvectorbase.h.

SSVectorBase ( const VectorBase< S > &  vec,
eps = Param::epsilon() 
)
explicit

Constructs nonsetup copy of vec.

Definition at line 676 of file ssvectorbase.h.

destructor

Definition at line 851 of file ssvectorbase.h.

Member Function Documentation

void add ( int  i,
x 
)

Adds nonzero (i, x) to SSVectorBase.

No nonzero with index i must exist in the SSVectorBase.

Definition at line 208 of file ssvectorbase.h.

Referenced by SPxBasis::condition(), and SPxBoundFlippingRT::flipAndUpdate().

IdxSet& altIndices ( )

Returns indices.

Definition at line 314 of file ssvectorbase.h.

SSVectorBase< R > & assign ( const SVectorBase< S > &  rhs)
SSVectorBase< R > & assign2product ( const SSVectorBase< S > &  x,
const SVSetBase< T > &  A 
)

Assigns $x^T \cdot A$ to SSVectorBase.

Definition at line 507 of file basevectors.h.

References soplex::isNotZero(), and SVSetBase< R >::num().

Referenced by SPxSolver::setupPupdate().

SSVectorBase< R > & assign2product1 ( const SVSetBase< S > &  A,
const SSVectorBase< T > &  x 
)
private
SSVectorBase< R > & assign2product4setup ( const SVSetBase< S > &  A,
const SSVectorBase< T > &  x 
)
SSVectorBase< R > & assign2productFull ( const SVSetBase< S > &  A,
const SSVectorBase< T > &  x 
)
private
void clearIdx ( int  i)

Clears element i.

Definition at line 242 of file ssvectorbase.h.

Referenced by SPxFastRT::maxReEnter(), SPxFastRT::minReEnter(), and SPxBoundFlippingRT::selectEnter().

void clearNum ( int  n)

Sets n 'th nonzero element to 0 (index n must exist).

Definition at line 258 of file ssvectorbase.h.

Referenced by SoPlex::_computeInfeasBox(), SPxDefaultRT::selectEnter(), SPxHarrisRT::selectEnter(), SPxHarrisRT::selectLeave(), and SSVectorBase< Real >::setValue().

R getEpsilon ( ) const
const IdxSet& indices ( ) const

Returns indices.

Definition at line 294 of file ssvectorbase.h.

Referenced by UpdateVector::idx(), SPxSolver::perturbMax(), and SPxSolver::perturbMin().

Real length ( ) const

Floating point approximation of euclidian norm (without any approximation guarantee).

Definition at line 520 of file ssvectorbase.h.

Referenced by SPxBasis::condition(), and SPxSolver::leave().

R length2 ( ) const

Squared euclidian norm.

Definition at line 504 of file ssvectorbase.h.

Referenced by SPxDevexPR::left4(), SPxSteepPR::left4(), SSVectorBase< Real >::length(), and SPxSteepPR::selectEnter().

R maxAbs ( ) const

Maximum absolute value, i.e., infinity norm.

Definition at line 483 of file ssvectorbase.h.

SSVectorBase< R > & multAdd ( xx,
const SVectorBase< T > &  vec 
)

Addition of a scaled vector.

Todo:
SSVectorBase::multAdd() should be rewritten without pointer arithmetic.
Todo:
SSVectorBase::multAdd() should be rewritten without pointer arithmetic.

Definition at line 440 of file basevectors.h.

References SVectorBase< R >::index(), soplex::isNotZero(), SVectorBase< R >::size(), SOPLEX_VECTOR_MARKER, and SVectorBase< R >::value().

Referenced by SPxBoundFlippingRT::flipAndUpdate(), and SPxBasis::multBaseWith().

SSVectorBase<R>& multAdd ( x,
const VectorBase< T > &  vec 
)

Addition of a scaled vector.

Definition at line 455 of file ssvectorbase.h.

int number ( int  i) const

Returns the position number of index i, or -1 if i doesn't exist.

Definition at line 191 of file ssvectorbase.h.

Referenced by SSVectorBase< Real >::add(), SSVectorBase< Real >::clearIdx(), SSVectorBase< Real >::isConsistent(), and SSVectorBase< Real >::setValue().

R operator* ( const SSVectorBase< S > &  w)

Definition at line 417 of file ssvectorbase.h.

SSVectorBase<R>& operator*= ( x)

Scaling.

Definition at line 402 of file ssvectorbase.h.

SSVectorBase<R>& operator+= ( const VectorBase< S > &  vec)

Addition.

Definition at line 328 of file ssvectorbase.h.

SSVectorBase< R > & operator+= ( const SVectorBase< S > &  vec)

Addition.

Definition at line 401 of file basevectors.h.

SSVectorBase<R>& operator+= ( const SSVectorBase< S > &  vec)

Addition.

Definition at line 346 of file ssvectorbase.h.

SSVectorBase<R>& operator-= ( const VectorBase< S > &  vec)

Subtraction.

Definition at line 362 of file ssvectorbase.h.

SSVectorBase< R > & operator-= ( const SVectorBase< S > &  vec)

Subtraction.

Definition at line 420 of file basevectors.h.

SSVectorBase<R>& operator-= ( const SSVectorBase< S > &  vec)

Subtraction.

Definition at line 381 of file ssvectorbase.h.

SSVectorBase<R>& operator= ( const SSVectorBase< S > &  rhs)

Assignment operator.

Definition at line 744 of file ssvectorbase.h.

SSVectorBase<R>& operator= ( const SSVectorBase< R > &  rhs)

Assignment operator.

Definition at line 790 of file ssvectorbase.h.

SSVectorBase< R > & operator= ( const SVectorBase< S > &  rhs)

Assignment operator.

Definition at line 886 of file basevectors.h.

SSVectorBase<R>& operator= ( const VectorBase< S > &  rhs)

Assignment operator.

Definition at line 840 of file ssvectorbase.h.

R operator[] ( int  i) const

Returns i 'th value.

Definition at line 276 of file ssvectorbase.h.

void reMem ( int  newsize)

Resets memory consumption to newsize.

Definition at line 563 of file ssvectorbase.h.

void setEpsilon ( eps)

Changes the non-zero epsilon, invalidating the setup. */.

Definition at line 110 of file ssvectorbase.h.

Referenced by SoPlex::_computeInfeasBox(), and SPxSteepPR::setType().

void setMax ( int  newmax)
private

Allocates enough space to accommodate newmax values.

Definition at line 65 of file ssvectorbase.h.

Referenced by SSVectorBase< Real >::operator=(), SSVectorBase< Real >::reDim(), SSVectorBase< Real >::reMem(), and SSVectorBase< Real >::setup_and_assign().

void setValue ( int  i,
x 
)
int size ( ) const

Returns the number of nonzeros.

Definition at line 199 of file ssvectorbase.h.

Referenced by SoPlex::_computeInfeasBox(), VectorBase< R >::assign(), SSVectorBase< R >::assign2product1(), SSVectorBase< R >::assign2product4setup(), SSVectorBase< R >::assign2productFull(), SSVectorBase< R >::assign2productShort(), SLUFactorRational::change(), SLUFactor::change(), SLUFactorRational::changeEta(), SLUFactor::changeEta(), DSVectorBase< R >::DSVectorBase(), SPxSolver::enter(), SoPlex::getBasisInverseColReal(), SoPlex::getBasisInverseRowReal(), SPxSolver::leave(), SPxFastRT::maxDelta(), SPxFastRT::maxSelect(), SPxFastRT::minDelta(), SPxFastRT::minSelect(), VectorBase< R >::multAdd(), SPxBasis::multBaseWith(), VectorBase< R >::operator*(), SSVectorBase< Real >::operator*(), SSVectorBase< Real >::operator*=(), VectorBase< R >::operator+=(), SSVectorBase< Real >::operator+=(), VectorBase< R >::operator-=(), SSVectorBase< Real >::operator-=(), DSVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SSVectorBase< Real >::operator=(), SPxSolver::perturbMax(), SPxSolver::perturbMin(), SPxHarrisRT::selectEnter(), SPxBoundFlippingRT::selectEnter(), SPxHarrisRT::selectLeave(), SPxBoundFlippingRT::selectLeave(), SSVectorBase< Real >::setup_and_assign(), SPxSolver::setupPupdate(), SLUFactor::solve2right4update(), SLUFactorRational::solve2right4update(), SLUFactor::solve3right4update(), SLUFactorRational::solve3right4update(), SLUFactor::solveLeft(), SLUFactorRational::solveLeft(), SLUFactor::solveRight4update(), SLUFactorRational::solveRight4update(), and SSVectorBase< Real >::value().

R value ( int  n) const

Friends And Related Function Documentation

friend class DSVectorBase
friend

Definition at line 52 of file ssvectorbase.h.

friend class DVectorBase< R >
friend

Definition at line 50 of file ssvectorbase.h.

friend class VectorBase< R >
friend

Definition at line 51 of file ssvectorbase.h.

Member Data Documentation