Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std::vector. More...
#include <dsvectorbase.h>
Public Member Functions | |
bool | isConsistent () const |
Consistency check. More... | |
template<> | |
Rational | operator* (const VectorBase< Rational > &vec) const |
Inner product. More... | |
Construction and assignment | |
VectorBase () | |
Constructor. More... | |
VectorBase (int dimen, R *p_val) | |
VectorBase (int p_dimen) | |
template<typename S > | |
VectorBase (const VectorBase< S > &vec) | |
VectorBase (const VectorBase< R > &&vec) noexcept | |
VectorBase (const VectorBase< R > &vec) | |
template<class S > | |
VectorBase< R > & | operator= (const VectorBase< S > &vec) |
Assignment operator. More... | |
VectorBase< R > & | operator= (const VectorBase< R > &vec) |
Assignment operator. More... | |
VectorBase< R > & | operator= (const VectorBase< R > &&vec) |
Move assignment operator. More... | |
VectorBase< R > & | scaleAssign (int scaleExp, const VectorBase< R > &vec) |
scale and assign More... | |
VectorBase< R > & | scaleAssign (const int *scaleExp, const VectorBase< R > &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 contain all-zeros (keeping the same length) 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... | |
R | operator* (const VectorBase< R > &vec) const |
Inner product. More... | |
R | operator* (const SVectorBase< R > &vec) const |
Inner product. More... | |
R | operator* (const SSVectorBase< R > &vec) const |
Inner product. More... | |
R | maxAbs () const |
Maximum absolute value, i.e., infinity norm. More... | |
R | minAbs () const |
Minimum absolute value. More... | |
R | length () const |
Floating point approximation of euclidian norm (without any approximation guarantee). More... | |
R | 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... | |
Protected Attributes | |
Data | |
std::vector< R > | val |
Values of vector. More... | |
Friends | |
template<typename S > | |
class | VectorBase |
Access | |
bool | operator== (const VectorBase< R > &vec1, const VectorBase< R > &vec2) |
Equality operator. More... | |
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... | |
const std::vector< R > & | vec () |
Return underlying std::vector. More... | |
Utilities | |
VectorBase< R > | operator- (const VectorBase< R > &vec) |
R * | get_ptr () |
Conversion to C-style pointer. More... | |
const R * | get_const_ptr () const |
Conversion to C-style pointer. More... | |
std::vector< R >::const_iterator | begin () const |
std::vector< R >::iterator | begin () |
std::vector< R >::const_iterator | end () const |
std::vector< R >::iterator | end () |
int | memSize () const |
void | reDim (int newdim, const bool setZero=true) |
Resets VectorBase's dimension to newdim . More... | |
void | reSize (int newsize) |
Resets VectorBase's memory size to newsize . More... | |
const VectorBase< R > | operator- (const VectorBase< R > &vec) const |
const VectorBase< R > | operator+ (const VectorBase< R > &v) const |
Dense vector.
Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std::vector.
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.
The following mathematical operations are provided by class VectorBase (VectorBase a
, b
; R x
):
Operation | Description | |
-= | subtraction | a -= b |
+= | addition | a += b |
* | scalar product | x = a * b |
*= | scaling | a *= x |
maxAbs() | infinity norm | a.maxAbs() == \(\|a\|_{\infty}\) |
minAbs() |
| |
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.
VectorBase | ( | ) |
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 109 of file vectorbase.h.
VectorBase | ( | int | dimen, |
R * | p_val | ||
) |
Definition at line 116 of file vectorbase.h.
|
explicit |
Definition at line 122 of file vectorbase.h.
VectorBase | ( | const VectorBase< S > & | vec | ) |
Definition at line 130 of file vectorbase.h.
|
noexcept |
Definition at line 136 of file vectorbase.h.
VectorBase | ( | const VectorBase< R > & | vec | ) |
Definition at line 141 of file vectorbase.h.
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 78 of file basevectors.h.
Referenced by VectorBase< Rational >::scaleAssign(), and VectorBase< Rational >::VectorBase().
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 118 of file basevectors.h.
std::vector<R>::const_iterator begin | ( | ) | const |
Definition at line 501 of file vectorbase.h.
std::vector<R>::iterator begin | ( | ) |
Definition at line 506 of file vectorbase.h.
void clear | ( | ) |
Set vector to contain all-zeros (keeping the same length)
Definition at line 300 of file vectorbase.h.
Referenced by UpdateVector< R >::clear(), SSVectorBase< Rational >::clear(), SPxBasisBase< R >::coSolve(), VectorBase< Rational >::operator=(), SPxBasisBase< R >::solve(), and SSVectorBase< Rational >::SSVectorBase().
int dim | ( | ) | const |
Dimension of vector.
Definition at line 262 of file vectorbase.h.
Referenced by LPColSetBase< Rational >::add(), LPRowSetBase< R >::add(), SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::addPrimalActivity(), SSVectorBase< Rational >::assign(), SPxLPBase< R >::changeLhs(), SPxLPBase< R >::changeLower(), SPxLPBase< R >::changeMaxObj(), SPxLPBase< R >::changeRhs(), SPxLPBase< R >::changeRowObj(), SPxLPBase< R >::changeUpper(), SPxBasisBase< R >::coSolve(), LPColSetBase< Rational >::create(), LPRowSetBase< R >::create(), SSVectorBase< Rational >::dim(), DSVectorBase< Rational >::DSVectorBase(), Presol< R >::getBasis(), LPColSetBase< Rational >::isConsistent(), LPRowSetBase< R >::isConsistent(), VectorBase< Rational >::maxAbs(), VectorBase< Rational >::minAbs(), VectorBase< Rational >::multAdd(), VectorBase< Rational >::operator*(), VectorBase< Rational >::operator*=(), VectorBase< Rational >::operator+(), VectorBase< Rational >::operator+=(), VectorBase< Rational >::operator-(), soplex::operator-(), VectorBase< Rational >::operator-=(), VectorBase< Rational >::operator/=(), DSVectorBase< Rational >::operator=(), SVectorBase< Rational >::operator=(), soplex::operator>>(), VectorBase< Rational >::operator[](), VectorBase< Rational >::reDim(), VectorBase< Rational >::scaleAssign(), SLUFactorRational::SLUFactorRational(), SPxBasisBase< R >::solve(), and SPxLPBase< R >::subDualActivity().
std::vector<R>::const_iterator end | ( | ) | const |
Definition at line 512 of file vectorbase.h.
std::vector<R>::iterator end | ( | ) |
Definition at line 517 of file vectorbase.h.
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 495 of file vectorbase.h.
Referenced by SPxWeightPR< R >::operator=(), and SPxWeightPR< R >::SPxWeightPR().
R* get_ptr | ( | ) |
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 486 of file vectorbase.h.
Referenced by SSVectorBase< Rational >::get_ptr().
bool isConsistent | ( | ) | const |
Consistency check.
Definition at line 614 of file vectorbase.h.
Referenced by LPColSetBase< Rational >::isConsistent(), and SSVectorBase< Rational >::isConsistent().
R length | ( | ) | const |
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition at line 437 of file vectorbase.h.
R length2 | ( | ) | const |
Squared norm.
Definition at line 443 of file vectorbase.h.
Referenced by VectorBase< Rational >::length(), and SSVectorBase< Rational >::length2().
R maxAbs | ( | ) | const |
Maximum absolute value, i.e., infinity norm.
Definition at line 397 of file vectorbase.h.
Referenced by SSVectorBase< Rational >::maxAbs().
int memSize | ( | ) | const |
Definition at line 527 of file vectorbase.h.
R minAbs | ( | ) | const |
Minimum absolute value.
Definition at line 417 of file vectorbase.h.
VectorBase<R>& multAdd | ( | const S & | x, |
const VectorBase< T > & | vec | ||
) |
Addition of scaled vector.
Definition at line 450 of file vectorbase.h.
Referenced by SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::addPrimalActivity(), SSVectorBase< Rational >::multAdd(), and UpdateVector< R >::update().
VectorBase< R > & multAdd | ( | const S & | x, |
const SVectorBase< T > & | vec | ||
) |
Addition of scaled vector.
Definition at line 272 of file basevectors.h.
VectorBase< R > & multAdd | ( | const S & | x, |
const SSVectorBase< T > & | vec | ||
) |
Addition of scaled vector.
Definition at line 306 of file basevectors.h.
VectorBase< R > & multSub | ( | const S & | x, |
const SVectorBase< T > & | vec | ||
) |
Subtraction of scaled vector.
Definition at line 289 of file basevectors.h.
Referenced by SPxLPBase< R >::subDualActivity().
R operator* | ( | const VectorBase< R > & | vec | ) | const |
Inner product.
Definition at line 378 of file vectorbase.h.
R operator* | ( | const SVectorBase< R > & | vec | ) | const |
Inner product.
Definition at line 227 of file basevectors.h.
R operator* | ( | const SSVectorBase< R > & | vec | ) | const |
Inner product.
Definition at line 244 of file basevectors.h.
Rational operator* | ( | const VectorBase< Rational > & | vec | ) | const |
Inner product.
Definition at line 624 of file vectorbase.h.
VectorBase<R>& operator*= | ( | const S & | x | ) |
Scaling.
Definition at line 352 of file vectorbase.h.
const VectorBase<R> operator+ | ( | const VectorBase< R > & | v | ) | const |
Definition at line 580 of file vectorbase.h.
VectorBase<R>& operator+= | ( | const VectorBase< S > & | vec | ) |
Addition.
Definition at line 308 of file vectorbase.h.
Referenced by VectorBase< Rational >::operator+=(), and SSVectorBase< Rational >::operator+=().
VectorBase< R > & operator+= | ( | const SVectorBase< S > & | vec | ) |
Addition.
Definition at line 144 of file basevectors.h.
VectorBase< R > & operator+= | ( | const SSVectorBase< S > & | vec | ) |
Addition.
Definition at line 162 of file basevectors.h.
const VectorBase<R> operator- | ( | const VectorBase< R > & | vec | ) | const |
Definition at line 563 of file vectorbase.h.
VectorBase<R>& operator-= | ( | const VectorBase< S > & | vec | ) |
Subtraction.
Definition at line 330 of file vectorbase.h.
Referenced by VectorBase< Rational >::operator-=(), and SSVectorBase< Rational >::operator-=().
VectorBase< R > & operator-= | ( | const SVectorBase< S > & | vec | ) |
Subtraction.
Definition at line 186 of file basevectors.h.
VectorBase< R > & operator-= | ( | const SSVectorBase< S > & | vec | ) |
Subtraction.
Definition at line 204 of file basevectors.h.
VectorBase<R>& operator/= | ( | const S & | x | ) |
Division.
Definition at line 365 of file vectorbase.h.
VectorBase<R>& operator= | ( | const VectorBase< S > & | vec | ) |
Assignment operator.
Definition at line 149 of file vectorbase.h.
Referenced by UpdateVector< R >::operator=(), SSVectorBase< Rational >::operator=(), VectorBase< Rational >::scaleAssign(), and VectorBase< Rational >::VectorBase().
VectorBase<R>& operator= | ( | const VectorBase< R > & | vec | ) |
Assignment operator.
Definition at line 166 of file vectorbase.h.
VectorBase<R>& operator= | ( | const VectorBase< R > && | vec | ) |
Move assignment operator.
Definition at line 179 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().
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.
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().
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 98 of file basevectors.h.
R& operator[] | ( | int | n | ) |
Return n
'th value by reference.
Definition at line 268 of file vectorbase.h.
const R& operator[] | ( | int | n | ) | const |
Return n
'th value.
Definition at line 275 of file vectorbase.h.
void reDim | ( | int | newdim, |
const bool | setZero = true |
||
) |
Resets VectorBase's dimension to newdim
.
Definition at line 533 of file vectorbase.h.
Referenced by LPColSetBase< Rational >::add(), LPRowSetBase< R >::add(), LPColSetBase< Rational >::clear(), LPRowSetBase< R >::clear(), LPColSetBase< Rational >::create(), LPRowSetBase< R >::create(), SSVectorBase< Rational >::operator=(), soplex::operator>>(), UpdateVector< R >::reDim(), SSVectorBase< Rational >::reDim(), LPColSetBase< Rational >::remove(), LPRowSetBase< R >::remove(), SSVectorBase< Rational >::setup_and_assign(), and SLUFactorRational::SLUFactorRational().
void reSize | ( | int | newsize | ) |
Resets VectorBase's memory size to newsize
.
Definition at line 552 of file vectorbase.h.
Referenced by LPColSetBase< Rational >::reMax(), LPRowSetBase< R >::reMax(), and SSVectorBase< Rational >::reMem().
VectorBase<R>& scaleAssign | ( | int | scaleExp, |
const VectorBase< R > & | vec | ||
) |
scale and assign
Definition at line 186 of file vectorbase.h.
VectorBase<R>& scaleAssign | ( | const int * | scaleExp, |
const VectorBase< R > & | vec, | ||
bool | negateExp = false |
||
) |
scale and assign
Definition at line 203 of file vectorbase.h.
const std::vector<R>& vec | ( | ) |
Return underlying std::vector.
Definition at line 288 of file vectorbase.h.
Referenced by SSVectorBase< Rational >::operator+=(), VectorBase< Rational >::operator=(), VectorBase< Rational >::scaleAssign(), and VectorBase< Rational >::VectorBase().
|
friend |
Definition at line 597 of file vectorbase.h.
|
friend |
Equality operator.
Definition at line 282 of file vectorbase.h.
|
friend |
Definition at line 83 of file vectorbase.h.
|
protected |
Values of vector.
Definition at line 93 of file vectorbase.h.
Referenced by VectorBase< Rational >::assign(), SSVectorBase< Rational >::assign2product1(), SSVectorBase< Rational >::assign2productAndSetup(), SSVectorBase< Rational >::assign2productFull(), SSVectorBase< Rational >::assign2productShort(), SSVectorBase< Rational >::assignPWproduct4setup(), VectorBase< Rational >::multAdd(), VectorBase< Rational >::operator*(), SSVectorBase< Rational >::operator*(), VectorBase< Rational >::operator+(), VectorBase< Rational >::operator-(), SSVectorBase< Rational >::operator=(), SSVectorBase< Rational >::setup_and_assign(), and VectorBase< Rational >::vec().