SoPlex
|
Dense Vector with semi-sparse Vector for updates. More...
#include <updatevector.h>
Public Member Functions | |
Constructors / destructors | |
UpdateVector (int p_dim, std::shared_ptr< Tolerances > tols=nullptr) | |
default constructor. | |
~UpdateVector () | |
UpdateVector (const UpdateVector< R > &) | |
copy constructor | |
UpdateVector< R > & | operator= (const VectorBase< R > &rhs) |
assignment from VectorBase<R> | |
UpdateVector< R > & | operator= (const UpdateVector< R > &rhs) |
assignment | |
Access | |
R & | value () |
update multiplicator \(\alpha\), writeable | |
R | value () const |
update multiplicator \(\alpha\) | |
SSVectorBase< R > & | delta () |
update VectorBase<R> \(\delta\), writeable | |
const SSVectorBase< R > & | delta () const |
update VectorBase<R> \(\delta\) | |
const IdxSet & | idx () const |
nonzero indices of update VectorBase<R> \(\delta\) | |
Modification | |
void | update () |
Perform the update. | |
void | clear () |
clear VectorBase<R> and update vector | |
void | clearUpdate () |
clear \(\delta\), \(\alpha\) | |
void | reDim (int newdim) |
reset dimension | |
void | setTolerances (std::shared_ptr< Tolerances > &tolerances) |
set tolerances | |
Consistency check | |
bool | isConsistent () const |
![]() | |
bool | isConsistent () const |
Consistency check. | |
Rational | operator* (const VectorBase< Rational > &vec) const |
Inner product. | |
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 . | |
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. | |
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. | |
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 |
Private Attributes | |
Data | |
R | theval |
update multiplicator | |
SSVectorBase< R > | thedelta |
update vector | |
Additional Inherited Members | |
![]() | |
std::vector< R > | val |
Values of vector. | |
Dense Vector with semi-sparse Vector for updates.
In many algorithms vectors are updated in every iteration, by adding a multiple of another VectorBase<R> to it, i.e., given a VectorBase<R> x
, a scalar \(\alpha\) and another VectorBase<R> \(\delta\), the update to x
constists of substituting it by \(x \leftarrow x +
\alpha\cdot\delta\).
While the update itself can easily be expressed with methods of the class VectorBase<R>, it is often desirable to save the last update VectorBase<R> \(\delta\) and value \(\alpha\). This is provided by class UpdateVector<R>.
UpdateVectors are derived from VectorBase<R> and provide additional methods for saving and setting the multiplicator \(\alpha\) and the update Vector \(\delta\). Further, it allows for efficient sparse updates, by providing an IdxSet idx() containing the nonzero indices of \(\delta\).
Definition at line 62 of file updatevector.h.
|
explicit |
default constructor.
Definition at line 80 of file updatevector.h.
References isConsistent(), thedelta, theval, and VectorBase< R >::VectorBase.
Referenced by operator=(), operator=(), and UpdateVector().
~UpdateVector | ( | ) |
Definition at line 88 of file updatevector.h.
UpdateVector | ( | const UpdateVector< R > & | ) |
copy constructor
References UpdateVector().
void clear | ( | ) |
clear VectorBase<R> and update vector
Definition at line 153 of file updatevector.h.
References VectorBase< R >::clear(), and clearUpdate().
void clearUpdate | ( | ) |
clear \(\delta\), \(\alpha\)
Definition at line 160 of file updatevector.h.
References thedelta, and theval.
Referenced by clear().
SSVectorBase< R > & delta | ( | ) |
update VectorBase<R> \(\delta\), writeable
Definition at line 122 of file updatevector.h.
References thedelta.
const SSVectorBase< R > & delta | ( | ) | const |
const IdxSet & idx | ( | ) | const |
nonzero indices of update VectorBase<R> \(\delta\)
Definition at line 133 of file updatevector.h.
References thedelta.
bool isConsistent | ( | ) | const |
Referenced by operator=(), and UpdateVector().
UpdateVector< R > & operator= | ( | const UpdateVector< R > & | rhs | ) |
assignment
References UpdateVector().
UpdateVector< R > & operator= | ( | const VectorBase< R > & | rhs | ) |
assignment from VectorBase<R>
Definition at line 93 of file updatevector.h.
References isConsistent(), VectorBase< R >::operator=(), UpdateVector(), and VectorBase< R >::VectorBase.
void reDim | ( | int | newdim | ) |
reset dimension
Definition at line 167 of file updatevector.h.
References VectorBase< R >::reDim(), and thedelta.
void setTolerances | ( | std::shared_ptr< Tolerances > & | tolerances | ) |
set tolerances
Definition at line 174 of file updatevector.h.
References thedelta.
Referenced by SPxSolverBase< Real >::setTolerances().
void update | ( | ) |
Perform the update.
Add value()
* delta()
to the UpdateVector<R>. Only the indices in idx() are affected. For all other indices, delta() is asumed to be 0.
Definition at line 147 of file updatevector.h.
References VectorBase< R >::multAdd(), and thedelta.
R & value | ( | ) |
update multiplicator \(\alpha\), writeable
Definition at line 111 of file updatevector.h.
References theval.
R value | ( | ) | const |
|
private |
update vector
Definition at line 70 of file updatevector.h.
Referenced by clearUpdate(), delta(), delta(), idx(), reDim(), setTolerances(), update(), and UpdateVector().
|
private |
update multiplicator
Definition at line 69 of file updatevector.h.
Referenced by clearUpdate(), UpdateVector(), value(), and value().