diff options
-rw-r--r-- | mdpoly/representations.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mdpoly/representations.py b/mdpoly/representations.py index 0cda642..55763a9 100644 --- a/mdpoly/representations.py +++ b/mdpoly/representations.py @@ -32,6 +32,12 @@ class SparseRepr(Repr): self.data[entry][term] = value + def set_zero(self, entry: MatrixIndex, term: PolyIndex): + """ Set an entry to zero """ + del self.data[entry][term] + if not self.data[entry]: + del self.data[entry] + def entries(self) -> Sequence[MatrixIndex]: """ Return indices to non-zero entries of the matrix """ yield from self.data.keys() |