140 typedef std::list<svt::SparseItem>::iterator
iterator;
217 return pFeatures.begin();
223 return pFeatures.begin();
226 const_iterator
end()
const 228 return pFeatures.end();
234 return pFeatures.end();
248 const_iterator p = begin();
249 while( p != end() && p->index() <
index)
253 if (p->index() ==
index)
274 iterator p = begin();
275 while( p != end() && p->index() <
index)
279 if (p != end() && p->index() ==
index)
286 return newItem->value();
345 for (iterator p=begin();
372 for (const_iterator p=begin();
376 pSquare+=p->value() * p->value();
400 const_iterator i=begin();
401 const_iterator j=fv.
begin();
403 i!=end() && j!=fv.
end();
406 if (i->index()==j->index())
408 sum+=i->value() * j->value();
412 else if (i->index()>j->index())
436 if( pFeatures.size() != fv.
pFeatures.size())
return false;
437 const_iterator p1 = pFeatures.begin();
439 for( ; p1 != pFeatures.end(); ++p1, ++p2)
441 if( p1->index() != p2->index()
442 || p1->value() != p2->value())
453 if( pFeatures.size() == fv.
pFeatures.size())
457 for( ; p1 != pFeatures.end(); ++p1, ++p2)
459 if( p1->index() == p2->index())
461 p1->value() += p2->value();
465 err <<
"can not calculate with sparse vectors of different shape !\n";
473 err<<
"can not calculate with sparse vectors of differnt size !/n";
481 for( ; p1 != pFeatures.end(); ++p1)
483 p1->value() *= factor;
490 for( ; p1 != pFeatures.end(); ++p1)
514 if( is.rdbuf()->sgetc() == EOF)
return;
517 }
while( isspace(c) && c !=
'\n');
520 if( !isdigit(c) )
return;
531 operator[](index) =
value;
544 std::ostream& os)
const 546 for (const_iterator p=begin(); p!=end(); ++p )
548 if( p != begin()) os <<
" ";
549 os << p->index() <<
":" << p->value();
555 return "<label><ws><index>:<feature><ws><index>:<feature>...\n" 556 "where <ws> is any number of white spaces except for newline\n" 557 "First <index> is 1.\n" 559 "4 1:0.123 13:2.432 235:42.0";
void pSquare(blitz::Array< Typea, Dim > &a)
void operator*=(double factor)
const double & const_reference
void cleanup()
cleanup function to delete items with value 0 (maybe someone needs this)
const double & value() const
void setUniqueID(unsigned int uid)
void readWithoutLabel(std::istream &is)
Read FV from input stream without label.
double getLabel() const
Returns label of FV.
const_iterator end() const
const unsigned int MAX_BELIEVABLE_UNIQUE_ID
std::ostream & operator<<(std::ostream &os, const svt::BasicFV &fv)
std::istream & operator>>(std::istream &is, svt::BasicFV &fv)
unsigned int index() const
std::list< svt::SparseItem >::iterator iterator
void writeWithoutLabel(std::ostream &os) const
Write FV to output stream without label.
SparseItem(unsigned int index, double value)
void clear()
Clear FV's data.
unsigned int uniqueID() const
The SparseFV class specifies a vector with sparse storage.
double dotProduct(const svt::SparseFV &fv) const
Calculate and return dot product of *this and specified FV.
void operator+=(const svt::SparseFV &fv)
const_iterator begin() const
double square() const
Calculate and return square of FV.
bool operator==(const svt::SparseFV &fv) const
comparison
reference operator[](size_type index)
Return reference to value data item with specified index.
size_type size() const
size of sparse vector is just the value of the last resize()
std::list< svt::SparseItem > pFeatures
void setLabel(double value)
Set FV's label.
std::list< svt::SparseItem >::const_iterator const_iterator
void resize(size_type s)
resizing sparse vector has no effect on the vector.
double operator[](size_type index) const
Return const reference to value data item with specified index.
The SparseItem class specifies one element in a SpareFV.
static const char * helpPipeFormat()