コード例 #1
0
def test_multisol():
    A = make_integer_matrix()
    m = GSO.Mat(A)
    lll_obj = LLL.Reduction(m)
    lll_obj()

    solutions = []
    solutions = Enumeration(m, nr_solutions=200).enumerate(0, 27, 48.5, 0)
    assert len(solutions) == 126 / 2
    for _, sol in solutions:
        sol = IntegerMatrix.from_iterable(1, A.nrows,
                                          map(lambda x: int(round(x)), sol))
        sol = tuple((sol * A)[0])
        dist = sum([x**2 for x in sol])
        assert dist == 48

    solutions = []
    solutions = Enumeration(m, nr_solutions=126 / 2).enumerate(0, 27, 100., 0)
    assert len(solutions) == 126 / 2
    for _, sol in solutions:
        sol = IntegerMatrix.from_iterable(1, A.nrows,
                                          map(lambda x: int(round(x)), sol))
        sol = tuple((sol * A)[0])
        dist = sum([x**2 for x in sol])
        assert dist == 48
コード例 #2
0
def test_multisol():
    A = make_integer_matrix()
    m = GSO.Mat(A)
    lll_obj = LLL.Reduction(m)
    lll_obj()

    solutions = []
    solutions = Enumeration(m, nr_solutions=200).enumerate(0, 27, 48.5, 0)
    assert len(solutions)== 126 / 2
    for sol, _ in solutions:
        sol = IntegerMatrix.from_iterable(1, A.nrows, map(lambda x: int(round(x)), sol))
        sol = tuple((sol*A)[0])
        dist = sum([x**2 for x in sol])
        assert dist==48

    solutions = []
    solutions = Enumeration(m, nr_solutions=126 / 2).enumerate(0, 27, 100., 0)
    assert len(solutions)== 126 / 2
    for sol, _ in solutions:
        sol = IntegerMatrix.from_iterable(1, A.nrows, map(lambda x: int(round(x)), sol))
        sol = tuple((sol*A)[0])
        dist = sum([x**2 for x in sol])
        assert dist==48
コード例 #3
0
ファイル: test_cvp.py プロジェクト: blowfish880/fpylll
def test_cvp():
    for m, n in dimensions:
        A = make_integer_matrix(m, n)
        A = LLL.reduction(A)
        M = GSO.Mat(A)
        M.update_gso()
        t = list(make_integer_matrix(n, n)[0])
        v0 = CVP.closest_vector(A, t)

        E = Enumeration(M)
        v1, _ = E.enumerate(0, A.nrows, 2, 40, M.from_canonical(t))
        v1 = IntegerMatrix.from_iterable(1, A.nrows, map(lambda x: int(round(x)), v1))
        v1 = tuple((v1*A)[0])

        assert v0 == v1
コード例 #4
0
ファイル: test_cvp.py プロジェクト: zhli271828/fpylll
def test_cvp():
    for m, n in dimensions:
        A = make_integer_matrix(m, n)
        A = LLL.reduction(A)
        M = GSO.Mat(A)
        M.update_gso()
        t = list(make_integer_matrix(n, n)[0])
        v0 = CVP.closest_vector(A, t)

        E = Enumeration(M)
        v1, _ = E.enumerate(0, A.nrows, 2, 40, M.from_canonical(t))[0]
        v1 = IntegerMatrix.from_iterable(1, A.nrows,
                                         map(lambda x: int(round(x)), v1))
        v1 = tuple((v1 * A)[0])

        assert v0 == v1
コード例 #5
0
ファイル: test_gso.py プロジェクト: zhli271828/fpylll
def test_gso_io():
    for m, n in dimensions:
        if m <= 2 or n <= 2:
            continue

        A = make_integer_matrix(m, n)
        v = list(A[0])
        LLL.reduction(A)

        for float_type in float_types:
            M = GSO.Mat(copy(A), float_type=float_type)
            M.update_gso()
            w = M.babai(v)
            v_ = IntegerMatrix.from_iterable(1, m, w) * A
            v_ = list(v_[0])
            assert v == v_
コード例 #6
0
 def vector_from_coeffs(self, coeffs, lattice):
     return tuple((IntegerMatrix.from_iterable(
         1, lattice.nrows, map(lambda x: int(round(x)), coeffs)) *
                   lattice)[0])