Skip to content

Commit

Permalink
faster degree check
Browse files Browse the repository at this point in the history
  • Loading branch information
feltroidprime committed Feb 21, 2024
1 parent 497a798 commit aaeeced
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,10 @@ def __getitem__(self, i):
return 0

def degree(self):
if self.coefficients == []:
return -1
zero = PyFelt(0, self.coefficients[0].p)
if self.coefficients == [zero] * len(self.coefficients):
return -1
maxindex = 0
for i in range(len(self.coefficients)):
if self.coefficients[i] != zero:
maxindex = i
return maxindex
for i in range(len(self.coefficients) - 1, -1, -1):
if self.coefficients[i].value != 0:
return i
return -1

def get_coeffs(self) -> list[PyFelt]:
coeffs = self.coefficients.copy()
Expand Down

0 comments on commit aaeeced

Please sign in to comment.