Dynamic sparse vectors. More...
#include <dsvectorbase.h>
Public Member Functions | |
| ~DSVectorBase () | |
| Destructor (specialization for Real). More... | |
| void | setMax (int newmax) |
Reset nonzero memory to >= newmax. More... | |
Construction, assignment, and destruction | |
| DSVectorBase (int n=8) | |
| Default constructor. More... | |
| template<class S > | |
| DSVectorBase (const SVectorBase< S > &old) | |
| Copy constructor. More... | |
| DSVectorBase (const DSVectorBase< R > &old) | |
| Copy constructor. More... | |
| template<class S > | |
| DSVectorBase (const DSVectorBase< S > &old) | |
| Copy constructor. More... | |
| template<class S > | |
| DSVectorBase (const VectorBase< S > &vec) | |
| Copy constructor. More... | |
| template<class S > | |
| DSVectorBase (const SSVectorBase< S > &old) | |
| Copy constructor. More... | |
| template<class S > | |
| DSVectorBase< R > & | operator= (const SVectorBase< S > &vec) |
| Assignment operator. More... | |
| DSVectorBase< R > & | operator= (const DSVectorBase< R > &vec) |
| Assignment operator. More... | |
| template<class S > | |
| DSVectorBase< R > & | operator= (const DSVectorBase< S > &vec) |
| Assignment operator. More... | |
| template<class S > | |
| DSVectorBase< R > & | operator= (const VectorBase< S > &vec) |
| Assignment operator. More... | |
| template<class S > | |
| DSVectorBase< R > & | operator= (const SSVectorBase< S > &vec) |
| Assignment operator. More... | |
| virtual | ~DSVectorBase () |
| Destructor. More... | |
Modification | |
| template<class S > | |
| void | add (const SVectorBase< S > &vec) |
Append nonzeros of sv. More... | |
| void | add (int i, const R &v) |
Append one nonzero (i,v). More... | |
| void | add (int i) |
| Append one uninitialized nonzero. More... | |
| void | add (int n, const int i[], const R v[]) |
Append n nonzeros. More... | |
| void | setMax (int newmax=1) |
Reset nonzero memory to >= newmax. More... | |
Utilities | |
| bool | isConsistent () const |
| Consistency check. More... | |
Public Member Functions inherited from SVectorBase< R > | |
| SVectorBase< Real > & | operator= (const VectorBase< S > &vec) |
| Assignment operator (specialization for Real). More... | |
| Real | operator* (const SVectorBase< S > &w) const |
| specialization for inner product for sparse vectors More... | |
| int | size () const |
| Number of used indices. More... | |
| int | max () const |
| Maximal number of indices. More... | |
| int | dim () const |
| Dimension of the vector defined as maximal index + 1. More... | |
| int | pos (int i) const |
Position of index i. More... | |
| R | operator[] (int i) const |
Value to index i. More... | |
| Nonzero< R > & | element (int n) |
Reference to the n 'th nonzero element. More... | |
| const Nonzero< R > & | element (int n) const |
The n 'th nonzero element. More... | |
| int & | index (int n) |
Reference to index of n 'th nonzero. More... | |
| int | index (int n) const |
Index of n 'th nonzero. More... | |
| R & | value (int n) |
Reference to value of n 'th nonzero. More... | |
| const R & | value (int n) const |
Value of n 'th nonzero. More... | |
| void | add (int i, const R &v) |
Append one nonzero (i,v). More... | |
| void | add (int i) |
| Append one uninitialized nonzero. More... | |
| void | add (const SVectorBase &sv) |
Append nonzeros of sv. More... | |
| void | add (int n, const int i[], const R v[]) |
Append n nonzeros. More... | |
| template<class S > | |
| void | add (int n, const int i[], const S v[]) |
Append n nonzeros. More... | |
| void | add (int n, const Nonzero< R > e[]) |
Append n nonzeros. More... | |
| void | remove (int n, int m) |
Remove nonzeros n thru m. More... | |
| void | remove (int n) |
Remove n 'th nonzero. More... | |
| void | clear () |
| Remove all indices. More... | |
| void | sort () |
| Sort nonzeros to increasing indices. 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... | |
| SVectorBase< R > & | operator*= (const R &x) |
| Scaling. More... | |
| R | operator* (const VectorBase< R > &w) const |
| Inner product. More... | |
| template<class S > | |
| R | operator* (const SVectorBase< S > &w) const |
| inner product for sparse vectors More... | |
| SVectorBase (int n=0, Nonzero< R > *p_mem=nullptr) | |
| Default constructor. More... | |
| SVectorBase (const SVectorBase< R > &sv)=default | |
| template<class S > | |
| SVectorBase< R > & | operator= (const VectorBase< S > &vec) |
| Assignment operator. More... | |
| SVectorBase< R > & | operator= (const SVectorBase< R > &sv) |
| Assignment operator. More... | |
| SVectorBase< R > & | operator= (const SVectorBase< R > &&sv) |
| move assignement operator. More... | |
| template<class S > | |
| SVectorBase< R > & | operator= (const SVectorBase< S > &sv) |
| Assignment operator. More... | |
| SVectorBase< Real > & | scaleAssign (int scaleExp, const SVectorBase< Real > &sv) |
| scale and assign More... | |
| SVectorBase< Real > & | scaleAssign (const int *scaleExp, const SVectorBase< Real > &sv, bool negateExp=false) |
| scale and assign More... | |
| template<class S > | |
| SVectorBase< R > & | assignArray (const S *rowValues, const int *rowIndices, int rowSize) |
| Assignment operator. More... | |
| template<class S > | |
| SVectorBase< R > & | operator= (const SSVectorBase< S > &sv) |
| Assignment operator. More... | |
| Nonzero< R > * | mem () const |
| get pointer to internal memory. More... | |
| void | set_size (int s) |
| Set size of the vector. More... | |
| void | set_max (int m) |
| Set the maximum number of nonzeros in the vector. More... | |
| void | setMem (int n, Nonzero< R > *elmem) |
| Set the memory area where the nonzeros will be stored. More... | |
| bool | isConsistent () const |
| Consistency check. More... | |
| bool | hasNaNs () const |
| Checks whether the array contains any nan entries. More... | |
| bool | hasInfs () const |
| Checks whether the array contains any NaN entries. More... | |
Private Member Functions | |
| void | allocMem (int n) |
Allocate memory for n nonzeros (specialization for Real). More... | |
Private helpers | |
| void | allocMem (int n) |
Allocate memory for n nonzeros. More... | |
| void | makeMem (int n) |
Ensure there is room for n new nonzeros. More... | |
Private Attributes | |
Data | |
| Nonzero< R > * | theelem |
| Memory. More... | |
Friends | |
| class | SLinSolver< R > |
Additional Inherited Members | |
Public Types inherited from SVectorBase< R > | |
| typedef Nonzero< R > | Element |
Dynamic sparse vectors.
Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with an automatic memory management. This allows the user to freely add() as many nonzeros to a DSVectorBase as desired, without any precautions. For saving memory method setMax() allows to reduce memory consumption to the amount really required.
Definition at line 52 of file dsvectorbase.h.
|
explicit |
Default constructor.
Creates a DSVectorBase ready to hold n nonzeros. However, the memory is automatically enlarged, if more nonzeros are added to the DSVectorBase.
Definition at line 106 of file dsvectorbase.h.
References DSVectorBase< R >::allocMem(), and DSVectorBase< R >::isConsistent().
|
explicit |
Copy constructor.
Definition at line 116 of file dsvectorbase.h.
References DSVectorBase< R >::allocMem(), DSVectorBase< R >::isConsistent(), SVectorBase< R >::operator=(), and SVectorBase< R >::size().
| DSVectorBase | ( | const DSVectorBase< R > & | old | ) |
Copy constructor.
The redundancy with the copy constructor below is necessary since otherwise the compiler doesn't realize that it could use the more general one with S = R and generates a shallow copy constructor.
Definition at line 129 of file dsvectorbase.h.
References DSVectorBase< R >::allocMem(), DSVectorBase< R >::isConsistent(), SVectorBase< R >::operator=(), and SVectorBase< R >::size().
| DSVectorBase | ( | const DSVectorBase< S > & | old | ) |
Copy constructor.
Definition at line 141 of file dsvectorbase.h.
References DSVectorBase< R >::allocMem(), DSVectorBase< R >::isConsistent(), SVectorBase< R >::operator=(), and SVectorBase< R >::size().
|
explicit |
Copy constructor.
Definition at line 1063 of file basevectors.h.
References DSVectorBase< R >::allocMem(), VectorBase< R >::dim(), and DSVectorBase< R >::isConsistent().
|
explicit |
Copy constructor.
Definition at line 1078 of file basevectors.h.
References DSVectorBase< R >::allocMem(), DSVectorBase< R >::isConsistent(), SVectorBase< R >::operator=(), and SSVectorBase< R >::size().
|
virtual |
Destructor.
Definition at line 209 of file dsvectorbase.h.
References soplex::spx_free(), and DSVectorBase< R >::theelem.
| ~DSVectorBase | ( | ) |
Destructor (specialization for Real).
Definition at line 334 of file dsvectorbase.h.
References soplex::spx_free().
| void add | ( | const SVectorBase< S > & | vec | ) |
Append nonzeros of sv.
Definition at line 228 of file dsvectorbase.h.
References SVectorBase< R >::add(), SVectorBase< R >::clear(), DSVectorBase< R >::makeMem(), and SVectorBase< R >::size().
Referenced by soplex::operator*(), SoPlex_addColRational(), SoPlex_addColReal(), SoPlex_addRowRational(), SoPlex_addRowReal(), test_rational(), and test_real().
| void add | ( | int | i | ) |
Append one uninitialized nonzero.
Definition at line 243 of file dsvectorbase.h.
References SVectorBase< R >::add(), and DSVectorBase< R >::makeMem().
| void add | ( | int | i, |
| const R & | v | ||
| ) |
Append one nonzero (i,v).
Definition at line 236 of file dsvectorbase.h.
References SVectorBase< R >::add(), and DSVectorBase< R >::makeMem().
| void add | ( | int | n, |
| const int | i[], | ||
| const R | v[] | ||
| ) |
Append n nonzeros.
Definition at line 250 of file dsvectorbase.h.
References SVectorBase< R >::add(), and DSVectorBase< R >::makeMem().
|
private |
Allocate memory for n nonzeros.
Definition at line 72 of file dsvectorbase.h.
References SVectorBase< R >::setMem(), soplex::spx_alloc(), and DSVectorBase< R >::theelem.
Referenced by DSVectorBase< R >::DSVectorBase().
|
private |
Allocate memory for n nonzeros (specialization for Real).
Definition at line 323 of file dsvectorbase.h.
References SVectorBase< R >::setMem(), and soplex::spx_alloc().
| bool isConsistent | ( | ) | const |
Consistency check.
Definition at line 303 of file dsvectorbase.h.
References SPX_MSG_INCONSISTENT, and DSVectorBase< R >::theelem.
Referenced by DSVectorBase< R >::DSVectorBase().
|
private |
Ensure there is room for n new nonzeros.
Definition at line 83 of file dsvectorbase.h.
References DSVectorBase< R >::setMax().
Referenced by DSVectorBase< R >::add(), and DSVectorBase< R >::operator=().
| DSVectorBase< R > & operator= | ( | const DSVectorBase< R > & | vec | ) |
Assignment operator.
Definition at line 174 of file dsvectorbase.h.
References SVectorBase< R >::clear(), DSVectorBase< R >::makeMem(), SVectorBase< R >::operator=(), and SVectorBase< R >::size().
| DSVectorBase< R > & operator= | ( | const DSVectorBase< S > & | vec | ) |
Assignment operator.
Definition at line 188 of file dsvectorbase.h.
References SVectorBase< R >::clear(), DSVectorBase< R >::makeMem(), SVectorBase< R >::operator=(), and SVectorBase< R >::size().
| DSVectorBase< R > & operator= | ( | const SSVectorBase< S > & | vec | ) |
Assignment operator.
Definition at line 1112 of file basevectors.h.
References SVectorBase< R >::clear(), SVectorBase< R >::operator=(), and SSVectorBase< R >::size().
| DSVectorBase< R > & operator= | ( | const SVectorBase< S > & | vec | ) |
Assignment operator.
Definition at line 161 of file dsvectorbase.h.
References SVectorBase< R >::clear(), DSVectorBase< R >::makeMem(), SVectorBase< R >::operator=(), and SVectorBase< R >::size().
| DSVectorBase< R > & operator= | ( | const VectorBase< S > & | vec | ) |
Assignment operator.
Definition at line 1093 of file basevectors.h.
References SVectorBase< R >::clear(), VectorBase< R >::dim(), and SVectorBase< R >::operator=().
| void setMax | ( | int | newmax | ) |
Reset nonzero memory to >= newmax.
This methods resets the memory consumption to newmax. However, if newmax < size(), it is reset to size() only (specialization for Real).
Definition at line 348 of file dsvectorbase.h.
References soplex::spx_realloc().
| void setMax | ( | int | newmax = 1 | ) |
Reset nonzero memory to >= newmax.
This methods resets the memory consumption to newmax. However, if newmax < size(), it is reset to size() only.
Definition at line 260 of file dsvectorbase.h.
References SVectorBase< R >::set_size(), SVectorBase< R >::setMem(), SVectorBase< R >::size(), soplex::spx_alloc(), soplex::spx_free(), and DSVectorBase< R >::theelem.
Referenced by DSVectorBase< R >::makeMem().
|
friend |
Definition at line 348 of file dsvectorbase.h.
|
private |
Memory.
Definition at line 63 of file dsvectorbase.h.
Referenced by DSVectorBase< R >::allocMem(), DSVectorBase< R >::isConsistent(), DSVectorBase< R >::setMax(), and DSVectorBase< R >::~DSVectorBase().