SoPlex
|
Dense vector. More...
#include <vectorbase.h>
Public Member Functions | |
bool | isConsistent () const |
Consistency check. | |
Rational | operator* (const VectorBase< Rational > &vec) const |
Inner product. | |
Construction and assignment | |
VectorBase () | |
Constructor. | |
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. | |
VectorBase< R > & | operator= (const VectorBase< R > &vec) |
Assignment operator. | |
VectorBase< R > & | operator= (const VectorBase< R > &&vec) |
Move assignment operator. | |
VectorBase< R > & | scaleAssign (int scaleExp, const VectorBase< R > &vec) |
scale and assign | |
VectorBase< R > & | scaleAssign (const int *scaleExp, const VectorBase< R > &vec, bool negateExp=false) |
scale and assign | |
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 . | |
Arithmetic operations | |
void | clear () |
Set vector to contain all-zeros (keeping the same length) | |
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. | |
R | operator* (const VectorBase< R > &vec) const |
Inner product. | |
R | operator* (const SVectorBase< R > &vec) const |
Inner product. | |
R | operator* (const SSVectorBase< R > &vec) const |
Inner product. | |
R | maxAbs () const |
Maximum absolute value, i.e., infinity norm. | |
R | minAbs () const |
Minimum absolute value. | |
R | length () const |
Floating point approximation of euclidian norm (without any approximation guarantee). | |
R | 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. |
Protected Attributes | |
Data | |
std::vector< R > | val |
Values of vector. |
Friends | |
template<typename S> | |
class | VectorBase |
Access | |
bool | operator== (const VectorBase< R > &vec1, const VectorBase< R > &vec2) |
Equality operator. | |
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. | |
const std::vector< R > & | vec () |
Return underlying std::vector. |
Utilities | |
VectorBase< R > | operator- (const VectorBase< R > &vec) |
R * | get_ptr () |
Conversion to C-style pointer. | |
const R * | get_const_ptr () const |
Conversion to C-style pointer. | |
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 . | |
void | reSize (int newsize) |
Resets VectorBase's memory size to newsize . | |
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
infinity norm
a.maxAbs()
== \(\|a\|_{\infty}\)
a.minAbs()
== \(\min |a_i|\)
euclidian norm
a.length()
== \(\sqrt{a^2}\)
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.
|
explicit |
Definition at line 130 of file vectorbase.h.
Definition at line 138 of file vectorbase.h.
|
noexcept |
Definition at line 144 of file vectorbase.h.
VectorBase | ( | const VectorBase< R > & | vec | ) |
Definition at line 149 of file vectorbase.h.
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 dim(), operator=(), val, vec(), and VectorBase.
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 dim(), val, vec(), and VectorBase.
Referenced by operator=().
std::vector< R >::iterator begin | ( | ) |
Definition at line 514 of file vectorbase.h.
std::vector< R >::const_iterator begin | ( | ) | const |
Definition at line 509 of file vectorbase.h.
void clear | ( | ) |
Set vector to contain all-zeros (keeping the same length)
Definition at line 308 of file vectorbase.h.
Referenced by SSVectorBase< Real >::clear(), UpdateVector< R >::clear(), SPxBasisBase< Real >::coSolve(), operator=(), operator=(), SPxBasisBase< Real >::solve(), and SSVectorBase< Real >::SSVectorBase().
int dim | ( | ) | const |
Dimension of vector.
Definition at line 270 of file vectorbase.h.
Referenced by SPxLPBase< Real >::addDualActivity(), SPxLPBase< Real >::addPrimalActivity(), SSVectorBase< R >::assign(), SSVectorBase< Real >::assign(), assign(), assign(), SPxLPBase< Real >::changeLhs(), SPxLPBase< Real >::changeLower(), SPxLPBase< Real >::changeMaxObj(), SPxLPBase< Real >::changeRhs(), SPxLPBase< Real >::changeRowObj(), SPxLPBase< Real >::changeUpper(), SPxBasisBase< Real >::coSolve(), SSVectorBase< Real >::dim(), DSVectorBase< R >::DSVectorBase(), SSVectorBase< Real >::isConsistent(), VectorBase< Real >::maxAbs(), VectorBase< Real >::minAbs(), multAdd(), multAdd(), VectorBase< Real >::multAdd(), multSub(), operator*(), operator*(), VectorBase< Real >::operator*(), VectorBase< Real >::operator*=(), VectorBase< Real >::operator+(), operator+=(), operator+=(), VectorBase< Real >::operator+=(), soplex::operator-(), VectorBase< Real >::operator-(), operator-=(), operator-=(), VectorBase< Real >::operator-=(), VectorBase< Real >::operator/=(), soplex::operator<<(), DSVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SVectorBase< Real >::operator=(), operator=(), soplex::operator>>(), VectorBase< Real >::operator[](), VectorBase< Real >::operator[](), VectorBase< Real >::reDim(), VectorBase< Real >::reSize(), VectorBase< Real >::scaleAssign(), VectorBase< Real >::scaleAssign(), SSVectorBase< Real >::scaleValue(), SSVectorBase< Real >::setValue(), SPxBasisBase< Real >::solve(), and SPxLPBase< Real >::subDualActivity().
std::vector< R >::iterator end | ( | ) |
Definition at line 525 of file vectorbase.h.
std::vector< R >::const_iterator end | ( | ) | const |
Definition at line 520 of file vectorbase.h.
Referenced by SSVectorBase< R >::assign2productAndSetup().
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.
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.
Referenced by SSVectorBase< Real >::get_ptr().
bool isConsistent | ( | ) | const |
Consistency check.
Definition at line 622 of file vectorbase.h.
Referenced by SSVectorBase< Real >::isConsistent().
R length | ( | ) | const |
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition at line 445 of file vectorbase.h.
R length2 | ( | ) | const |
Squared norm.
Definition at line 451 of file vectorbase.h.
Referenced by VectorBase< Real >::length(), and SSVectorBase< Real >::length2().
R maxAbs | ( | ) | const |
Maximum absolute value, i.e., infinity norm.
Definition at line 405 of file vectorbase.h.
Referenced by SSVectorBase< Real >::maxAbs().
int memSize | ( | ) | const |
Definition at line 535 of file vectorbase.h.
Referenced by SSVectorBase< Real >::reDim(), and SSVectorBase< Real >::reMem().
R minAbs | ( | ) | const |
Minimum absolute value.
Definition at line 425 of file vectorbase.h.
VectorBase< R > & multAdd | ( | const S & | x, |
const SSVectorBase< T > & | vec ) |
Addition of scaled vector.
Definition at line 314 of file basevectors.h.
References dim(), val, vec(), and VectorBase.
VectorBase< R > & multAdd | ( | const S & | x, |
const SVectorBase< T > & | vec ) |
Addition of scaled vector.
Definition at line 280 of file basevectors.h.
References dim(), val, vec(), and VectorBase.
VectorBase< R > & multAdd | ( | const S & | x, |
const VectorBase< T > & | vec ) |
Addition of scaled vector.
Definition at line 458 of file vectorbase.h.
Referenced by SPxLPBase< Real >::addDualActivity(), SPxLPBase< Real >::addPrimalActivity(), SSVectorBase< R >::multAdd(), SSVectorBase< Real >::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 dim(), val, vec(), and VectorBase.
Referenced by SPxLPBase< Real >::subDualActivity().
R operator* | ( | const SSVectorBase< R > & | vec | ) | const |
R operator* | ( | const SVectorBase< R > & | vec | ) | const |
R operator* | ( | const VectorBase< R > & | vec | ) | const |
Inner product.
Definition at line 386 of file vectorbase.h.
Rational operator* | ( | const VectorBase< Rational > & | vec | ) | const |
Inner product.
Definition at line 632 of file vectorbase.h.
Scaling.
Definition at line 360 of file vectorbase.h.
const VectorBase< R > operator+ | ( | const VectorBase< R > & | v | ) | const |
Definition at line 588 of file vectorbase.h.
Addition.
Definition at line 170 of file basevectors.h.
References dim(), val, vec(), and VectorBase.
Addition.
Definition at line 152 of file basevectors.h.
References dim(), val, vec(), and VectorBase.
Addition.
Definition at line 316 of file vectorbase.h.
Referenced by SSVectorBase< R >::operator+=(), and SSVectorBase< Real >::operator+=().
const VectorBase< R > operator- | ( | const VectorBase< R > & | vec | ) | const |
Definition at line 571 of file vectorbase.h.
Subtraction.
Definition at line 212 of file basevectors.h.
References dim(), val, vec(), and VectorBase.
Subtraction.
Definition at line 194 of file basevectors.h.
References dim(), val, vec(), and VectorBase.
Subtraction.
Definition at line 338 of file vectorbase.h.
Referenced by SSVectorBase< R >::operator-=(), SSVectorBase< Real >::operator-=(), and SSVectorBase< Real >::operator-=().
Division.
Definition at line 373 of file vectorbase.h.
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 assign(), clear(), operator=(), vec(), and VectorBase.
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 clear(), dim(), val, vec(), and VectorBase.
VectorBase< R > & operator= | ( | const VectorBase< R > && | vec | ) |
Move assignment operator.
Definition at line 187 of file vectorbase.h.
VectorBase< R > & operator= | ( | const VectorBase< R > & | vec | ) |
Assignment operator.
Definition at line 174 of file vectorbase.h.
Assignment operator.
Definition at line 157 of file vectorbase.h.
Referenced by assign(), SSVectorBase< Real >::operator=(), UpdateVector< R >::operator=(), operator=(), and VectorBase< Real >::VectorBase().
R & operator[] | ( | int | n | ) |
Return n
'th value by reference.
Definition at line 276 of file vectorbase.h.
const R & operator[] | ( | int | n | ) | const |
Return n
'th value.
Definition at line 283 of file vectorbase.h.
void reDim | ( | int | newdim, |
const bool | setZero = true ) |
Resets VectorBase's dimension to newdim
.
Definition at line 541 of file vectorbase.h.
Referenced by SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), soplex::operator>>(), SSVectorBase< Real >::reDim(), UpdateVector< R >::reDim(), and SSVectorBase< Real >::setup_and_assign().
void reSize | ( | int | newsize | ) |
Resets VectorBase's memory size to newsize
.
Definition at line 560 of file vectorbase.h.
Referenced by SSVectorBase< Real >::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.
VectorBase< R > & scaleAssign | ( | int | scaleExp, |
const VectorBase< R > & | vec ) |
scale and assign
Definition at line 194 of file vectorbase.h.
const std::vector< R > & vec | ( | ) |
Return underlying std::vector.
Definition at line 296 of file vectorbase.h.
Referenced by assign(), assign(), SSVectorBase< R >::multAdd(), multAdd(), multAdd(), multSub(), operator*(), operator*(), SSVectorBase< R >::operator+=(), operator+=(), operator+=(), SSVectorBase< R >::operator-=(), operator-=(), operator-=(), operator=(), and operator=().
|
friend |
Definition at line 605 of file vectorbase.h.
|
friend |
Equality operator.
Definition at line 290 of file vectorbase.h.
Definition at line 91 of file vectorbase.h.
Referenced by assign(), assign(), multAdd(), multAdd(), multSub(), operator+=(), operator+=(), operator-=(), operator-=(), UpdateVector< R >::operator=(), operator=(), operator=(), and UpdateVector< R >::UpdateVector().
|
protected |
Values of vector.
Definition at line 101 of file vectorbase.h.
Referenced by SSVectorBase< Real >::add(), SSVectorBase< Real >::altValues(), SSVectorBase< R >::assign(), assign(), assign(), SSVectorBase< R >::assign2product1(), SSVectorBase< BP >::assign2product1(), SSVectorBase< R >::assign2productAndSetup(), SSVectorBase< BP >::assign2productAndSetup(), SSVectorBase< R >::assign2productFull(), SSVectorBase< R >::assign2productShort(), SSVectorBase< Real >::clear(), SSVectorBase< Real >::clearIdx(), SSVectorBase< Real >::clearNum(), SSVectorBase< Real >::isConsistent(), SSVectorBase< Real >::length2(), SSVectorBase< Real >::maxAbs(), SSVectorBase< R >::multAdd(), multAdd(), multAdd(), multSub(), VectorBase< BP >::multSub(), SSVectorBase< Real >::operator*(), operator*(), SSVectorBase< Real >::operator*=(), VectorBase< Real >::operator+(), SSVectorBase< Real >::operator+=(), operator+=(), operator+=(), VectorBase< Real >::operator-, VectorBase< Real >::operator-(), SSVectorBase< Real >::operator-=(), operator-=(), operator-=(), SSVectorBase< Real >::operator=(), SSVectorBase< Real >::operator=(), operator=(), VectorBase< Real >::operator==, SSVectorBase< Real >::operator[](), SSVectorBase< Real >::scaleValue(), SSVectorBase< Real >::setup(), SSVectorBase< Real >::setup_and_assign(), SSVectorBase< Real >::setValue(), SSVectorBase< Real >::value(), and SSVectorBase< Real >::values().