Révision dd576474
b/src/functions_for_cvp.sage | ||
---|---|---|
44 | 44 |
return (scalingCoefficient, offset) |
45 | 45 |
# End cvp_affine_to_chebyshev |
46 | 46 |
# |
47 |
def cvp_babai(redBasis, redBasisGso, vect):
|
|
47 |
def cvp_babai(readBasis, readBasisGso, vect):
|
|
48 | 48 |
""" |
49 | 49 |
Closest plane vector implementation as per Babaï. |
50 |
@param redBasis : a lattice basis, preferably a reduced one; |
|
51 |
@param redBasisGSO: the GSO of the previous basis; |
|
52 |
@param vector : a vector, in coordinated in the ambient
|
|
50 |
@param readBasis : a lattice basis, preferably a reduced one;
|
|
51 |
@param readBasisGSO: the GSO of the previous basis;
|
|
52 |
@param vect : a vector, in coordinated in the ambient
|
|
53 | 53 |
space of the lattice |
54 | 54 |
@return the closest vector to the input, in coordinates in the |
55 | 55 |
ambient space of the lattice. |
... | ... | |
58 | 58 |
curVect = copy(vect) |
59 | 59 |
#print "cvp_babai - Vector:", vect |
60 | 60 |
## From index of last row down to 0. |
61 |
for vIndex in xrange(len(redBasis.rows())-1, -1, -1): |
|
62 |
curRBGSO = redBasisGso.row(vIndex) |
|
61 |
for vIndex in xrange(len(readBasis.rows())-1, -1, -1):
|
|
62 |
curRBGSO = readBasisGso.row(vIndex)
|
|
63 | 63 |
curVect = curVect - \ |
64 | 64 |
(round((curVect * curRBGSO) / (curRBGSO * curRBGSO)) * \ |
65 |
redBasis.row(vIndex)) |
|
65 |
readBasis.row(vIndex))
|
|
66 | 66 |
return vect - curVect |
67 | 67 |
# End cvp_babai |
68 | 68 |
# |
... | ... | |
196 | 196 |
def cvp_chebyshev_maxis_1k(numPoints, realField, contFracMaxErr = None): |
197 | 197 |
""" |
198 | 198 |
Compute the Chebyshev maxis for some polynomial degree (numPoints, for the |
199 |
zeros) scaled to the [lowerBound, upperBound] interval. |
|
200 |
The list is returned as row floating-point numbers is contFracMaxErr is None. |
|
199 |
zeros, numPoints + 1 for the maxis) scaled to the [lowerBound, upperBound] |
|
200 |
interval. |
|
201 |
The list is returned as a row floating-point numbers is contFracMaxErr |
|
202 |
is None. |
|
201 | 203 |
Otherwise elements are transformed into rational numbers. |
202 | 204 |
""" |
203 | 205 |
if numPoints < 1: |
... | ... | |
1118 | 1120 |
""" |
1119 | 1121 |
Compute the coordinates of "vect" in "basis" by |
1120 | 1122 |
solving a linear system. |
1121 |
@param vect the vector we want to compute the coordinates of |
|
1122 |
in coordinates of the ambient space; |
|
1123 |
@param basis the basis we want to compute the coordinates in |
|
1124 |
as a matrix relative to the ambient space. |
|
1123 |
@param vect: the vector we want to compute the coordinates of
|
|
1124 |
in coordinates of the ambient space;
|
|
1125 |
@param basis: the basis we want to compute the coordinates in
|
|
1126 |
as a matrix relative to the ambient space.
|
|
1125 | 1127 |
""" |
1126 | 1128 |
## Create the variables for the linear equations. |
1127 | 1129 |
varDeclString = "" |
Formats disponibles : Unified diff