From bd0486edbded04389c7e0a438d8fb6ad0ff35258 Mon Sep 17 00:00:00 2001 From: PimLeerkes Date: Tue, 25 Feb 2025 14:02:52 +0100 Subject: [PATCH] we now use tensors --- stormvogel/parametric_representation.py | 30 +++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/stormvogel/parametric_representation.py b/stormvogel/parametric_representation.py index d081335..ac569ec 100644 --- a/stormvogel/parametric_representation.py +++ b/stormvogel/parametric_representation.py @@ -17,28 +17,16 @@ def __str__(self) -> str: class Polynomial: coefficients: np.ndarray = np.array([]) - def __init__( - self, degree: int, dimension: int, coefficients: np.ndarray | None = None - ): - if coefficients is None: - self.coefficients = np.zeroes((degree + 1,) * dimension) - else: - self.coefficients = coefficients + def __init__(self, degree: int, dimension: int): + self.coefficients = np.zeros((degree + 1,) * dimension) - # def set_coefficient(self, variables: tuple[Parameter, ...], coefficient: float): - # self.coefficients[tuple[Parameter, ...]] = coefficient + def set_coefficient(self, exponents: tuple[int, ...], coefficient: float): + self.coefficients[exponents] = coefficient def __str__(self) -> str: s = "" - for index, pair in enumerate(self.coefficients.items()): - term = "" - if str(pair[1]) != "1": - term += str(pair[1]) - for var in pair[0]: - term += str(var) - s += term - if index < len(self.coefficients.items()) - 1: - s += " + " + for id in np.ndindex(self.coefficients.shape): + s += f"Index: {id}, Value: {self.coefficients[id]}" return s @@ -64,6 +52,8 @@ def __str__(self) -> str: polynomial1 = Polynomial(3, 3) polynomial2 = Polynomial(4, 4) - function = RationalFunction(polynomial1, polynomial2) + print(polynomial1) - print(function) + # function = RationalFunction(polynomial1, polynomial2) + + # print(function)