Scippy

SoPlex

Sequential object-oriented simPlex

VectorBase< R > Class Template Reference

Dense vector.Class VectorBase provides dense linear algebra vectors. It does not provide memory management for the array of values. Instead, the constructor requires a pointer to a memory block large enough to fit the desired dimension of Real or Rational values. More...

#include <dsvectorbase.h>

Inheritance diagram for VectorBase< R >:

Public Member Functions

template<>
VectorBase< Rational > & multAdd (const Rational &x, const SVectorBase< Rational > &vec)
 Addition of scaled vector, specialization for rationals. More...
 
template<>
VectorBase< Rational > & multSub (const Rational &x, const SVectorBase< Rational > &vec)
 Subtraction of scaled vector, specialization for rationals. More...
 
template<>
VectorBase< Real > & operator= (const VectorBase< Real > &vec)
 Assignment operator (specialization for Real). More...
 
template<>
VectorBase< Real > & operator= (const VectorBase< Rational > &vec)
 Assignment operator (specialization for Real). More...
 
template<>
void clear ()
 Set vector to 0 (specialization for Real). More...
 
template<>
Rational operator* (const VectorBase< Rational > &vec) const
 Inner product. More...
 
Construction and assignment
 VectorBase (int p_dimen, R *p_val)
 Constructor. More...
 
template<class S >
VectorBase< R > & operator= (const VectorBase< S > &vec)
 Assignment operator. More...
 
VectorBase< R > & operator= (const VectorBase< R > &vec)
 Assignment operator. More...
 
template<class S >
VectorBase< R > & operator= (const SVectorBase< S > &vec)
 Assignment operator. More...
 
template<class S >
VectorBase< R > & operator= (const SSVectorBase< S > &vec)
 Assignment operator. More...
 
template<class S >
VectorBase< R > & assign (const SVectorBase< S > &vec)
 Assign values of vec. More...
 
template<class S >
VectorBase< R > & assign (const SSVectorBase< S > &vec)
 Assign values of vec. More...
 
Arithmetic operations
void clear ()
 Set vector to 0. More...
 
template<class S >
VectorBase< R > & operator+= (const VectorBase< S > &vec)
 Addition. More...
 
template<class S >
VectorBase< R > & operator+= (const SVectorBase< S > &vec)
 Addition. More...
 
template<class S >
VectorBase< R > & operator+= (const SSVectorBase< S > &vec)
 Addition. More...
 
template<class S >
VectorBase< R > & operator-= (const VectorBase< S > &vec)
 Subtraction. More...
 
template<class S >
VectorBase< R > & operator-= (const SVectorBase< S > &vec)
 Subtraction. More...
 
template<class S >
VectorBase< R > & operator-= (const SSVectorBase< S > &vec)
 Subtraction. More...
 
template<class S >
VectorBase< R > & operator*= (const S &x)
 Scaling. More...
 
template<class S >
VectorBase< R > & operator/= (const S &x)
 Division. More...
 
operator* (const VectorBase< R > &vec) const
 Inner product. More...
 
operator* (const SVectorBase< R > &vec) const
 Inner product. More...
 
operator* (const SSVectorBase< R > &vec) const
 Inner product. More...
 
maxAbs () const
 Maximum absolute value, i.e., infinity norm. More...
 
minAbs () const
 Minimum absolute value. More...
 
Real length () const
 Floating point approximation of euclidian norm (without any approximation guarantee). More...
 
length2 () const
 Squared norm. More...
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const VectorBase< T > &vec)
 Addition of scaled vector. More...
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const SVectorBase< T > &vec)
 Addition of scaled vector. More...
 
template<class S , class T >
VectorBase< R > & multSub (const S &x, const SVectorBase< T > &vec)
 Subtraction of scaled vector. More...
 
template<class S , class T >
VectorBase< R > & multAdd (const S &x, const SSVectorBase< T > &vec)
 Addition of scaled vector. More...
 
Utilities
R * get_ptr ()
 Conversion to C-style pointer. More...
 
const R * get_const_ptr () const
 Conversion to C-style pointer. More...
 
bool isConsistent () const
 Consistency check. More...
 

Protected Attributes

Data
int dimen
 Dimension of vector. More...
 
R * val
 Values of vector. More...
 

Private Member Functions

Blocked
 VectorBase ()
 Blocked default constructor. More...
 

Access

int dim () const
 Dimension of vector. More...
 
R & operator[] (int n)
 Return n 'th value by reference. More...
 
const R & operator[] (int n) const
 Return n 'th value. More...
 
bool operator== (const VectorBase< R > &vec1, const VectorBase< R > &vec2)
 Equality operator. More...
 

Detailed Description

template<class R>
class soplex::VectorBase< R >

Dense vector.

Class VectorBase provides dense linear algebra vectors. It does not provide memory management for the array of values. Instead, the constructor requires a pointer to a memory block large enough to fit the desired dimension of Real or Rational values.

After construction, the values of a VectorBase can be accessed with the subscript operator[](). Safety is provided by qchecking of array bound when accessing elements with the subscript operator[]() (only when compiled without -DNDEBUG).

A VectorBase is distinguished from a simple array of Reals or Rationals by providing a set of mathematical operations. Since VectorBase does not provide any memory management features, no operations are available that would require allocation of temporary memory space.

The following mathematical operations are provided by class VectorBase (VectorBase a, b; R x):

OperationDescription  
-= subtraction a -= b
+= addition a += b
* scalar product x = a * b
*= scaling a *= x
maxAbs() infinity norm a.maxAbs() == $\|a\|_{\infty}$
minAbs()

a.minAbs() == $\min |a_i|$

length() euclidian norm a.length() == $\sqrt{a^2}$
length2()square norm a.length2() == $a^2$
multAdd(x,b)add scaled vector a += x * b

When using any of these operations, the vectors involved must be of the same dimension. Also an SVectorBase b is allowed if it does not contain nonzeros with index greater than the dimension of a.q

Definition at line 28 of file dsvectorbase.h.

Constructor & Destructor Documentation

VectorBase ( int  p_dimen,
R *  p_val 
)

Constructor.

There is no default constructor since the storage for a VectorBase must be provided externally. Storage must be passed as a memory block val at construction. It must be large enough to fit at least dimen values.

Definition at line 101 of file vectorbase.h.

VectorBase ( )
private

Blocked default constructor.

Definition at line 437 of file vectorbase.h.

Member Function Documentation

VectorBase< R > & assign ( const SVectorBase< S > &  vec)

Assign values of vec.

Assigns all nonzeros of vec to the vector. All other values remain unchanged.

Definition at line 80 of file basevectors.h.

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

Referenced by VectorBase< Real >::operator=(), SLUFactor::solveRight(), and SLUFactorRational::solveRight().

VectorBase< R > & assign ( const SSVectorBase< S > &  vec)

Assign values of vec.

Assigns all nonzeros of vec to the vector. All other values remain unchanged.

Definition at line 119 of file basevectors.h.

References SSVectorBase< R >::dim(), SSVectorBase< R >::indexMem(), SSVectorBase< R >::isSetup(), SSVectorBase< R >::size(), and VectorBase< R >::val.

void clear ( )

Set vector to 0 (specialization for Real).

Definition at line 488 of file vectorbase.h.

References VectorBase< R >::dimen, and VectorBase< R >::val.

int dim ( ) const

Dimension of vector.

Definition at line 174 of file vectorbase.h.

Referenced by SoPlex::_solveRealForRational(), LPColSetBase< Real >::add(), LPRowSetBase< Real >::add(), SPxLPBase< Real >::addDualActivity(), SPxDevexPR::addedCoVecs(), SPxWeightPR::addedCoVecs(), SPxSteepPR::addedCoVecs(), SPxDevexPR::addedVecs(), SPxWeightPR::addedVecs(), SPxSteepPR::addedVecs(), SPxLPBase< Real >::addPrimalActivity(), SLUFactorRational::assign(), SPxLPBase< Real >::changeLhs(), SPxSolver::changeLower(), SPxLPBase< Real >::changeLower(), SPxLPBase< Real >::changeMaxObj(), SPxLPBase< Real >::changeObj(), SPxLPBase< Real >::changeRhs(), SPxLPBase< Real >::changeRowObj(), SPxSolver::changeUpper(), SPxLPBase< Real >::changeUpper(), SLUFactorRational::clear(), SPxLPBase< Real >::computeDualActivity(), SPxLPBase< Real >::computePrimalActivity(), LPColSetBase< Real >::create(), LPRowSetBase< Real >::create(), DSVectorBase< R >::DSVectorBase(), DVectorBase< Real >::DVectorBase(), DVectorBase< R >::DVectorBase(), SPxWeightST::generate(), SoPlex::getBoundViolationRational(), SoPlex::getBoundViolationReal(), SoPlex::getDualFarkasRational(), SoPlex::getDualFarkasReal(), SPxPricer::getDualNorms(), SoPlex::getDualRational(), SoPlex::getDualReal(), SoPlex::getDualViolationRational(), SoPlex::getDualViolationReal(), SPxPricer::getNdualNorms(), SoPlex::getPrimalRational(), SoPlex::getPrimalRayRational(), SoPlex::getPrimalRayReal(), SoPlex::getPrimalReal(), SoPlex::getRedCostRational(), SoPlex::getRedCostReal(), SoPlex::getRedCostViolationRational(), SoPlex::getRedCostViolationReal(), SoPlex::getRowViolationRational(), SoPlex::getRowViolationReal(), SoPlex::getSlacksRational(), SoPlex::getSlacksReal(), SPxDevexPR::init(), SPxDevexPR::isConsistent(), SPxWeightPR::isConsistent(), VectorBase< Real >::isConsistent(), LPColSetBase< Real >::isConsistent(), LPRowSetBase< Real >::isConsistent(), SPxSolver::isConsistent(), soplex::LPFwriteObjective(), CLUFactorRational::makeLvec(), VectorBase< Real >::maxAbs(), SPxFastRT::maxDelta(), VectorBase< Real >::minAbs(), SPxFastRT::minDelta(), CLUFactorRational::minLMem(), CLUFactorRational::minRowMem(), SPxBasis::multBaseWith(), SPxBasis::multWithBase(), VectorBase< R >::operator*(), soplex::operator*(), VectorBase< Real >::operator*=(), soplex::operator+(), VectorBase< Real >::operator+=(), soplex::operator-(), VectorBase< Real >::operator-=(), VectorBase< Real >::operator/=(), VectorBase< Real >::operator=(), DVectorBase< Real >::operator=(), DSVectorBase< R >::operator=(), VectorBase< R >::operator=(), SVectorBase< R >::operator=(), soplex::operator>>(), SPxSolver::perturbMax(), SPxSolver::perturbMin(), soplex::reconstructVector(), CLUFactorRational::remaxRow(), SPxWeightPR::removedCoVec(), SPxSteepPR::removedCoVec(), SPxWeightPR::removedCoVecs(), SPxSteepPR::removedCoVecs(), SPxWeightPR::removedVec(), SPxSteepPR::removedVec(), SPxWeightPR::removedVecs(), SPxSteepPR::removedVecs(), DVectorBase< R >::reSize(), SPxDevexPR::selectEnterDenseCoDim(), SPxDevexPR::selectEnterDenseDim(), SPxDevexPR::selectEnterSparseCoDim(), SPxDevexPR::selectEnterSparseDim(), SPxDevexPR::selectLeaveX(), SPxPricer::setDualNorms(), SPxSolver::setupPupdate(), SPxSteepPR::setupWeights(), SPxVectorST::setupWeights(), SLUFactorRational::SLUFactorRational(), CLUFactorRational::solveLleftForest(), CLUFactorRational::solveLleftForestNoNZ(), CLUFactorRational::solveLleftNoNZ(), CLUFactorRational::solveUleft(), CLUFactorRational::solveUleftNoNZ(), CLUFactorRational::solveUpdateLeft(), SPxLPBase< Real >::subDualActivity(), SPxScaler::unscaleDual(), SPxScaler::unscalePrimal(), SPxScaler::unscaleRedCost(), SPxScaler::unscaleSlacks(), SPxMainSM::unsimplify(), CLUFactorRational::vSolveUpdateRight(), and CLUFactorRational::vSolveUpdateRightNoNZ().

const R* get_const_ptr ( ) const

Conversion to C-style pointer.

This function serves for using a VectorBase in an C-style function. It returns a pointer to the first value of the array.

Definition at line 412 of file vectorbase.h.

Referenced by SPxDevexPR::buildBestPriceVectorEnterCoDim(), SPxSteepPR::buildBestPriceVectorEnterCoDim(), SPxDevexPR::buildBestPriceVectorEnterDim(), SPxSteepPR::buildBestPriceVectorEnterDim(), SPxDevexPR::buildBestPriceVectorLeave(), SPxSteepPR::buildBestPriceVectorLeave(), SPxSteepPR::entered4(), SPxSteepPR::left4(), SPxFastRT::maxDelta(), SPxFastRT::maxSelect(), SPxFastRT::minDelta(), SPxFastRT::minSelect(), SPxWeightPR::operator=(), SPxSolver::perturbMax(), SPxSolver::perturbMin(), SPxDefaultRT::selectEnter(), SPxHarrisRT::selectEnter(), SPxBoundFlippingRT::selectEnter(), SPxDevexPR::selectEnterDenseCoDim(), SPxSteepPR::selectEnterDenseCoDim(), SPxDevexPR::selectEnterDenseDim(), SPxSteepPR::selectEnterDenseDim(), SPxDevexPR::selectEnterHyperCoDim(), SPxSteepPR::selectEnterHyperCoDim(), SPxDevexPR::selectEnterHyperDim(), SPxSteepPR::selectEnterHyperDim(), SPxDevexPR::selectEnterSparseCoDim(), SPxSteepPR::selectEnterSparseCoDim(), SPxDevexPR::selectEnterSparseDim(), SPxSteepPR::selectEnterSparseDim(), SPxDefaultRT::selectLeave(), SPxHarrisRT::selectLeave(), SPxWeightPR::selectLeave(), SPxBoundFlippingRT::selectLeave(), SPxDevexPR::selectLeaveHyper(), SPxSteepPR::selectLeaveHyper(), SPxDevexPR::selectLeaveSparse(), SPxSteepPR::selectLeaveSparse(), SPxDevexPR::selectLeaveX(), SPxSteepPR::selectLeaveX(), SPxWeightPR::setRep(), SPxSumST::setupWeights(), and SPxWeightPR::SPxWeightPR().

bool isConsistent ( ) const
Real length ( ) const

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

Definition at line 356 of file vectorbase.h.

Referenced by SPxSolver::enter(), SPxSolver::factorize(), SPxSolver::leave(), SPxWeightPR::load(), SPxSolver::terminate(), and SPxSolver::testVecs().

R length2 ( ) const
R maxAbs ( ) const

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

Definition at line 314 of file vectorbase.h.

Referenced by SSVectorBase< Real >::maxAbs(), and SPxWeightST::setupWeights().

R minAbs ( ) const

Minimum absolute value.

Definition at line 335 of file vectorbase.h.

VectorBase< Rational > & multAdd ( const Rational x,
const SVectorBase< Rational > &  vec 
)

Addition of scaled vector, specialization for rationals.

Definition at line 308 of file basevectors.h.

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

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

Addition of scaled vector.

Definition at line 273 of file basevectors.h.

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

VectorBase< R > & multAdd ( const S &  x,
const SSVectorBase< T > &  vec 
)
VectorBase< Rational > & multSub ( const Rational x,
const SVectorBase< Rational > &  vec 
)

Subtraction of scaled vector, specialization for rationals.

Definition at line 325 of file basevectors.h.

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

VectorBase< R > & multSub ( const S &  x,
const SVectorBase< T > &  vec 
)

Subtraction of scaled vector.

Definition at line 290 of file basevectors.h.

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

Referenced by SPxLPBase< Real >::subDualActivity().

R operator* ( const VectorBase< R > &  vec) const

Inner product.

Definition at line 295 of file vectorbase.h.

R operator* ( const SVectorBase< R > &  vec) const
Rational operator* ( const VectorBase< Rational > &  vec) const

Inner product.

Definition at line 500 of file vectorbase.h.

References Rational::addProduct(), VectorBase< R >::dim(), VectorBase< R >::dimen, and VectorBase< R >::val.

VectorBase<R>& operator*= ( const S &  x)

Scaling.

Definition at line 272 of file vectorbase.h.

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

Addition.

Definition at line 230 of file vectorbase.h.

Referenced by VectorBase< Real >::operator+=(), and SSVectorBase< Real >::operator+=().

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

Addition.

Definition at line 145 of file basevectors.h.

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

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

Subtraction.

Definition at line 251 of file vectorbase.h.

Referenced by VectorBase< Real >::operator-=(), and SSVectorBase< Real >::operator-=().

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

Subtraction.

Definition at line 187 of file basevectors.h.

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

VectorBase<R>& operator/= ( const S &  x)

Division.

Definition at line 284 of file vectorbase.h.

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

Assignment operator.

Definition at line 111 of file vectorbase.h.

Referenced by VectorBase< Real >::operator=(), DVectorBase< Real >::operator=(), and SSVectorBase< Real >::operator=().

VectorBase<R>& operator= ( const VectorBase< R > &  vec)

Assignment operator.

Definition at line 127 of file vectorbase.h.

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

Assignment operator.

Assigning an SVectorBase to a VectorBase using operator=() will set all values to 0 except the nonzeros of vec. This is diffent in method assign().

Definition at line 58 of file basevectors.h.

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

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

Assignment operator.

Assigning an SSVectorBase to a VectorBase using operator=() will set all values to 0 except the nonzeros of vec. This is diffent in method assign().

Todo:
do we need this also in non-template version, because SSVectorBase can be automatically cast to VectorBase?

Assigning an SSVectorBase to a VectorBase using operator=() will set all values to 0 except the nonzeros of vec. This is diffent in method assign().

Definition at line 99 of file basevectors.h.

References SSVectorBase< R >::isSetup().

VectorBase< Real > & operator= ( const VectorBase< Real > &  vec)

Assignment operator (specialization for Real).

Definition at line 449 of file vectorbase.h.

References VectorBase< R >::dim(), VectorBase< R >::dimen, VectorBase< R >::isConsistent(), and VectorBase< R >::val.

VectorBase< Real > & operator= ( const VectorBase< Rational > &  vec)

Assignment operator (specialization for Real).

Definition at line 468 of file vectorbase.h.

References VectorBase< R >::dim(), VectorBase< R >::dimen, VectorBase< R >::isConsistent(), and VectorBase< R >::val.

R& operator[] ( int  n)

Return n 'th value by reference.

Definition at line 180 of file vectorbase.h.

const R& operator[] ( int  n) const

Return n 'th value.

Definition at line 187 of file vectorbase.h.

Friends And Related Function Documentation

bool operator== ( const VectorBase< R > &  vec1,
const VectorBase< R > &  vec2 
)
friend

Equality operator.

Definition at line 194 of file vectorbase.h.

Member Data Documentation