diff options
author | Nao Pross <np@0hm.ch> | 2024-03-03 00:08:06 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-03 00:08:06 +0100 |
commit | 065116122d8dc0318e6d161cacd033e910fb02cc (patch) | |
tree | 2896b24307cc7f4871a65806727da2f1a3702c0a | |
parent | Add total ordering to PolyVarIndex and PolyIndex.product to compute index of ... (diff) | |
download | mdpoly-065116122d8dc0318e6d161cacd033e910fb02cc.tar.gz mdpoly-065116122d8dc0318e6d161cacd033e910fb02cc.zip |
Add Repr.is_zero to check if value is small
Diffstat (limited to '')
-rw-r--r-- | mdpoly/abc.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/mdpoly/abc.py b/mdpoly/abc.py index 56507d6..77285aa 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -54,6 +54,7 @@ class Expr(Protocol): class Repr(Protocol): """ Representation of a polynomial expression. + """ @abstractmethod def at(self, entry: MatrixIndex, term: PolyIndex) -> Number: @@ -63,6 +64,10 @@ class Repr(Protocol): def set(self, entry: MatrixIndex, term: PolyIndex, value: Number) -> None: """ Set value of polynomial entry """ + def is_zero(self, entry: MatrixIndex, term: PolyIndex, eps: Number = NUMERICS_EPS) -> bool: + """ Check if a polynomial entry is zero """ + return self.at(entry, term) < eps + @abstractmethod def set_zero(self, entry: MatrixIndex, term: PolyIndex) -> None: """ Set an entry to zero """ |