26 #ifndef CSPARSEVECTOR_H
27 #define CSPARSEVECTOR_H
53 static Type nullElement;
60 CSparseVector(
int dim,
int size, vector<Type> elements, vector<int> pos);
70 void setElement(
int index, pair<int, Type> value);
74 virtual string className()
const {
return string(
"CSparseVector");};
112 std::ostream& operator << (std::ostream& stream, const CSparseVector<Type>& rhs)
114 stream <<
"SparseVector[dim=" << rhs.dimension()
115 <<
", size=" << rhs.getNumNonZero() <<
", pairs={";
118 i != rhs.end(); ++i) {
119 stream <<
"(" << i.
key() <<
", " << i.val() <<
") ";
126 template <
class Type>
128 template <
class Type>
135 #endif // CSPARSEVECTOR_H
int key() const
Definition: keyed_iterator.hpp:107
keyed_iterator< Type > begin() const
Definition: CSparseVector.h:93
keyed_iterator< Type > iterator
Definition: CSparseVector.h:47
bool isNaN() const
returns true if vector contains nan elements
CVector< Type > * clone() const
destructor
CSparseVector< Type > elementMul(const CSparseVector< Type > &, const CVector< Type > &)
Type euclideanLength(bool bQuad=false) const
returns euclidean length of vector
CSparseVector< Type > operator/(const CSparseVector< Type > &, const Type &)
Type getElement(int iIndex) const
return copy of n'th vector element
CVector< Type > & operator/=(const CVector< Type > &v2)
Definition: CSparseVector.h:83
element_type * pointer_type
Definition: CSparseVector.h:46
void setElement(int index, pair< int, Type > value)
CSparseVector< Type > operator*(const CSparseVector< Type > &vec, const Type &s)
CSparseVector(int dim, int size, Type elements[], int pos[])
Definition: CDenseVector.h:35
CVector< double > * toDouble() const
create a copy with every element stored as 'double'
CVector< float > * toFloat() const
create a copy with every element stored as 'float'
pair< int, Type > element_type
Definition: CSparseVector.h:45
CVector< Type > & operator*=(const CVector< Type > &)
multiply vectors elementwise
Sparse, immutable vector representation.
Definition: CSparseVector.h:42
CVector< Type > & operator/=(const CVector< Type > &)
divide vectors elementwise
keyed_iterator< Type > end()
Definition: CSparseVector.h:102
int dimension() const
return vector dimension
Definition: CSparseVector.h:68
const Type & operator[](int index) const
return constant reference to n'th vector element
CVector< Type > & operator*=(const CVector< Type > &v2)
Definition: CSparseVector.h:79
Template object for vectors of single and double precision and integer.
Definition: CDenseVector.h:37
int getNumNonZero() const
returns the number of non-zero entries
Definition: CSparseVector.h:71
templatized vector for numerical applications
Definition: CMatrix.h:39
keyed_iterator< Type > begin()
Definition: CSparseVector.h:96
virtual string className() const
Returns the class name.
Definition: CSparseVector.h:74
CDenseVector< int > sort()
keyed_iterator< Type > end() const
Definition: CSparseVector.h:99