SoPlex
Loading...
Searching...
No Matches
UnitVectorBase< R > Class Template Reference

Sparse vector \(e_i\). More...

#include <unitvectorbase.h>

Inheritance diagram for UnitVectorBase< R >:
SVectorBase< R >

Public Member Functions

Access
value (int n) const
 returns value = 1
Constructors / destructors
 UnitVectorBase (int i=0)
 construct i 'th unit vector.
 UnitVectorBase (const UnitVectorBase< R > &rhs)
 copy constructor
UnitVectorBase< R > & operator= (const UnitVectorBase< R > &rhs)
 assignment
UnitVectorBase< R > & operator= (UnitVectorBase< R > &&rhs)
 move assignment
 ~UnitVectorBase ()
 destructor
Miscellaneous
bool isConsistent () const
 consistency check
Public Member Functions inherited from SVectorBase< R >
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.
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.
maxAbs () const
 Maximum absolute value, i.e., infinity norm.
minAbs () const
 Minimum absolute value.
length () const
 Floating point approximation of euclidian norm (without any approximation guarantee).
length2 () const
 Squared norm.
SVectorBase< R > & operator*= (const R &x)
 Scaling.
operator* (const VectorBase< R > &w) const
 Inner product.
template<class S>
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 Attributes

Data
SVectorBase< R >::Element themem
 memory for sparse vector entry

Additional Inherited Members

Public Types inherited from SVectorBase< R >
typedef Nonzero< R > Element

Detailed Description

template<class R>
class soplex::UnitVectorBase< R >

Sparse vector \(e_i\).

A UnitVectorBase is an SVectorBase that can take only one nonzero value with value 1 but arbitrary index.

Todo
Several SVectorBase modification methods are still accessible for UnitVector. They might be used to change the vector.
Todo
UnitVectorBase memory management must be changed when SVectorBase is redesigned.

Definition at line 53 of file unitvectorbase.h.

Constructor & Destructor Documentation

◆ UnitVectorBase() [1/2]

template<class R>
UnitVectorBase ( int i = 0)
explicit

construct i 'th unit vector.

Definition at line 90 of file unitvectorbase.h.

◆ UnitVectorBase() [2/2]

template<class R>
UnitVectorBase ( const UnitVectorBase< R > & rhs)

copy constructor

Definition at line 99 of file unitvectorbase.h.

◆ ~UnitVectorBase()

template<class R>
~UnitVectorBase ( )

destructor

Definition at line 134 of file unitvectorbase.h.

Member Function Documentation

◆ isConsistent()

template<class R>
bool isConsistent ( ) const

◆ operator=() [1/2]

template<class R>
UnitVectorBase< R > & operator= ( const UnitVectorBase< R > & rhs)

assignment

Definition at line 108 of file unitvectorbase.h.

◆ operator=() [2/2]

template<class R>
UnitVectorBase< R > & operator= ( UnitVectorBase< R > && rhs)

move assignment

Definition at line 121 of file unitvectorbase.h.

◆ value()

template<class R>
R value ( int n) const

returns value = 1

Precondition
n must be 0.

Definition at line 78 of file unitvectorbase.h.

Member Data Documentation

◆ themem

template<class R>
SVectorBase<R>::Element themem
private

memory for sparse vector entry

Definition at line 60 of file unitvectorbase.h.

Referenced by UnitVectorBase< Real >::operator=(), and UnitVectorBase< Real >::UnitVectorBase().