Skip to content

Commit

Permalink
suggested detail + clean that file
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Dec 14, 2024
1 parent e1a6ffa commit 5518497
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/sage/coding/guruswami_sudan/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sage.matrix.constructor import matrix
from sage.misc.misc_c import prod

####################### Linear algebra system solving ###############################
# ###################### Linear algebra system solving ###############################


def _flatten_once(lstlst):
Expand All @@ -50,9 +50,9 @@ def _flatten_once(lstlst):
for lst in lstlst:
yield from lst

#*************************************************************
# *************************************************************
# Linear algebraic Interpolation algorithm, helper functions
#*************************************************************
# *************************************************************


def _monomial_list(maxdeg, l, wy):
Expand Down Expand Up @@ -137,9 +137,9 @@ def eqs_affine(x0, y0):
jhat = monomial[1]
if ihat >= i and jhat >= j:
icoeff = binomial(ihat, i) * x0**(ihat-i) \
if ihat > i else 1
if ihat > i else 1
jcoeff = binomial(jhat, j) * y0**(jhat-j) \
if jhat > j else 1
if jhat > j else 1
eq[monomial] = jcoeff * icoeff
eqs.append([eq.get(monomial, 0) for monomial in monomials])
return eqs
Expand Down Expand Up @@ -286,10 +286,10 @@ def gs_interpolation_linalg(points, tau, parameters, wy):
# Construct the Q polynomial
PF = M.base_ring()['x', 'y'] # make that ring a ring in <x>
x, y = PF.gens()
return sum([x**monomials[i][0] * y**monomials[i][1] * sol[i]
for i in range(len(monomials))])
return sum([x**m[0] * y**m[1] * sol[i]
for i, m in enumerate(monomials)])

####################### Lee-O'Sullivan's method ###############################
# ###################### Lee-O'Sullivan's method ###############################


def lee_osullivan_module(points, parameters, wy):
Expand Down Expand Up @@ -397,12 +397,11 @@ def gs_interpolation_lee_osullivan(points, tau, parameters, wy):
from .utils import _degree_of_vector
s, l = parameters[0], parameters[1]
F = points[0][0].parent()
M = lee_osullivan_module(points, (s,l), wy)
shifts = [i * wy for i in range(0,l+1)]
M = lee_osullivan_module(points, (s, l), wy)
shifts = [i * wy for i in range(l + 1)]
Mnew = M.reduced_form(shifts=shifts)
# Construct Q as the element of the row with the lowest weighted degree
Qlist = min(Mnew.rows(), key=lambda r: _degree_of_vector(r, shifts))
PFxy = F['x,y']
xx, yy = PFxy.gens()
Q = sum(yy**i * PFxy(Qlist[i]) for i in range(0,l+1))
return Q
return sum(yy**i * PFxy(Qlist[i]) for i in range(l + 1))

0 comments on commit 5518497

Please sign in to comment.