Skip to content

Commit

Permalink
fix doctest (use random_seed)
Browse files Browse the repository at this point in the history
  • Loading branch information
kionactf committed Feb 5, 2024
1 parent 5cdbcf3 commit a8a7914
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/fpylll/fplll/bkz.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1120,24 +1120,40 @@ def bkz_reduction(IntegerMatrix B, BKZParam o, U=None, float_type=None, int prec
Example::
>>> from fpylll import IntegerMatrix, BKZ
>>> from fpylll import FPLLL, IntegerMatrix, BKZ
>>> FPLLL.set_random_seed(1337)
>>> A = IntegerMatrix(9, 10)
>>> A.randomize("intrel", bits=10)
>>> print(A)
>>> BKZ.reduction(A, BKZ.Param(3))
>>> print(A)
>>> print(BKZ.reduction(A, BKZ.Param(3)))
[ 0 0 0 0 -1 -1 0 1 1 0 ]
[ 0 0 0 -1 1 -1 0 0 -1 0 ]
[ 0 -1 1 1 0 0 0 0 -1 0 ]
[ 0 -1 -1 0 -1 0 0 1 0 1 ]
[ 1 -1 1 -1 -1 0 -1 0 1 1 ]
[ 2 1 0 1 -1 0 1 0 0 0 ]
[ 0 -1 -1 1 1 0 -1 1 1 -1 ]
[ -2 0 -1 0 1 -1 1 -2 0 1 ]
[ -1 1 1 0 0 -1 -2 0 0 2 ]
We can obtain the transformation matrix as well::
>>> import copy
>>> from fpylll import IntegerMatrix, BKZ
>>> from fpylll import FPLLL, IntegerMatrix, BKZ
>>> FPLLL.set_random_seed(1337)
>>> A = IntegerMatrix(9, 10)
>>> A.randomize("intrel", bits=10)
>>> print(A)
>>> B = copy.copy(A)
>>> U = IntegerMatrix(9, 9)
>>> BKZ.reduction(A, BKZ.Param(3), U=U)
>>> print(A)
>>> print(BKZ.reduction(A, BKZ.Param(3), U=U))
[ 0 0 0 0 -1 -1 0 1 1 0 ]
[ 0 0 0 -1 1 -1 0 0 -1 0 ]
[ 0 -1 1 1 0 0 0 0 -1 0 ]
[ 0 -1 -1 0 -1 0 0 1 0 1 ]
[ 1 -1 1 -1 -1 0 -1 0 1 1 ]
[ 2 1 0 1 -1 0 1 0 0 0 ]
[ 0 -1 -1 1 1 0 -1 1 1 -1 ]
[ -2 0 -1 0 1 -1 1 -2 0 1 ]
[ -1 1 1 0 0 -1 -2 0 0 2 ]
>>> A == U * B
True
Expand Down

0 comments on commit a8a7914

Please sign in to comment.