diff options
Diffstat (limited to 'python/src/vectors.pxi')
-rw-r--r-- | python/src/vectors.pxi | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/python/src/vectors.pxi b/python/src/vectors.pxi index fc0c365f..ce95968c 100644 --- a/python/src/vectors.pxi +++ b/python/src/vectors.pxi @@ -80,6 +80,12 @@ cdef class SparseVector: def __contains__(self, char* fname): return self.vector.nonzero(FDConvert(fname)) + + def __neg__(self): + cdef SparseVector result = SparseVector() + result.vector = new FastSparseVector[weight_t](self.vector[0]) + result.vector[0] *= -1.0 + return result def __iadd__(SparseVector self, SparseVector other): self.vector[0] += other.vector[0] |