diff options
author | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-07-05 16:53:26 -0400 |
---|---|---|
committer | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-07-05 16:53:26 -0400 |
commit | 757f56e391bd2e1d7442ab38fc98aff00d064d38 (patch) | |
tree | db07405a8e182655fe182757ff76859b4008dba1 /python/src/vectors.pxi | |
parent | 32a8d92affae91094f2348b73dd26be800e10abd (diff) |
[python] Add convenience methods
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] |