From 065116122d8dc0318e6d161cacd033e910fb02cc Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sun, 3 Mar 2024 00:08:06 +0100 Subject: Add Repr.is_zero to check if value is small --- mdpoly/abc.py | 5 +++++ 1 file changed, 5 insertions(+) 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 """ -- cgit v1.2.1