SoPlex Doxygen Documentation

Dynamic vectors.Class DVector is a derived class of Vector adding automatic memory management to such objects. This allows to implement maths operations operator+() and operator-(). Further, it is possible to reset the dimension of a DVector via method reDim(). However, this may render all references to values of a reDim()ed DVector invalid. More...

#include <dvector.h>

Inheritance diagram for DVector:

Public Member Functions

Access
void reDim (int newdim)
 resets DVector's dimension to newdim.
 
void reSize (int newsize)
 resets DVector's memory size to newsize.
 
void reSize (int newsize, int newdim)
 resets DVector's memory size to newsize and dimension to newdim.
 
int memSize () const
 returns DVector's memory size.
 
bool isConsistent () const
 consistency check.
 
Construction / destruction
 DVector (int dim=0)
 default constructor. dim is the initial dimension.
 
 DVector (const Vector &old)
 copy constructor.
 
 DVector (const Vector_exact &old)
 cast from exact vector.
 
 DVector (const DVector &old)
 copy constructor.
 
DVectoroperator= (const Vector &vec)
 assignment operator.
 
DVectoroperator= (const DVector &vec)
 assignment operator.
 
DVectoroperator= (const SVector &vec)
 assingment operator.
 
 ~DVector ()
 destructor.
 
- Public Member Functions inherited from Vector
 Vector (int p_dimen, Real *p_val)
 construction
 
Vectoroperator= (const Vector &vec)
 Assignment operator.
 
Vectoroperator= (const SVector &vec)
 Assignment operator.
 
Vectoroperator= (const SSVector &vec)
 Assignment operator.
 
Vectoroperator= (const Vector_exact &vec)
 Assignment operator.
 
Vectorassign (const SVector &sv)
 Assign values of sv.
 
Vectorassign (const SSVector &sv)
 Assign values of sv.
 
int dim () const
 dimension of vector
 
Realoperator[] (int n)
 return n 'th value by reference
 
Real operator[] (int n) const
 return n 'th value
 
Vectoroperator+= (const Vector &vec)
 vector addition
 
Vectoroperator+= (const SVector &vec)
 vector addition
 
Vectoroperator+= (const SSVector &vec)
 vector addition
 
Vectoroperator-= (const Vector &vec)
 vector difference
 
Vectoroperator-= (const SVector &vec)
 vector difference
 
Vectoroperator-= (const SSVector &vec)
 vector difference
 
Vectoroperator*= (Real x)
 scaling
 
Real operator* (const SSVector &v) const
 inner product.
 
Real operator* (const SVector &v) const
 inner product.
 
Real operator* (const Vector &v) const
 inner product.
 
Real maxAbs () const
 absolute biggest element (infinity norm).
 
Real minAbs () const
 absolute smallest element.
 
Real length () const
 euclidian norm.
 
Real length2 () const
 squared norm.
 
VectormultAdd (Real x, const SVector &vec)
 addition of scaled vector
 
VectormultAdd (Real x, const SSVector &svec)
 addition of scaled vector
 
VectormultAdd (Real x, const Vector &vec)
 addition of scaled vector
 
Realget_ptr ()
 Conversion to C-style pointer.
 
const Realget_const_ptr () const
 Conversion to C-style pointer.
 
bool isConsistent () const
 consistency check.
 
void clear ()
 set vector to 0.
 

Private Attributes

Data
int memsize
 length of array of values mem
 
Realmem
 value array to be used
 

Friends

Arithmetic operations (friends)
DVector operator+ (const Vector &v, const Vector &w)
 adding vectors.
 
DVector operator+ (const SVector &v, const Vector &w)
 adding vectors.
 
DVector operator+ (const Vector &v, const SVector &w)
 adding vectors.
 
DVector operator- (const Vector &v, const Vector &w)
 subtracting vectors.
 
DVector operator- (const SVector &v, const Vector &w)
 subtracting vectors.
 
DVector operator- (const Vector &v, const SVector &w)
 subtracting vectors.
 
DVector operator- (const Vector &vec)
 negation operator.
 
DVector operator- (const SVector &vec)
 negation operator.
 
DVector operator* (const Vector &v, Real x)
 scaling vectors with a real number.
 
DVector operator* (Real x, const Vector &v)
 scaling vectors with a real number.
 
I/O
std::istream & operator>> (std::istream &s, DVector &vec)
 output operator.
 
- Friends inherited from Vector

Additional Inherited Members

- Protected Attributes inherited from Vector
int dimen
 dimension of vector
 
Realval
 values of a vector
 

Detailed Description

Dynamic vectors.

Class DVector is a derived class of Vector adding automatic memory management to such objects. This allows to implement maths operations operator+() and operator-(). Further, it is possible to reset the dimension of a DVector via method reDim(). However, this may render all references to values of a reDim()ed DVector invalid.

For vectors that are often subject to reDim() it may be unconvenient to reallocate the required memory every time. Instead, an array of values of length memSize() is kept, where only the first dim() elements are used. Initially, memSize() == dim(). However, if the dimension is increased, memSize() will be increased at least by a factor of 1.2 to be prepared for future (small) reDim()s. Finally, one can explicitly set memSize() with method reSize(), but not lower than dim().

Definition at line 53 of file dvector.h.

Constructor & Destructor Documentation

DVector ( int  dim = 0)
explicit

default constructor. dim is the initial dimension.

Definition at line 190 of file dvector.cpp.

References Vector::dimen, DVector::isConsistent(), DVector::mem, DVector::memsize, soplex::spx_alloc(), and Vector::val.

DVector ( const Vector old)
explicit
DVector ( const Vector_exact old)
explicit
DVector ( const DVector old)
~DVector ( )

destructor.

Definition at line 206 of file dvector.cpp.

References DVector::mem, and soplex::spx_free().

Member Function Documentation

int memSize ( ) const

returns DVector's memory size.

Definition at line 155 of file dvector.h.

References DVector::memsize.

Referenced by SSVector::reDim(), and SSVector::reMem().

DVector& operator= ( const Vector vec)

assignment operator.

Definition at line 177 of file dvector.h.

References Vector::dim(), DVector::isConsistent(), Vector::operator=(), and DVector::reDim().

Referenced by UpdateVector::operator=().

DVector& operator= ( const DVector vec)

assignment operator.

Definition at line 188 of file dvector.h.

References Vector::dim(), DVector::isConsistent(), Vector::operator=(), and DVector::reDim().

DVector& operator= ( const SVector vec)

assingment operator.

Definition at line 201 of file dvector.h.

References Vector::dim(), SVector::dim(), DVector::isConsistent(), Vector::operator=(), and DVector::reDim().

void reSize ( int  newsize)

resets DVector's memory size to newsize.

Definition at line 80 of file dvector.cpp.

References Vector::dim(), DVector::mem, DVector::memsize, soplex::spx_realloc(), and Vector::val.

Referenced by DVector::reDim(), LPColSet::reMax(), LPRowSet::reMax(), and SSVector::reMem().

void reSize ( int  newsize,
int  newdim 
)

resets DVector's memory size to newsize and dimension to newdim.

Definition at line 90 of file dvector.cpp.

References Vector::dimen, DVector::mem, DVector::memsize, soplex::spx_realloc(), and Vector::val.

Friends And Related Function Documentation

DVector operator* ( const Vector v,
Real  x 
)
friend

scaling vectors with a real number.

Definition at line 72 of file dvector.cpp.

DVector operator* ( Real  x,
const Vector v 
)
friend

scaling vectors with a real number.

DVector operator+ ( const Vector v,
const Vector w 
)
friend

adding vectors.

Definition at line 25 of file dvector.cpp.

DVector operator+ ( const SVector v,
const Vector w 
)
friend

adding vectors.

DVector operator+ ( const Vector v,
const SVector w 
)
friend

adding vectors.

Definition at line 34 of file dvector.cpp.

DVector operator- ( const Vector v,
const Vector w 
)
friend

subtracting vectors.

Definition at line 49 of file dvector.cpp.

DVector operator- ( const SVector v,
const Vector w 
)
friend

subtracting vectors.

Definition at line 65 of file dvector.cpp.

DVector operator- ( const Vector v,
const SVector w 
)
friend

subtracting vectors.

Definition at line 58 of file dvector.cpp.

DVector operator- ( const Vector vec)
friend

negation operator.

Definition at line 41 of file dvector.cpp.

DVector operator- ( const SVector vec)
friend

negation operator.

std::istream& operator>> ( std::istream &  s,
DVector vec 
)
friend

output operator.

Definition at line 113 of file dvector.cpp.

Member Data Documentation

Real* mem
private

value array to be used

Definition at line 59 of file dvector.h.

Referenced by DVector::DVector(), DVector::isConsistent(), DVector::reDim(), DVector::reSize(), and DVector::~DVector().

int memsize
private

length of array of values mem

Definition at line 58 of file dvector.h.

Referenced by DVector::DVector(), DVector::isConsistent(), DVector::memSize(), DVector::reDim(), and DVector::reSize().