Skip to content

Commit

Permalink
Python 3 doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Feb 11, 2018
1 parent 92d166f commit 4bbcf00
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions docs/example-custom-pruning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,25 @@
Linear Pruning
==============

If we want to use pruning we can use the default pruning of fplll or
to use our custom pruning. For instance, say that for some reason we
want to use linear pruning. Then, we shall define the new linear pruning
strategy as follows.
If we want to use pruning we can use the default pruning of fplll or to use our custom pruning. For instance, say that for some reason we want to use linear pruning. Then, we shall define the new linear pruning strategy as follows.

::

>>> def linear_pruning_strategy(blocksize,level):
... if level > blocksize - 1:
... print "error"
... return
... if blocksize < 5:
... print "error"
... return
>>> def linear_pruning_strategy(block_size, level):
... if level > block_size - 1:
... raise ValueError
... if block_size < 5:
... raise ValueError
... from fpylll import BKZ
... from fpylll.fplll.pruner import PruningParams
... from fpylll.fplll.bkz_param import Strategy
... preprocessing = 3
... strategies1 = [Strategy(i) for i in range(6)]
... for b in range(6, blocksize+1):
... pr = PruningParams.LinearPruningParams(blocksize, level)
... for b in range(6, block_size+1):
... pr = PruningParams.LinearPruningParams(block_size, level)
... s = Strategy(b, [preprocessing], [pr])
... strategies1.append(s)
... param = BKZ.Param(block_size = blocksize, strategies = strategies1)
... param = BKZ.Param(block_size = block_size, strategies = strategies1)
... return param

So, now we can define a new strategy that uses linear pruning
Expand All @@ -45,8 +40,7 @@ So, now we can define a new strategy that uses linear pruning

>>> LP = linear_pruning_strategy(10, 6)

Now, we shall compute the BKZ reduction of a large matrix using linear
pruning.
Now, we shall compute the BKZ reduction of a large matrix using linear pruning.

::

Expand All @@ -56,10 +50,7 @@ pruning.
>>> A.randomize("intrel", bits=100)
>>> bkz_reduced = BKZ.reduction(A, LP)

Now, ``bkz_reduced`` is the BKZ reduced matrix of **A** using linear
pruning with blocksize 10 and level 6. If we want to use the default
strategy of fplll (which is faster than the previous linear pruning
strategy) we use ``BKZ.DEFAULT_STRATEGY``,
Now, ``bkz_reduced`` is the BKZ reduced matrix of **A** using linear pruning with blocksize 10 and level 6. If we want to use the default strategy of fplll (which is faster than the previous linear pruning strategy) we use ``BKZ.DEFAULT_STRATEGY``,

::

Expand Down

0 comments on commit 4bbcf00

Please sign in to comment.