Dense vector. More...
#include <vectorbase.h>
Public Member Functions | |
bool | isConsistent () const |
Consistency check. More... | |
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 85 of file vectorbase.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 117 of file vectorbase.h.
VectorBase | ( | int | dimen, |
R * | p_val | ||
) |
Definition at line 124 of file vectorbase.h.
References VectorBase< R >::val.
|
explicit |
Definition at line 130 of file vectorbase.h.
References VectorBase< R >::val.
VectorBase | ( | const VectorBase< S > & | vec | ) |
Definition at line 138 of file vectorbase.h.
References VectorBase< R >::operator=().
|
noexcept |
Definition at line 144 of file vectorbase.h.
VectorBase | ( | const VectorBase< R > & | vec | ) |
Definition at line 149 of file vectorbase.h.
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 126 of file basevectors.h.
References SSVectorBase< R >::dim(), SSVectorBase< R >::indexMem(), SSVectorBase< R >::isSetup(), SSVectorBase< R >::size(), and VectorBase< R >::val.
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 86 of file basevectors.h.
References SVectorBase< R >::index(), SVectorBase< R >::size(), and SVectorBase< R >::value().
std::vector< R >::iterator begin | ( | ) |
Definition at line 514 of file vectorbase.h.
References VectorBase< R >::val.
std::vector< R >::const_iterator begin | ( | ) | const |
Definition at line 509 of file vectorbase.h.
References VectorBase< R >::val.
void clear | ( | ) |
Set vector to contain all-zeros (keeping the same length)
Definition at line 308 of file vectorbase.h.
References VectorBase< R >::val.
Referenced by SSVectorBase< R >::clear(), UpdateVector< R >::clear(), SPxBasisBase< R >::coSolve(), SLUFactorRational::operator=(), SPxBasisBase< R >::solve(), and SSVectorBase< R >::SSVectorBase().
int dim | ( | ) | const |
Dimension of vector.
Definition at line 270 of file vectorbase.h.
References VectorBase< R >::val.
Referenced by SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::addPrimalActivity(), SPxLPBase< R >::changeLhs(), SPxLPBase< R >::changeLower(), SPxLPBase< R >::changeMaxObj(), SPxLPBase< R >::changeRhs(), SPxLPBase< R >::changeRowObj(), SPxLPBase< R >::changeUpper(), SPxBasisBase< R >::coSolve(), SSVectorBase< R >::dim(), DSVectorBase< R >::DSVectorBase(), VectorBase< R >::maxAbs(), VectorBase< R >::minAbs(), VectorBase< R >::multAdd(), VectorBase< R >::operator*(), VectorBase< R >::operator*=(), VectorBase< R >::operator+(), VectorBase< R >::operator+=(), soplex::operator-(), VectorBase< R >::operator-(), VectorBase< R >::operator-=(), VectorBase< R >::operator/=(), soplex::operator<<(), DSVectorBase< R >::operator=(), SVectorBase< R >::operator=(), soplex::operator>>(), VectorBase< R >::operator[](), VectorBase< R >::reDim(), VectorBase< R >::scaleAssign(), SLUFactorRational::SLUFactorRational(), SPxBasisBase< R >::solve(), and SPxLPBase< R >::subDualActivity().
std::vector< R >::iterator end | ( | ) |
Definition at line 525 of file vectorbase.h.
References VectorBase< R >::val.
std::vector< R >::const_iterator end | ( | ) | const |
Definition at line 520 of file vectorbase.h.
References VectorBase< R >::val.
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 503 of file vectorbase.h.
References VectorBase< R >::val.
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 494 of file vectorbase.h.
References VectorBase< R >::val.
Referenced by SSVectorBase< R >::get_ptr(), and SLUFactorRational::SLUFactorRational().
bool isConsistent | ( | ) | const |
Consistency check.
Definition at line 622 of file vectorbase.h.
Referenced by SSVectorBase< R >::isConsistent().
R length | ( | ) | const |
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition at line 445 of file vectorbase.h.
References VectorBase< R >::length2(), and soplex::spxSqrt().
R length2 | ( | ) | const |
Squared norm.
Definition at line 451 of file vectorbase.h.
Referenced by VectorBase< R >::length(), and SSVectorBase< R >::length2().
R maxAbs | ( | ) | const |
Maximum absolute value, i.e., infinity norm.
Definition at line 405 of file vectorbase.h.
References VectorBase< R >::dim(), soplex::spxAbs(), and VectorBase< R >::val.
Referenced by SSVectorBase< R >::maxAbs().
int memSize | ( | ) | const |
Definition at line 535 of file vectorbase.h.
References VectorBase< R >::val.
R minAbs | ( | ) | const |
Minimum absolute value.
Definition at line 425 of file vectorbase.h.
References VectorBase< R >::dim(), soplex::spxAbs(), and VectorBase< R >::val.
VectorBase< R > & multAdd | ( | const S & | x, |
const SSVectorBase< T > & | vec | ||
) |
Addition of scaled vector.
Definition at line 314 of file basevectors.h.
References SSVectorBase< R >::dim(), SSVectorBase< R >::indexMem(), SSVectorBase< R >::isSetup(), and SSVectorBase< R >::size().
VectorBase< R > & multAdd | ( | const S & | x, |
const SVectorBase< T > & | vec | ||
) |
Addition of scaled vector.
Definition at line 280 of file basevectors.h.
References SVectorBase< R >::index(), SVectorBase< R >::size(), and SVectorBase< R >::value().
VectorBase< R > & multAdd | ( | const S & | x, |
const VectorBase< T > & | vec | ||
) |
Addition of scaled vector.
Definition at line 458 of file vectorbase.h.
References VectorBase< R >::dim(), VectorBase< R >::val, and VectorBase< R >::vec().
Referenced by SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::addPrimalActivity(), SSVectorBase< R >::multAdd(), and UpdateVector< R >::update().
VectorBase< R > & multSub | ( | const S & | x, |
const SVectorBase< T > & | vec | ||
) |
Subtraction of scaled vector.
Definition at line 297 of file basevectors.h.
References SVectorBase< R >::index(), SVectorBase< R >::size(), and SVectorBase< R >::value().
Referenced by SPxLPBase< R >::subDualActivity().
R operator* | ( | const SSVectorBase< R > & | vec | ) | const |
R operator* | ( | const SVectorBase< R > & | vec | ) | const |
Inner product.
Definition at line 235 of file basevectors.h.
References SVectorBase< R >::dim(), SVectorBase< R >::index(), SVectorBase< R >::size(), and SVectorBase< R >::value().
R operator* | ( | const VectorBase< R > & | vec | ) | const |
Inner product.
Definition at line 386 of file vectorbase.h.
References VectorBase< R >::dim(), VectorBase< R >::val, and VectorBase< R >::vec().
Rational operator* | ( | const VectorBase< Rational > & | vec | ) | const |
Inner product.
Definition at line 632 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
VectorBase< R > & operator*= | ( | const S & | x | ) |
Scaling.
Definition at line 360 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
const VectorBase< R > operator+ | ( | const VectorBase< R > & | v | ) | const |
Definition at line 588 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
VectorBase< R > & operator+= | ( | const SSVectorBase< S > & | vec | ) |
Addition.
Definition at line 170 of file basevectors.h.
References SSVectorBase< R >::dim(), SSVectorBase< R >::index(), SSVectorBase< R >::isSetup(), SSVectorBase< R >::size(), and SSVectorBase< R >::value().
VectorBase< R > & operator+= | ( | const SVectorBase< S > & | vec | ) |
Addition.
Definition at line 152 of file basevectors.h.
VectorBase< R > & operator+= | ( | const VectorBase< S > & | vec | ) |
Addition.
Definition at line 316 of file vectorbase.h.
References VectorBase< R >::dim(), VectorBase< R >::val, and VectorBase< R >::vec().
Referenced by SSVectorBase< R >::operator+=().
const VectorBase< R > operator- | ( | const VectorBase< R > & | vec | ) | const |
Definition at line 571 of file vectorbase.h.
References VectorBase< R >::dim(), VectorBase< R >::val, and VectorBase< R >::vec().
VectorBase< R > & operator-= | ( | const SSVectorBase< S > & | vec | ) |
Subtraction.
Definition at line 212 of file basevectors.h.
References SSVectorBase< R >::dim(), SSVectorBase< R >::index(), SSVectorBase< R >::isSetup(), SSVectorBase< R >::size(), and SSVectorBase< R >::value().
VectorBase< R > & operator-= | ( | const SVectorBase< S > & | vec | ) |
Subtraction.
Definition at line 194 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 338 of file vectorbase.h.
References VectorBase< R >::dim(), VectorBase< R >::val, and VectorBase< R >::vec().
Referenced by SSVectorBase< R >::operator-=().
VectorBase< R > & operator/= | ( | const S & | x | ) |
Division.
Definition at line 373 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
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 106 of file basevectors.h.
References SSVectorBase< R >::isSetup().
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 66 of file basevectors.h.
References SVectorBase< R >::index(), SVectorBase< R >::size(), and SVectorBase< R >::value().
VectorBase< R > & operator= | ( | const VectorBase< R > && | vec | ) |
Move assignment operator.
Definition at line 187 of file vectorbase.h.
References VectorBase< R >::val, and VectorBase< R >::vec().
VectorBase< R > & operator= | ( | const VectorBase< R > & | vec | ) |
Assignment operator.
Definition at line 174 of file vectorbase.h.
References VectorBase< R >::val, and VectorBase< R >::vec().
VectorBase< R > & operator= | ( | const VectorBase< S > & | vec | ) |
Assignment operator.
Definition at line 157 of file vectorbase.h.
References VectorBase< R >::val, and VectorBase< R >::vec().
Referenced by UpdateVector< R >::operator=(), SSVectorBase< R >::operator=(), and VectorBase< R >::VectorBase().
R & operator[] | ( | int | n | ) |
Return n
'th value by reference.
Definition at line 276 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
const R & operator[] | ( | int | n | ) | const |
Return n
'th value.
Definition at line 283 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
void reDim | ( | int | newdim, |
const bool | setZero = true |
||
) |
Resets VectorBase's dimension to newdim
.
Definition at line 541 of file vectorbase.h.
References VectorBase< R >::dim(), and VectorBase< R >::val.
Referenced by SSVectorBase< R >::operator=(), soplex::operator>>(), SSVectorBase< R >::reDim(), UpdateVector< R >::reDim(), SSVectorBase< R >::setup_and_assign(), and SLUFactorRational::SLUFactorRational().
void reSize | ( | int | newsize | ) |
Resets VectorBase's memory size to newsize
.
Definition at line 560 of file vectorbase.h.
References VectorBase< R >::val.
Referenced by SSVectorBase< R >::reMem().
VectorBase< R > & scaleAssign | ( | const int * | scaleExp, |
const VectorBase< R > & | vec, | ||
bool | negateExp = false |
||
) |
scale and assign
Definition at line 211 of file vectorbase.h.
References VectorBase< R >::dim(), soplex::spxLdexp(), VectorBase< R >::val, and VectorBase< R >::vec().
VectorBase< R > & scaleAssign | ( | int | scaleExp, |
const VectorBase< R > & | vec | ||
) |
scale and assign
Definition at line 194 of file vectorbase.h.
References VectorBase< R >::dim(), soplex::spxLdexp(), VectorBase< R >::val, and VectorBase< R >::vec().
const std::vector< R > & vec | ( | ) |
Return underlying std::vector.
Definition at line 296 of file vectorbase.h.
References VectorBase< R >::val.
Referenced by VectorBase< R >::multAdd(), SSVectorBase< R >::multAdd(), VectorBase< R >::operator*(), SSVectorBase< R >::operator+=(), VectorBase< R >::operator+=(), VectorBase< R >::operator-(), SSVectorBase< R >::operator-=(), VectorBase< R >::operator-=(), VectorBase< R >::operator=(), VectorBase< R >::scaleAssign(), and SSVectorBase< R >::SSVectorBase().
|
friend |
Definition at line 605 of file vectorbase.h.
|
friend |
Equality operator.
Definition at line 290 of file vectorbase.h.
|
friend |
Definition at line 91 of file vectorbase.h.
|
protected |
Values of vector.
Definition at line 101 of file vectorbase.h.
Referenced by VectorBase< R >::assign(), VectorBase< Rational >::assign(), SSVectorBase< R >::assign2product1(), SSVectorBase< R >::assign2productAndSetup(), SSVectorBase< R >::assign2productFull(), SSVectorBase< R >::assign2productShort(), VectorBase< R >::begin(), VectorBase< R >::clear(), VectorBase< R >::dim(), VectorBase< R >::end(), VectorBase< R >::get_const_ptr(), VectorBase< R >::get_ptr(), VectorBase< R >::maxAbs(), VectorBase< R >::memSize(), VectorBase< R >::minAbs(), VectorBase< Rational >::multAdd(), VectorBase< R >::multAdd(), SSVectorBase< R >::operator*(), VectorBase< R >::operator*(), VectorBase< R >::operator*=(), VectorBase< R >::operator+(), VectorBase< R >::operator+=(), VectorBase< R >::operator-(), VectorBase< R >::operator-=(), VectorBase< R >::operator/=(), SSVectorBase< R >::operator=(), VectorBase< R >::operator=(), VectorBase< R >::operator[](), VectorBase< R >::reDim(), VectorBase< R >::reSize(), VectorBase< R >::scaleAssign(), SSVectorBase< R >::setup_and_assign(), VectorBase< R >::vec(), and VectorBase< R >::VectorBase().