SoPlex
|
Dynamic sparse vectors. More...
#include <dsvectorbase.h>
Public Member Functions | |
~DSVectorBase () | |
Destructor (specialization for Real). | |
void | setMax (int newmax) |
Reset nonzero memory to >= newmax . | |
Construction, assignment, and destruction | |
DSVectorBase (int n=8) | |
Default constructor. | |
template<class S> | |
DSVectorBase (const SVectorBase< S > &old) | |
Copy constructor. | |
DSVectorBase (const DSVectorBase< R > &old) | |
Copy constructor. | |
template<class S> | |
DSVectorBase (const DSVectorBase< S > &old) | |
Copy constructor. | |
template<class S> | |
DSVectorBase (const VectorBase< S > &vec) | |
Copy constructor. | |
template<class S> | |
DSVectorBase (const SSVectorBase< S > &old) | |
Copy constructor. | |
template<class S> | |
DSVectorBase< R > & | operator= (const SVectorBase< S > &vec) |
Assignment operator. | |
DSVectorBase< R > & | operator= (const DSVectorBase< R > &vec) |
Assignment operator. | |
template<class S> | |
DSVectorBase< R > & | operator= (const DSVectorBase< S > &vec) |
Assignment operator. | |
template<class S> | |
DSVectorBase< R > & | operator= (const VectorBase< S > &vec) |
Assignment operator. | |
template<class S> | |
DSVectorBase< R > & | operator= (const SSVectorBase< S > &vec) |
Assignment operator. | |
virtual | ~DSVectorBase () |
Destructor. | |
Modification | |
template<class S> | |
void | add (const SVectorBase< S > &vec) |
Append nonzeros of sv . | |
void | add (int i, const R &v) |
Append one nonzero (i,v). | |
void | add (int i) |
Append one uninitialized nonzero. | |
void | add (int n, const int i[], const R v[]) |
Append n nonzeros. | |
void | setMax (int newmax=1) |
Reset nonzero memory to >= newmax . | |
Utilities | |
bool | isConsistent () const |
Consistency check. | |
![]() | |
SVectorBase< Real > & | operator= (const VectorBase< S > &vec) |
Assignment operator (specialization for Real). | |
Real | operator* (const SVectorBase< S > &w) const |
specialization for inner product for sparse vectors | |
int | size () const |
Number of used indices. | |
int | max () const |
Maximal number of indices. | |
int | dim () const |
Dimension of the vector defined as maximal index + 1. | |
int | pos (int i) const |
Position of index i . | |
R | operator[] (int i) const |
Value to index i . | |
Nonzero< R > & | element (int n) |
Reference to the n 'th nonzero element. | |
const Nonzero< R > & | element (int n) const |
The n 'th nonzero element. | |
int & | index (int n) |
Reference to index of n 'th nonzero. | |
int | index (int n) const |
Index of n 'th nonzero. | |
R & | value (int n) |
Reference to value of n 'th nonzero. | |
const R & | value (int n) const |
Value of n 'th nonzero. | |
void | add (int i, const R &v) |
Append one nonzero (i,v). | |
void | add (int i) |
Append one uninitialized nonzero. | |
void | add (const SVectorBase &sv) |
Append nonzeros of sv . | |
void | add (int n, const int i[], const R v[]) |
Append n nonzeros. | |
template<class S> | |
void | add (int n, const int i[], const S v[]) |
Append n nonzeros. | |
void | add (int n, const Nonzero< R > e[]) |
Append n nonzeros. | |
void | remove (int n, int m) |
Remove nonzeros n thru m . | |
void | remove (int n) |
Remove n 'th nonzero. | |
void | clear () |
Remove all indices. | |
void | sort () |
Sort nonzeros to increasing indices. | |
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. | |
SVectorBase< R > & | operator*= (const R &x) |
Scaling. | |
R | operator* (const VectorBase< R > &w) const |
Inner product. | |
template<class S> | |
R | operator* (const SVectorBase< S > &w) const |
inner product for sparse vectors | |
SVectorBase (int n=0, Nonzero< R > *p_mem=nullptr) | |
Default constructor. | |
SVectorBase (const SVectorBase< R > &sv)=default | |
template<class S> | |
SVectorBase< R > & | operator= (const VectorBase< S > &vec) |
Assignment operator. | |
SVectorBase< R > & | operator= (const SVectorBase< R > &sv) |
Assignment operator. | |
SVectorBase< R > & | operator= (const SVectorBase< R > &&sv) |
move assignement operator. | |
template<class S> | |
SVectorBase< R > & | operator= (const SVectorBase< S > &sv) |
Assignment operator. | |
SVectorBase< Real > & | scaleAssign (int scaleExp, const SVectorBase< Real > &sv) |
scale and assign | |
SVectorBase< Real > & | scaleAssign (const int *scaleExp, const SVectorBase< Real > &sv, bool negateExp=false) |
scale and assign | |
template<class S> | |
SVectorBase< R > & | assignArray (const S *rowValues, const int *rowIndices, int rowSize) |
Assignment operator. | |
template<class S> | |
SVectorBase< R > & | operator= (const SSVectorBase< S > &sv) |
Assignment operator. | |
Nonzero< R > * | mem () const |
get pointer to internal memory. | |
void | set_size (int s) |
Set size of the vector. | |
void | set_max (int m) |
Set the maximum number of nonzeros in the vector. | |
void | setMem (int n, Nonzero< R > *elmem) |
Set the memory area where the nonzeros will be stored. | |
bool | isConsistent () const |
Consistency check. | |
bool | hasNaNs () const |
Checks whether the array contains any nan entries. | |
bool | hasInfs () const |
Checks whether the array contains any NaN entries. | |
Private Member Functions | |
void | allocMem (int n) |
Allocate memory for n nonzeros (specialization for Real). | |
Private helpers | |
void | allocMem (int n) |
Allocate memory for n nonzeros. | |
void | makeMem (int n) |
Ensure there is room for n new nonzeros. | |
Private Attributes | |
Data | |
Nonzero< R > * | theelem |
Memory. | |
Friends | |
class | SLinSolver< R > |
Additional Inherited Members | |
![]() | |
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.
Referenced by operator=(), and operator=().
Copy constructor.
Definition at line 116 of file dsvectorbase.h.
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.
Copy constructor.
Definition at line 141 of file dsvectorbase.h.
Copy constructor.
Definition at line 1072 of file basevectors.h.
References allocMem(), VectorBase< R >::dim(), isConsistent(), and theelem.
Copy constructor.
Definition at line 1087 of file basevectors.h.
References allocMem(), isConsistent(), SVectorBase< R >::operator=(), SSVectorBase< R >::size(), and theelem.
|
virtual |
Destructor.
Definition at line 209 of file dsvectorbase.h.
~DSVectorBase | ( | ) |
Destructor (specialization for Real).
Definition at line 334 of file dsvectorbase.h.
Append nonzeros of sv
.
Definition at line 228 of file dsvectorbase.h.
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.
void add | ( | int | i, |
const R & | v ) |
Append one nonzero (i,v).
Definition at line 236 of file dsvectorbase.h.
void add | ( | int | n, |
const int | i[], | ||
const R | v[] ) |
Append n
nonzeros.
Definition at line 250 of file dsvectorbase.h.
|
private |
Allocate memory for n
nonzeros.
Definition at line 72 of file dsvectorbase.h.
Referenced by DSVectorBase(), DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), and DSVectorBase< Real >::DSVectorBase().
|
private |
Allocate memory for n
nonzeros (specialization for Real).
Definition at line 323 of file dsvectorbase.h.
bool isConsistent | ( | ) | const |
Consistency check.
Definition at line 303 of file dsvectorbase.h.
Referenced by DSVectorBase(), DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), DSVectorBase< Real >::DSVectorBase(), and operator=().
|
private |
Ensure there is room for n
new nonzeros.
Definition at line 83 of file dsvectorbase.h.
Referenced by DSVectorBase< Real >::add(), DSVectorBase< Real >::add(), DSVectorBase< Real >::add(), DSVectorBase< Real >::add(), operator=(), DSVectorBase< Real >::operator=(), DSVectorBase< Real >::operator=(), and DSVectorBase< Real >::operator=().
DSVectorBase< R > & operator= | ( | const DSVectorBase< R > & | vec | ) |
Assignment operator.
Definition at line 174 of file dsvectorbase.h.
Assignment operator.
Definition at line 188 of file dsvectorbase.h.
Assignment operator.
Definition at line 1121 of file basevectors.h.
References SVectorBase< R >::clear(), DSVectorBase(), makeMem(), SVectorBase< R >::operator=(), and SSVectorBase< R >::size().
Assignment operator.
Definition at line 161 of file dsvectorbase.h.
Assignment operator.
Definition at line 1102 of file basevectors.h.
References SVectorBase< R >::clear(), VectorBase< R >::dim(), DSVectorBase(), isConsistent(), SVectorBase< R >::operator=(), and setMax().
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.
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.
Referenced by DSVectorBase< Real >::makeMem(), and operator=().
|
friend |
Definition at line 348 of file dsvectorbase.h.
|
private |
Memory.
Definition at line 63 of file dsvectorbase.h.
Referenced by DSVectorBase(), and DSVectorBase().