20 #ifndef _SSVECTORBASE_H_ 21 #define _SSVECTORBASE_H_ 142 for(
int i = 0; i < d; ++i)
186 assert(n >= 0 && n <
size());
273 assert(
index(n) >= 0);
363 for(
int i = vec.
size() - 1; i >= 0; --i)
400 for(
int i = vec.
size() - 1; i >= 0; --i)
422 for(
int i =
size() - 1; i >= 0; --i)
438 int j = w.
size() - 1;
446 while(i != 0 && j != 0)
462 while(i != 0 && vi != wj)
465 while(j != 0 && vi != wj)
477 template <
class S,
class T >
481 template <
class S,
class T >
496 template <
class S,
class T >
500 template <
class S,
class T >
504 template <
class S,
class T >
506 Timer* timeSparse,
Timer* timeFull,
int& nCallsSparse,
int& nCallsFull);
511 template <
class S,
class T >
521 for(
int i = 0; i <
num; ++i)
542 for(
int i = 0; i <
num; ++i)
574 if(
index(i) >= newdim)
608 for(
int i = 0; i <
num; ++i)
623 #ifdef ENABLE_CONSISTENCY_CHECKS 633 for(
int i = 0; i < VectorBase<R>::dim(); ++i)
639 MSG_ERROR(std::cerr <<
"ESSVEC01 i = " << i
668 len = (p_dim < 1) ? 1 : p_dim;
734 for(
int i =
size() - 1; i >= 0; --i)
745 for(
int i = 0; i < d; ++i)
792 for(
int i =
size() - 1; i >= 0; --i)
803 for(
int i = 0; i < d; ++i)
838 for(
int i =
size() - 1; i >= 0; --i)
848 for(
int i = 0; i < rhs.
dim(); ++i)
899 template <
class S,
class T >
903 template <
class S,
class T >
907 template <
class S,
class T >
914 #endif // _SSVECTORBASE_H_ R maxAbs() const
Maximum absolute value, i.e., infinity norm.
void add(int n)
appends n uninitialized indices.
SSVectorBase< R > & assign2productFull(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assignment helper.
int * idx
array of indices
bool isSetup() const
Returns setup status.
VectorBase< R > & operator=(const VectorBase< S > &vec)
Assignment operator.
Memory allocation routines.
int max() const
returns the maximal number of indices which can be stored in IdxSet.
SSVectorBase< R > & assign(const SVectorBase< S > &rhs)
Assigns only the elements of rhs.
R length2() const
Squared norm.
Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std...
int pos(int i) const
Finds the position of index i in the IdxSet, or -1 if i doesn't exist.
SSVectorBase< R > & operator-=(const VectorBase< S > &vec)
Subtraction.
SSVectorBase< R > & operator+=(const SSVectorBase< S > &vec)
Addition.
SSVectorBase< R > & assign2product1(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assignment helper.
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
void unSetup()
Makes SSVectorBase not setup.
void setValue(int i, R x)
Sets i 'th element to x.
void clear()
removes all indices.
SSVectorBase< R > & operator=(const SSVectorBase< R > &rhs)
Assignment operator.
void reMem(int newsize)
Resets memory consumption to newsize.
SSVectorBase< R > & operator*=(S x)
Scaling.
IdxSet()
default constructor.
SSVectorBase< R > & assign2product4setup(const SVSetBase< S > &A, const SSVectorBase< T > &x, Timer *timeSparse, Timer *timeFull, int &nCallsSparse, int &nCallsFull)
Assigns SSVectorBase to for a setup x.
SSVectorBase< R > & multAdd(S x, const VectorBase< T > &vec)
Addition of a scaled vector.
R operator*(const SSVectorBase< S > &w)
int * altIndexMem()
Returns array indices.
bool setupStatus
Is the SSVectorBase set up?
VectorBase< R > & operator+=(const VectorBase< S > &vec)
Addition.
void addIdx(int i)
appends index i.
Semi sparse vector.This class implements semi-sparse vectors. Such are VectorBases where the indices ...
bool isConsistent() const
consistency check.
int dim() const
Dimension of VectorBase.
SSVectorBase< R > & assign2productAndSetup(const SVSetBase< S > &A, SSVectorBase< T > &x)
Assigns SSVectorBase to thereby setting up x.
void spx_alloc(T &p, int n=1)
Allocate memory.
R * altValues()
Returns array values.
R * get_ptr()
Conversion to C-style pointer.
const R * values() const
Returns array values.
SSVectorBase< R > & assign2product(const SSVectorBase< S > &x, const SVSetBase< T > &A)
Assigns to SSVectorBase.
int pos(int i) const
returns the position of index i.
int size() const
returns the number of used indices.
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
int len
length of array idx
const IdxSet & indices() const
Returns indices.
R length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
void clearNum(int n)
Sets n 'th nonzero element to 0 (index n must exist).
IdxSet & operator=(const IdxSet &set)
assignment operator.
R operator[](int i) const
Returns i 'th value.
Real spxSqrt(Real a)
returns square root
void clear()
Clears vector.
void reSize(int newsize)
Resets VectorBase's memory size to newsize.
IdxSet & altIndices()
Returns indices.
void setEpsilon(R eps)
Changes the non-zero epsilon, invalidating the setup. */.
bool isConsistent() const
Consistency check.
bool isConsistent() const
consistency check.
SSVectorBase< R > & multAdd(S xx, const SVectorBase< T > &vec)
Addition of a scaled vector.
int index(int n) const
Returns index of the n 'th nonzero element.
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
SSVectorBase< R > & operator-=(const SSVectorBase< S > &vec)
Subtraction.
const int * indexMem() const
Returns array indices.
void reDim(int newdim)
Resets dimension to newdim.
Debugging, floating point type and parameter definitions.
void setSize(int n)
Sets number of nonzeros (thereby unSetup SSVectorBase).
void clearIdx(int i)
Clears element i.
R * get_ptr()
Only used in slufactor.hpp.
void spx_realloc(T &p, int n)
Change amount of allocated memory.
R length2() const
Squared euclidian norm.
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
int dim() const
Dimension of vector.
void setup_and_assign(SSVectorBase< S > &rhs)
Sets up rhs vector, and assigns it.
int size() const
Returns the number of nonzeros.
Everything should be within this namespace.
int dim() const
Dimension of the vector defined as maximal index + 1.
void setMax(int newmax)
Allocates enough space to accommodate newmax values.
R getEpsilon() const
Returns the non-zero epsilon used.
SSVectorBase< R > & operator=(const SSVectorBase< S > &rhs)
Assignment operator.
SSVectorBase< R > & operator+=(const VectorBase< S > &vec)
Addition.
VectorBase< R > & operator-=(const VectorBase< S > &vec)
Subtraction.
void setup()
Initializes nonzero indices for elements with absolute values above epsilon and sets all other elemen...
void reDim(int newdim, const bool setZero=true)
Resets VectorBase's dimension to newdim.
void clear()
Set vector to contain all-zeros (keeping the same length)
void forceSetup()
Forces setup status.
SSVectorBase< R > & operator=(const VectorBase< S > &rhs)
Assignment operator.
std::vector< R > val
Values of vector.
int dim() const
returns the maximal index.
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
SSVectorBase< R > & assignPWproduct4setup(const SSVectorBase< S > &x, const SSVectorBase< T > &y)
Assigns pair wise vector product to SSVectorBase.
#define MSGinconsistent(name)
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
R epsilon
A value x with |x| < epsilon is considered zero.
const std::vector< R > & vec()
Return underlying std::vector.
int index(int n) const
access n 'th index.
int num
number of used indices
void add(int i, R x)
Adds nonzero (i, x) to SSVectorBase.
SSVectorBase< R > & assign2productShort(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assignment helper.
Wrapper for the system time query methods.
Set of indices.Class IdxSet provides a set of indices. At construction it must be given an array of i...
void spx_free(T &p)
Release memory.
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
void scaleValue(int i, int scaleExp)
Scale i 'th element by a.
R value(int n) const
Returns value of the n 'th nonzero element.