Sparse vector \(e_i\).A UnitVectorBase is an SVectorBase that can take only one nonzero value with value 1 but arbitrary index. More...
#include <unitvectorbase.h>
Public Member Functions | |
Access | |
R | value (int n) const |
returns value = 1 More... | |
Constructors / destructors | |
UnitVectorBase (int i=0) | |
construct i 'th unit vector. More... | |
UnitVectorBase (const UnitVectorBase< R > &rhs) | |
copy constructor More... | |
UnitVectorBase< R > & | operator= (const UnitVectorBase< R > &rhs) |
assignment More... | |
~UnitVectorBase () | |
destructor More... | |
Miscellaneous | |
bool | isConsistent () const |
consistency check More... | |
Public Member Functions inherited from SVectorBase< R > | |
template<> | |
SVectorBase< Real > & | operator= (const VectorBase< S > &vec) |
Assignment operator (specialization for Real). More... | |
template<> | |
Real | operator* (const SVectorBase< S > &w) const |
specialization for inner product for sparse vectors More... | |
int | size () const |
Number of used indices. More... | |
int | max () const |
Maximal number of indices. More... | |
int | dim () const |
Dimension of the vector defined as maximal index + 1. More... | |
int | pos (int i) const |
Position of index i . More... | |
R | operator[] (int i) const |
Value to index i . More... | |
Nonzero< R > & | element (int n) |
Reference to the n 'th nonzero element. More... | |
const Nonzero< R > & | element (int n) const |
The n 'th nonzero element. More... | |
int & | index (int n) |
Reference to index of n 'th nonzero. More... | |
int | index (int n) const |
Index of n 'th nonzero. More... | |
R & | value (int n) |
Reference to value of n 'th nonzero. More... | |
const R & | value (int n) const |
Value of n 'th nonzero. More... | |
void | add (int i, const R &v) |
Append one nonzero (i,v). More... | |
void | add (int i) |
Append one uninitialized nonzero. More... | |
void | add (const SVectorBase &sv) |
Append nonzeros of sv . More... | |
void | add (int n, const int i[], const R v[]) |
Append n nonzeros. More... | |
template<class S > | |
void | add (int n, const int i[], const S v[]) |
Append n nonzeros. More... | |
void | add (int n, const Nonzero< R > e[]) |
Append n nonzeros. More... | |
void | remove (int n, int m) |
Remove nonzeros n thru m . More... | |
void | remove (int n) |
Remove n 'th nonzero. More... | |
void | clear () |
Remove all indices. More... | |
void | sort () |
Sort nonzeros to increasing indices. More... | |
R | maxAbs () const |
Maximum absolute value, i.e., infinity norm. More... | |
R | minAbs () const |
Minimum absolute value. More... | |
Real | length () const |
Floating point approximation of euclidian norm (without any approximation guarantee). More... | |
R | length2 () const |
Squared norm. More... | |
SVectorBase< R > & | operator*= (const R &x) |
Scaling. More... | |
R | operator* (const VectorBase< R > &w) const |
Inner product. More... | |
template<class S > | |
R | operator* (const SVectorBase< S > &w) const |
inner product for sparse vectors More... | |
SVectorBase (int n=0, Nonzero< R > *p_mem=0) | |
Default constructor. More... | |
template<class S > | |
SVectorBase< R > & | operator= (const VectorBase< S > &vec) |
Assignment operator. More... | |
SVectorBase< R > & | operator= (const SVectorBase< R > &sv) |
Assignment operator. More... | |
template<class S > | |
SVectorBase< R > & | operator= (const SVectorBase< S > &sv) |
Assignment operator. More... | |
SVectorBase< Real > & | scaleAssign (int scaleExp, const SVectorBase< Real > &sv) |
scale and assign More... | |
SVectorBase< Real > & | scaleAssign (const int *scaleExp, const SVectorBase< Real > &sv, bool negateExp=false) |
scale and assign More... | |
template<class S > | |
SVectorBase< R > & | assignArray (const S *rowValues, const int *rowIndices, int rowSize) |
Assignment operator. More... | |
template<class S > | |
SVectorBase< R > & | operator= (const SSVectorBase< S > &sv) |
Assignment operator. More... | |
Nonzero< R > * | mem () const |
get pointer to internal memory. More... | |
void | set_size (int s) |
Set size of the vector. More... | |
void | set_max (int m) |
Set the maximum number of nonzeros in the vector. More... | |
void | setMem (int n, Nonzero< R > *elmem) |
Set the memory area where the nonzeros will be stored. More... | |
bool | isConsistent () const |
Consistency check. More... | |
Private Attributes | |
Data | |
SVectorBase< R >::Element | themem |
memory for sparse vector entry More... | |
Additional Inherited Members | |
Public Types inherited from SVectorBase< R > | |
typedef Nonzero< R > | Element |
Sparse vector \(e_i\).
A UnitVectorBase is an SVectorBase that can take only one nonzero value with value 1 but arbitrary index.
Definition at line 44 of file unitvectorbase.h.
|
explicit |
construct i
'th unit vector.
Definition at line 81 of file unitvectorbase.h.
References SVectorBase< R >::add(), and UnitVectorBase< R >::isConsistent().
UnitVectorBase | ( | const UnitVectorBase< R > & | rhs | ) |
copy constructor
Definition at line 89 of file unitvectorbase.h.
References UnitVectorBase< R >::isConsistent().
~UnitVectorBase | ( | ) |
destructor
Definition at line 109 of file unitvectorbase.h.
bool isConsistent | ( | ) | const |
consistency check
Definition at line 117 of file unitvectorbase.h.
References SVectorBase< R >::isConsistent(), SVectorBase< R >::max(), SVectorBase< R >::mem(), MSGinconsistent, and SVectorBase< R >::size().
Referenced by UnitVectorBase< R >::operator=(), and UnitVectorBase< R >::UnitVectorBase().
UnitVectorBase<R>& operator= | ( | const UnitVectorBase< R > & | rhs | ) |
assignment
Definition at line 97 of file unitvectorbase.h.
References UnitVectorBase< R >::isConsistent(), and UnitVectorBase< R >::themem.
R value | ( | int | n | ) | const |
|
private |
memory for sparse vector entry
Definition at line 51 of file unitvectorbase.h.
Referenced by UnitVectorBase< R >::operator=().