aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-02 12:49:18 +0100
committerNao Pross <np@0hm.ch>2024-03-02 12:49:18 +0100
commit6b5a940c75ae32b6a127f8b3fb7d2391602b5521 (patch)
treebe22e12b472d04923d6d3415b2b86848d3fcd4dd
parentImport existing code into version control (diff)
downloadmdpoly-6b5a940c75ae32b6a127f8b3fb7d2391602b5521.tar.gz
mdpoly-6b5a940c75ae32b6a127f8b3fb7d2391602b5521.zip
Improve docstring of index types
-rw-r--r--mdpoly/types.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/mdpoly/types.py b/mdpoly/types.py
index 14847fa..29e7b83 100644
--- a/mdpoly/types.py
+++ b/mdpoly/types.py
@@ -50,13 +50,31 @@ class MatrixIndex(NamedTuple):
return cls(row, col)
-class PolyTermIndex(NamedTuple):
- term: int
+class PolyVarIndex(NamedTuple):
+ """
+ Tuple to index a power of a variable.
+
+ Concretely this represents things like x^2, y^4
+ """
+ varindex: int
power: Number
-class PolyIndex:
+class PolyIndex(tuple[PolyVarIndex]):
"""
Tuple to index a coefficient of a polynomial.
+
+ Example:
+
+ Suppose there are two variables x, y with indices 0, 1 respectively.
+ Then the monomal xy^2 has PolyIndex
+
+ (PolyVarIndex(varindex=0, power=1), PolyVarIndex(varindex=1, power=2)
+
+ Then given the polynomial
+
+ p(x, y) = 3x^2 + 5xy^2
+
+ The with the PolyIndex above we can retrieve the coefficient 5 in front
+ of xy^2.
"""
- indices: tuple[PolyTermIndex]