|
Loading...
Searching...
No Matches
Sparse vectors.
More...
#include <svectorbase.h>
|
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.
|
|
template<class R>
class soplex::SVectorBase< R > Sparse vectors.
Class SVectorBase provides packed sparse vectors. Such are a sparse vectors, with a storage scheme that keeps all data in one contiguous block of memory. This is best suited for using them for parallel computing on a distributed memory multiprocessor.
SVectorBase does not provide any memory management (this will be done by class DSVectorBase). This means, that the constructor of SVectorBase expects memory where to save the nonzeros. Further, adding nonzeros to an SVectorBase may fail if no more memory is available for saving them (see also DSVectorBase).
When nonzeros are added to an SVectorBase, they are appended to the set of nonzeros, i.e., they recieve numbers size(), size()+1 ... . An SVectorBase can hold atmost max() nonzeros, where max() is given in the constructor. When removing nonzeros, the remaining nonzeros are renumbered. However, only the numbers greater than the number of the first removed nonzero are affected.
The following mathematical operations are provided by class SVectorBase (SVectorBase a , b , c ; R x ):
Operation | Description | |
-= | subtraction | a -= b |
+= | addition | a += b |
* | skalar product | x = a * b |
*= | scaling | a *= x |
maxAbs() | infinity norm | a.maxAbs() == \(\|a\|_{\infty}\) |
length() | eucledian norm | a.length() == \(\sqrt{a^2}\) |
length2() | square norm | a.length2() == \(a^2\) |
Operators += and -= should be used with caution, since no efficient implementation is available. One should think of assigning the left handside vector to a dense VectorBase first and perform the addition on it. The same applies to the scalar product * .
There are two numberings of the nonzeros of an SVectorBase. First, an SVectorBase is supposed to act like a linear algebra VectorBase. An index refers to this view of an SVectorBase: operator[]() is provided which returns the value at the given index of the vector, i.e., 0 for all indices which are not in the set of nonzeros. The other view of SVectorBases is that of a set of nonzeros. The nonzeros are numbered from 0 to size()-1. The methods index(int
n) and value(int n) allow to access the index and value of the n 'th nonzero. n is referred to as the number of a nonzero.
- Todo
- SVectorBase should get a new implementation. There maybe a lot of memory lost due to padding the Nonzero structure. A better idea seems to be class SVectorBase { int size; int used; int* idx; R* val; }; which for several reasons could be faster or slower. If SVectorBase is changed, also DSVectorBase and SVSet have to be modified.
Definition at line 44 of file vectorbase.h.
◆ Element
◆ SVectorBase() [1/2]
Default constructor.
The constructor expects one memory block where to store the nonzero elements. This must be passed to the constructor, where the number of Nonzeros needs that fit into the memory must be given and a pointer to the beginning of the memory block. Once this memory has been passed, it shall not be modified until the SVectorBase is no longer used.
Definition at line 625 of file svectorbase.h.
References SVectorBase< R >::setMem().
◆ SVectorBase() [2/2]
◆ add() [1/6]
◆ add() [2/6]
◆ add() [3/6]
template<class R >
void add |
( |
int | i, |
|
|
const R & | v ) |
Append one nonzero (i,v).
Definition at line 282 of file svectorbase.h.
References SVectorBase< R >::m_elem, SVectorBase< R >::max(), SVectorBase< R >::set_size(), and SVectorBase< R >::size().
Referenced by DSVectorBase< R >::add(), DSVectorBase< R >::add(), DSVectorBase< R >::add(), DSVectorBase< R >::add(), SVectorBase< R >::add(), SVSetBase< R >::add2(), SVSetBase< R >::add2(), SVSetBase< R >::add2(), and UnitVectorBase< R >::UnitVectorBase().
◆ add() [4/6]
template<class R >
void add |
( |
int | n, |
|
|
const int | i[], |
|
|
const R | v[] ) |
◆ add() [5/6]
template<class R >
template<class S >
void add |
( |
int | n, |
|
|
const int | i[], |
|
|
const S | v[] ) |
◆ add() [6/6]
template<class R >
void add |
( |
int | n, |
|
|
const Nonzero< R > | e[] ) |
◆ assignArray()
template<class R >
template<class S >
SVectorBase< R > & assignArray |
( |
const S * | rowValues, |
|
|
const int * | rowIndices, |
|
|
int | rowSize ) |
◆ clear()
◆ dim()
◆ element() [1/2]
◆ element() [2/2]
template<class R >
const Nonzero< R > & element |
( |
int | n | ) |
const |
◆ index() [1/2]
Reference to index of n 'th nonzero.
Definition at line 246 of file svectorbase.h.
References SVectorBase< R >::m_elem, and SVectorBase< R >::size().
Referenced by SPxLPBase< R >::addCols(), SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::added2Set(), SPxLPBase< R >::addPrimalActivity(), SPxLPBase< R >::addRows(), SSVectorBase< R >::assign(), SSVectorBase< R >::assign(), VectorBase< R >::assign(), SPxLPBase< R >::changeCol(), SPxLPBase< R >::changeRow(), SPxLPBase< R >::doAddCol(), SPxLPBase< R >::doAddCol(), SPxLPBase< R >::doAddCols(), SPxLPBase< R >::doAddRow(), SPxLPBase< R >::doAddRow(), SPxLPBase< R >::doAddRows(), SPxLPBase< R >::doRemoveCol(), SPxLPBase< R >::doRemoveCols(), SPxLPBase< R >::doRemoveRow(), SPxLPBase< R >::doRemoveRows(), DSVectorBase< BP >::DSVectorBase(), SPxMainSM< R >::DuplicateRowsPS::DuplicateRowsPS(), SPxLPBase< R >::isConsistent(), VectorBase< R >::multAdd(), VectorBase< R >::multSub(), soplex::operator*(), VectorBase< R >::operator*(), VectorBase< Rational >::operator*(), VectorBase< R >::operator-=(), soplex::operator<<(), VectorBase< R >::operator=(), SVectorBase< R >::pos(), SVectorBase< R >::scaleAssign(), SVectorBase< R >::scaleAssign(), SoPlex_getRowVectorRational(), and SoPlex_getRowVectorReal().
◆ index() [2/2]
◆ isConsistent()
template<class R >
bool isConsistent |
( |
| ) |
const |
◆ length()
◆ length2()
◆ max()
Maximal number of indices.
Definition at line 171 of file svectorbase.h.
References SVectorBase< R >::m_elem, SVectorBase< R >::memsize, and SVectorBase< R >::memused.
Referenced by SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::assignArray(), SVSetBase< R >::deleteVec(), SVectorBase< R >::element(), SVSetBase< R >::ensureMem(), SVectorBase< R >::isConsistent(), SVSetBase< R >::isConsistent(), UnitVectorBase< R >::isConsistent(), SVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SVSetBase< R >::operator=(), SVectorBase< R >::scaleAssign(), SVectorBase< R >::scaleAssign(), and SVSetBase< R >::xtend().
◆ maxAbs()
◆ mem()
◆ minAbs()
◆ operator*() [1/3]
template<class R >
template<class S >
◆ operator*() [2/3]
◆ operator*() [3/3]
◆ operator*=()
◆ operator=() [1/6]
template<class R >
template<class S >
◆ operator=() [2/6]
◆ operator=() [3/6]
◆ operator=() [4/6]
template<class R >
template<class S >
◆ operator=() [5/6]
◆ operator=() [6/6]
template<class R >
template<class S >
Assignment operator.
Definition at line 951 of file basevectors.h.
References VectorBase< R >::dim(), Nonzero< R >::idx, and Nonzero< R >::val.
Referenced by DSVectorBase< R >::DSVectorBase(), DSVectorBase< R >::DSVectorBase(), DSVectorBase< R >::DSVectorBase(), DSVectorBase< R >::DSVectorBase(), DSVectorBase< R >::operator=(), DSVectorBase< R >::operator=(), DSVectorBase< R >::operator=(), SVSetBase< R >::DLPSV::operator=(), and SVSetBase< R >::DLPSV::operator=().
◆ operator[]()
template<class R >
R operator[] |
( |
int | i | ) |
const |
◆ pos()
Position of index i .
- Returns
- Finds the position of the first index
i in the index set. If no such index i is found, -1 is returned. Otherwise, index(pos(i)) == i holds.
Definition at line 197 of file svectorbase.h.
References SVectorBase< R >::index(), SVectorBase< R >::m_elem, and SVectorBase< R >::size().
Referenced by SPxLPBase< R >::changeCol(), SPxLPBase< R >::changeElement(), SPxLPBase< R >::changeElement(), SPxLPBase< R >::changeRow(), SPxLPBase< R >::doRemoveCol(), SPxLPBase< R >::doRemoveRow(), SPxLPBase< R >::isConsistent(), and SVectorBase< R >::operator[]().
◆ remove() [1/2]
◆ remove() [2/2]
template<class R >
void remove |
( |
int | n, |
|
|
int | m ) |
◆ scaleAssign() [1/2]
◆ scaleAssign() [2/2]
◆ set_max()
◆ set_size()
Set size of the vector.
Definition at line 799 of file svectorbase.h.
References SVectorBase< R >::m_elem, and SVectorBase< R >::memused.
Referenced by SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::assignArray(), SVectorBase< R >::clear(), SVSetBase< R >::deleteVec(), SVSetBase< R >::memPack(), SVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SVSetBase< R >::operator=(), UnitVectorBase< R >::operator=(), UnitVectorBase< R >::operator=(), SVectorBase< R >::remove(), SVectorBase< R >::remove(), DSVectorBase< R >::setMax(), SVectorBase< R >::setMem(), UnitVectorBase< R >::UnitVectorBase(), and SVSetBase< R >::xtend().
◆ setMem()
template<class R >
void setMem |
( |
int | n, |
|
|
Nonzero< R > * | elmem ) |
◆ size()
Number of used indices.
Definition at line 164 of file svectorbase.h.
References SVectorBase< R >::m_elem, and SVectorBase< R >::memused.
Referenced by DSVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVSetBase< R >::add(), SVSetBase< R >::add(), SVSetBase< R >::add2(), SVSetBase< R >::add2(), SVSetBase< R >::add2(), SPxLPBase< R >::addCols(), SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::added2Set(), SPxLPBase< R >::addPrimalActivity(), SPxLPBase< R >::addRows(), SSVectorBase< R >::assign(), SSVectorBase< R >::assign(), VectorBase< R >::assign(), SSVectorBase< R >::assign2product1(), SSVectorBase< R >::assign2productAndSetup(), SSVectorBase< R >::assign2productFull(), SSVectorBase< R >::assign2productShort(), SPxLPBase< R >::changeCol(), SPxLPBase< R >::changeRow(), SPxBasisBase< R >::coSolve(), SVSetBase< R >::deleteVec(), SVectorBase< R >::dim(), SPxLPBase< R >::doAddCol(), SPxLPBase< R >::doAddCol(), SPxLPBase< R >::doAddCols(), SPxLPBase< R >::doAddRow(), SPxLPBase< R >::doAddRow(), SPxLPBase< R >::doAddRows(), SPxLPBase< R >::doRemoveCol(), SPxLPBase< R >::doRemoveCols(), SPxLPBase< R >::doRemoveRow(), SPxLPBase< R >::doRemoveRows(), DSVectorBase< R >::DSVectorBase(), DSVectorBase< R >::DSVectorBase(), DSVectorBase< R >::DSVectorBase(), DSVectorBase< BP >::DSVectorBase(), SPxMainSM< R >::DuplicateRowsPS::DuplicateRowsPS(), SVectorBase< R >::element(), SVSetBase< R >::ensureMem(), SVectorBase< R >::index(), SVectorBase< R >::index(), SPxLPBase< R >::isConsistent(), SVectorBase< R >::isConsistent(), UnitVectorBase< R >::isConsistent(), SVectorBase< R >::length2(), SVectorBase< R >::maxAbs(), SVSetBase< R >::memPack(), SVectorBase< R >::minAbs(), SSVectorBase< R >::multAdd(), VectorBase< R >::multAdd(), VectorBase< R >::multSub(), soplex::operator*(), SVectorBase< R >::operator*(), VectorBase< R >::operator*(), SVectorBase< R >::operator*=(), VectorBase< R >::operator-=(), soplex::operator<<(), DSVectorBase< R >::operator=(), DSVectorBase< R >::operator=(), DSVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SVSetBase< R >::operator=(), VectorBase< R >::operator=(), SVectorBase< R >::pos(), SVectorBase< R >::remove(), SVectorBase< R >::remove(), SVectorBase< R >::scaleAssign(), SVectorBase< R >::scaleAssign(), DSVectorBase< R >::setMax(), SPxBasisBase< R >::solve(), SPxBasisBase< R >::solve4update(), SoPlex_getRowVectorRational(), SoPlex_getRowVectorReal(), SVectorBase< R >::sort(), SVectorBase< R >::value(), SVectorBase< R >::value(), and SVSetBase< R >::xtend().
◆ sort()
◆ value() [1/2]
Reference to value of n 'th nonzero.
Definition at line 264 of file svectorbase.h.
References SVectorBase< R >::m_elem, and SVectorBase< R >::size().
Referenced by SPxLPBase< R >::addCols(), SPxLPBase< R >::addDualActivity(), SPxLPBase< R >::added2Set(), SPxLPBase< R >::addPrimalActivity(), SPxLPBase< R >::addRows(), SSVectorBase< R >::assign(), SSVectorBase< R >::assign(), VectorBase< R >::assign(), SPxLPBase< R >::changeCol(), SPxLPBase< R >::changeElement(), SPxLPBase< R >::changeElement(), SPxLPBase< R >::changeRow(), SPxLPBase< R >::doAddCol(), SPxLPBase< R >::doAddCol(), SPxLPBase< R >::doAddCols(), SPxLPBase< R >::doAddRow(), SPxLPBase< R >::doAddRow(), SPxLPBase< R >::doAddRows(), SPxLPBase< R >::isConsistent(), VectorBase< R >::multAdd(), VectorBase< R >::multSub(), soplex::operator*(), VectorBase< R >::operator*(), VectorBase< R >::operator-=(), soplex::operator<<(), VectorBase< R >::operator=(), SVectorBase< R >::scaleAssign(), SVectorBase< R >::scaleAssign(), SoPlex_getRowVectorRational(), and SoPlex_getRowVectorReal().
◆ value() [2/2]
template<class R >
const R & value |
( |
int | n | ) |
const |
◆ SVectorBase
template<class R >
template<class S >
◆ m_elem
Definition at line 149 of file svectorbase.h.
Referenced by SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::add(), SVectorBase< R >::assignArray(), SVectorBase< R >::dim(), SVectorBase< R >::element(), SVectorBase< R >::element(), SVectorBase< R >::index(), SVectorBase< R >::index(), SVectorBase< R >::isConsistent(), SVectorBase< R >::length2(), SVectorBase< R >::max(), SVectorBase< R >::maxAbs(), SVectorBase< R >::mem(), SVectorBase< R >::minAbs(), SVectorBase< R >::operator*(), SVectorBase< R >::operator*=(), SVectorBase< R >::operator=(), SVectorBase< R >::operator=(), SVectorBase< R >::operator[](), SVectorBase< R >::pos(), SVectorBase< R >::remove(), SVectorBase< R >::remove(), SVectorBase< R >::scaleAssign(), SVectorBase< R >::scaleAssign(), SVectorBase< R >::set_max(), SVectorBase< R >::set_size(), SVectorBase< R >::setMem(), SVectorBase< R >::size(), SVectorBase< R >::sort(), SVectorBase< R >::value(), and SVectorBase< R >::value().
◆ memsize
◆ memused
|