Skip to content

Commit

Permalink
more Python 3 doctest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Feb 11, 2018
1 parent df20b1f commit 43a53ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/example-linear-diophantine-equations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Note that before we apply LLL to Mb we need to convert it to fpyll IntegerMatrix

::

>>> print LLL.reduction(IntegerMatrix.from_matrix([map(int, row) for row in Mb.tolist()]))
>>> print(LLL.reduction(IntegerMatrix.from_matrix([map(int, row) for row in Mb.tolist()])))
[ 0 -1 0 0 1 0 0 0 0 0 0 0 ]
[ 0 1 0 0 0 0 1 0 -2 0 0 0 ]
[ -1 0 -1 -1 0 0 1 0 1 1 0 0 ]
Expand Down
20 changes: 10 additions & 10 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Matrix :math:`A` is a (random) knapsack type matrix. That is of the form `[ {\b

::
>>> print A
>>> print(A)
[ 50 1 0 0 0 0 0 0 0 0 ]
[ 556 0 1 0 0 0 0 0 0 0 ]
[ 5 0 0 1 0 0 0 0 0 0 ]
Expand Down Expand Up @@ -60,7 +60,7 @@ Also, the following type of matrices are supported,

For instance::

>>> print D
>>> print(D)
[ 1 0 0 858 790 620 ]
[ 0 1 0 72 832 133 ]
[ 0 0 1 263 121 724 ]
Expand Down Expand Up @@ -94,9 +94,9 @@ We can then compute the inner product `r_{i,j} = \langle {\bf b}_i, {\bf b}^{*}_
::

>>> i = 3; j = 2;
>>> print M.get_r(i,j)
>>> print(M.get_r(i,j))
0.810079798404
>>> print M.get_mu(i,j)
>>> print(M.get_mu(i,j))
0.0584569876831

To compute the LLL reduced matrix of `{\bf A}`
Expand All @@ -106,7 +106,7 @@ To compute the LLL reduced matrix of `{\bf A}`
>>> from fpylll import LLL
>>> A.randomize("qary", bits=10, k=3)
>>> A_lll = LLL.reduction(A)
>>> print A_lll
>>> print(A_lll)
[ -1 -6 -1 10 ]
[ -7 -5 -7 -4 ]
[ -4 13 -4 3 ]
Expand All @@ -121,7 +121,7 @@ For the BKZ reduction of `{\bf A}` with blocksize say 3 (without pruning),
>>> block_size = 3
>>> A.randomize("qary", bits=10, k=3)
>>> A_bkz = BKZ.reduction(A, BKZ.Param(block_size))
>>> print A_bkz
>>> print(A_bkz)
[ 75 44 -5 -16 ]
[ 29 7 -52 134 ]
[ -89 108 56 29 ]
Expand All @@ -144,7 +144,7 @@ To compute the norm of a shortest vector of the lattice generated by the rows of
>>> import numpy as np
>>> SVP.shortest_vector(A)
(75, 44, -5, -16)
>>> print A[0]
>>> A[0]
(75, 44, -5, -16)
>>> A[0].norm()
88.55506761332182
Expand All @@ -159,7 +159,7 @@ Also, the ``GaussSieve`` algorithm [MV]_ is implemented,
>>> v = GaussSieve(A, algorithm=2)()
>>> tuple(map(lambda x: -1*x, v)) if v[0] < 0 else v
(6, -5, 3, -4, 2, -4, 1, -1, -3, -1, -5, 1, 1, 2, -1, -1, -3, 2, 1, 1, 0, 5, -2, 4, -3, 0, 3, -5, 0, -2)
>>> print A[0]
>>> A[0]
(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 52, 5, 45, 56, 26, 89, 51, 112, 64, 37, 85, 5, 87, 3)
>>> A[0].norm()
237.23827684418887
Expand All @@ -170,7 +170,7 @@ The previous code returns a Shortest vector of the lattice generated by `{\bf A}
>>> A = IntegerMatrix.from_matrix([[1,2,3,4],[30,4,4,5],[1,-2,3,4]])
>>> t = (1, 2, 5, 5)
>>> v0 = CVP.closest_vector(A, t)
>>> print v0
>>> v0
(1, 2, 3, 4)

In fact the following code was executed::
Expand All @@ -183,7 +183,7 @@ In fact the following code was executed::
>>> _, v2 = E.enumerate(0, A.nrows, 5, 40, M.from_canonical(t))[0]
>>> v3 = IntegerMatrix.from_iterable(1, A.nrows, map(lambda x: int(x), v2))
>>> v1 = v3*A
>>> print v1
>>> v1
[ 1 2 3 4 ]

Further examples
Expand Down

0 comments on commit 43a53ab

Please sign in to comment.