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>

Public Member Functions

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...
 
VectorBase< Real > & scaleAssign (int scaleExp, const VectorBase< Real > &vec)
 scale and assign More...
 
VectorBase< Real > & scaleAssign (const int *scaleExp, const VectorBase< Real > &vec, bool negateExp=false)
 scale and assign 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...
 

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()

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 102 of file vectorbase.h.

Member Function Documentation

◆ assign() [1/2]

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.

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

◆ assign() [2/2]

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 122 of file basevectors.h.

◆ clear() [1/2]

◆ clear() [2/2]

void clear ( )

Set vector to 0 (specialization for Real).

Definition at line 522 of file vectorbase.h.

◆ dim()

int dim ( ) const

Dimension of vector.

Definition at line 217 of file vectorbase.h.

Referenced by SoPlex::_solveRealForRational(), LPColSetBase< Rational >::add(), LPRowSetBase< Real >::add(), SPxLPBase< Real >::addDualActivity(), SPxDevexPR::addedCoVecs(), SPxWeightPR::addedCoVecs(), SPxSteepPR::addedCoVecs(), SPxDevexPR::addedVecs(), SPxWeightPR::addedVecs(), SPxSteepPR::addedVecs(), SPxLPBase< Real >::addPrimalActivity(), SLUFactorRational::assign(), SSVectorBase< Real >::assign(), SPxLPBase< Real >::changeLhs(), SPxSolver::changeLower(), SPxLPBase< Real >::changeLower(), SPxLPBase< Real >::changeMaxObj(), SPxLPBase< Real >::changeRhs(), SPxLPBase< Real >::changeRowObj(), SPxSolver::changeUpper(), SPxLPBase< Real >::changeUpper(), SLUFactorRational::clear(), SPxLPBase< Real >::computeDualActivity(), SPxLPBase< Real >::computePrimalActivity(), SPxBasis::coSolve(), LPColSetBase< Rational >::create(), LPRowSetBase< Real >::create(), DSVectorBase< Real >::DSVectorBase(), DVectorBase< Real >::DVectorBase(), SPxWeightST::generate(), SoPlex::getBasisInverseTimesVecReal(), SoPlex::getBoundViolationRational(), SoPlex::getBoundViolationReal(), SoPlex::getDecompBoundViolation(), SoPlex::getDecompRowViolation(), SoPlex::getDualFarkasRational(), SoPlex::getDualFarkasReal(), SPxSolver::getDualNorms(), SoPlex::getDualRational(), SoPlex::getDualReal(), SoPlex::getDualViolationRational(), SoPlex::getDualViolationReal(), SPxScaler::getLhsUnscaled(), SPxScaler::getLowerUnscaled(), SPxScaler::getMaxObjUnscaled(), SPxSolver::getNdualNorms(), SoPlex::getPrimalRational(), SoPlex::getPrimalRayRational(), SoPlex::getPrimalRayReal(), SoPlex::getPrimalReal(), SoPlex::getRedCostRational(), SoPlex::getRedCostReal(), SoPlex::getRedCostViolationRational(), SoPlex::getRedCostViolationReal(), SPxScaler::getRhsUnscaled(), SoPlex::getRowViolationRational(), SoPlex::getRowViolationReal(), SoPlex::getSlacksRational(), SoPlex::getSlacksReal(), SPxScaler::getUpperUnscaled(), SPxWeightPR::isConsistent(), VectorBase< Real >::isConsistent(), LPColSetBase< Rational >::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< Real >::operator*(), soplex::operator*(), VectorBase< Real >::operator*=(), soplex::operator+(), VectorBase< Real >::operator+=(), soplex::operator-(), VectorBase< Real >::operator-=(), VectorBase< Real >::operator/=(), VectorBase< Real >::operator=(), DSVectorBase< Real >::operator=(), DVectorBase< Real >::operator=(), SVectorBase< Real >::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< Real >::reSize(), VectorBase< Real >::scaleAssign(), SPxScaler::scaleObj(), SPxDevexPR::selectEnterDenseCoDim(), SPxDevexPR::selectEnterDenseDim(), SPxDevexPR::selectEnterSparseCoDim(), SPxDevexPR::selectEnterSparseDim(), SPxDevexPR::selectLeaveX(), SPxSolver::setDualNorms(), SPxSolver::setupPupdate(), SPxSteepPR::setupWeights(), SPxVectorST::setupWeights(), SLUFactorRational::SLUFactorRational(), SPxBasis::solve(), CLUFactorRational::solveLleftForest(), CLUFactorRational::solveLleftForestNoNZ(), CLUFactorRational::solveLleftNoNZ(), CLUFactorRational::solveUleft(), CLUFactorRational::solveUleftNoNZ(), CLUFactorRational::solveUpdateLeft(), SPxLPBase< Real >::subDualActivity(), SPxScaler::unscaleDual(), SPxScaler::unscaleDualray(), SPxScaler::unscalePrimal(), SPxScaler::unscalePrimalray(), SPxScaler::unscaleRedCost(), SPxScaler::unscaleSlacks(), SPxMainSM::unsimplify(), CLUFactorRational::vSolveUpdateRight(), and CLUFactorRational::vSolveUpdateRightNoNZ().

◆ get_const_ptr()

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 455 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(), and SPxWeightPR::SPxWeightPR().

◆ get_ptr()

◆ isConsistent()

bool isConsistent ( ) const

◆ length()

Real length ( ) const

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

Definition at line 399 of file vectorbase.h.

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

◆ length2()

R length2 ( ) const

◆ maxAbs()

R maxAbs ( ) const

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

Definition at line 357 of file vectorbase.h.

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

◆ minAbs()

R minAbs ( ) const

Minimum absolute value.

Definition at line 378 of file vectorbase.h.

◆ multAdd() [1/3]

◆ multAdd() [2/3]

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

Addition of scaled vector.

Definition at line 276 of file basevectors.h.

◆ multAdd() [3/3]

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

Addition of scaled vector.

Definition at line 310 of file basevectors.h.

◆ multSub()

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

Subtraction of scaled vector.

Definition at line 293 of file basevectors.h.

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

◆ operator*() [1/4]

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

Inner product.

Definition at line 338 of file vectorbase.h.

◆ operator*() [2/4]

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

Inner product.

Definition at line 231 of file basevectors.h.

◆ operator*() [3/4]

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

Inner product.

Definition at line 248 of file basevectors.h.

◆ operator*() [4/4]

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

Inner product.

Definition at line 533 of file vectorbase.h.

◆ operator*=()

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

Scaling.

Definition at line 315 of file vectorbase.h.

◆ operator+=() [1/3]

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

Addition.

Definition at line 273 of file vectorbase.h.

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

◆ operator+=() [2/3]

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

Addition.

Definition at line 148 of file basevectors.h.

◆ operator+=() [3/3]

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

Addition.

Definition at line 166 of file basevectors.h.

◆ operator-=() [1/3]

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

Subtraction.

Definition at line 294 of file vectorbase.h.

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

◆ operator-=() [2/3]

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

Subtraction.

Definition at line 190 of file basevectors.h.

◆ operator-=() [3/3]

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

Subtraction.

Definition at line 208 of file basevectors.h.

◆ operator/=()

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

Division.

Definition at line 327 of file vectorbase.h.

◆ operator=() [1/6]

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

Assignment operator.

Definition at line 112 of file vectorbase.h.

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

◆ operator=() [2/6]

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

Assignment operator.

Definition at line 128 of file vectorbase.h.

◆ operator=() [3/6]

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().

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

Definition at line 58 of file basevectors.h.

◆ operator=() [4/6]

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 different in method assign().

Definition at line 102 of file basevectors.h.

◆ operator=() [5/6]

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

Assignment operator (specialization for Real).

Definition at line 482 of file vectorbase.h.

◆ operator=() [6/6]

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

Assignment operator (specialization for Real).

Definition at line 502 of file vectorbase.h.

◆ operator[]() [1/2]

R& operator[] ( int  n)

Return n 'th value by reference.

Definition at line 223 of file vectorbase.h.

◆ operator[]() [2/2]

const R& operator[] ( int  n) const

Return n 'th value.

Definition at line 230 of file vectorbase.h.

◆ scaleAssign() [1/2]

VectorBase<Real>& scaleAssign ( int  scaleExp,
const VectorBase< Real > &  vec 
)

scale and assign

Definition at line 144 of file vectorbase.h.

◆ scaleAssign() [2/2]

VectorBase<Real>& scaleAssign ( const int *  scaleExp,
const VectorBase< Real > &  vec,
bool  negateExp = false 
)

scale and assign

Definition at line 160 of file vectorbase.h.

Friends And Related Function Documentation

◆ operator==

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

Equality operator.

Definition at line 237 of file vectorbase.h.

Member Data Documentation

◆ dimen

◆ val