Skip to content

Commit

Permalink
we now use tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
PimLeerkes committed Feb 25, 2025
1 parent 10f9eeb commit bd0486e
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions stormvogel/parametric_representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)

0 comments on commit bd0486e

Please sign in to comment.