diff --git a/Code/DataStructs/SparseIntVect.h b/Code/DataStructs/SparseIntVect.h index faaa28b3f..800deb617 100644 --- a/Code/DataStructs/SparseIntVect.h +++ b/Code/DataStructs/SparseIntVect.h @@ -260,6 +260,62 @@ namespace RDKit{ SparseIntVect res(*this); return res-=other; } + SparseIntVect & + operator*= (int v) { + typename StorageType::iterator iter=d_data.begin(); + while(iter!=d_data.end()){ + iter->second *= v; + ++iter; + } + return *this; + }; + SparseIntVect & + operator* (int v) { + SparseIntVect res(*this); + return res*=v; + }; + SparseIntVect & + operator/= (int v) { + typename StorageType::iterator iter=d_data.begin(); + while(iter!=d_data.end()){ + iter->second /= v; + ++iter; + } + return *this; + }; + SparseIntVect & + operator/ (int v) { + SparseIntVect res(*this); + return res/=v; + }; + SparseIntVect & + operator+= (int v) { + typename StorageType::iterator iter=d_data.begin(); + while(iter!=d_data.end()){ + iter->second += v; + ++iter; + } + return *this; + }; + SparseIntVect & + operator+ (int v) { + SparseIntVect res(*this); + return res+=v; + }; + SparseIntVect & + operator-= (int v) { + typename StorageType::iterator iter=d_data.begin(); + while(iter!=d_data.end()){ + iter->second -= v; + ++iter; + } + return *this; + }; + SparseIntVect & + operator- (int v) { + SparseIntVect res(*this); + return res-=v; + }; bool operator==(const SparseIntVect &v2) const{ if(d_length!=v2.d_length){ diff --git a/Code/DataStructs/Wrap/SparseIntVect.cpp b/Code/DataStructs/Wrap/SparseIntVect.cpp index d089dff9b..8e21d7ace 100644 --- a/Code/DataStructs/Wrap/SparseIntVect.cpp +++ b/Code/DataStructs/Wrap/SparseIntVect.cpp @@ -131,6 +131,14 @@ struct sparseIntVec_wrapper { .def(python::self += python::self) .def(python::self == python::self) .def(python::self != python::self) + //.def(python::self - int()) + .def(python::self -= int()) + //.def(python::self + int()) + .def(python::self += int()) + //.def(python::self / int()) + .def(python::self /= int()) + //.def(python::self * int()) + .def(python::self *= int()) .def("GetTotalVal", &SparseIntVect::getTotalVal, (python::args("useAbs")=false), "Get the sum of the values in the vector, basically L1 norm")