#ifndef _SPARSE_VECTOR_H_ #define _SPARSE_VECTOR_H_ #if 0 #if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP friend class boost::serialization::access; template void save(Archive & ar, const unsigned int version) const { (void) version; int eff_size = values_.size(); const_iterator it = this->begin(); if (values_.find(0) != values_.end()) { ++it; --eff_size; } ar & eff_size; while (it != this->end()) { const std::pair wire_pair(FD::Convert(it->first), it->second); ar & wire_pair; ++it; } } template void load(Archive & ar, const unsigned int version) { (void) version; this->clear(); int sz; ar & sz; for (int i = 0; i < sz; ++i) { std::pair wire_pair; ar & wire_pair; this->set_value(FD::Convert(wire_pair.first), wire_pair.second); } } BOOST_SERIALIZATION_SPLIT_MEMBER() #endif }; #if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP BOOST_CLASS_TRACKING(SparseVector,track_never) #endif #endif /// FIX #include "fast_sparse_vector.h" #define SparseVector FastSparseVector template SparseVector operator*(const SparseVector& a, const S& b) { SparseVector result = a; return result *= b; } template SparseVector operator*(const SparseVector& a, const double& b) { SparseVector result = a; return result *= b; } template SparseVector operator/(const SparseVector& a, const S& b) { SparseVector result = a; return result /= b; } template SparseVector operator/(const SparseVector& a, const double& b) { SparseVector result = a; return result /= b; } #include "fdict.h" template inline void print(O &o,const SparseVector& v, const char* kvsep="=",const char* pairsep=" ",const char* pre="",const char* post="") { o << pre; bool first=true; for (typename SparseVector::const_iterator i=v.begin(),e=v.end();i!=e;++i) { if (first) first=false; else o<first)<second; } o << post; } template inline std::ostream& operator<<(std::ostream& out, const SparseVector& v) { print(out, v); return out; } namespace B64 { void Encode(double objective, const SparseVector& v, std::ostream* out); // returns false if failed to decode bool Decode(double* objective, SparseVector* v, const char* data, size_t size); } #endif