Changeset 7383:6b57fec5f439
- Timestamp:
- 11/19/07 02:50:04 (5 years ago)
- Branch:
- default
- Location:
- sage
- Files:
-
- 2 edited
-
libs/fplll/fplll.pyx (modified) (14 diffs)
-
matrix/matrix_integer_dense.pyx (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/libs/fplll/fplll.pyx
r7126 r7383 176 176 self._check_eta(eta) 177 177 self._check_delta(delta) 178 cdef int ret = 0 178 179 179 180 cdef wrapper *w = wrapper_new(self._lattice, 0, eta, delta) 180 181 _sig_on 181 w.LLL()182 ret = w.LLL() 182 183 _sig_off 183 184 wrapper_delete(w) 185 if ret < 0: 186 raise RuntimeError, "fpLLL returned %d < 0"%ret 187 184 188 185 189 def proved(self, int precision=0, float eta=0.51, float delta=0.99, implementation=None): … … 240 244 cdef proved_mpfr *pmpfr 241 245 cdef proved_dpe *pdpe 246 cdef int ret = 0 242 247 243 248 if implementation is None: … … 247 252 pdouble = proved_double_new(self._lattice, precision, eta, delta) 248 253 _sig_on 249 pdouble.LLL()254 ret = pdouble.LLL() 250 255 _sig_off 251 256 proved_double_delete(pdouble) … … 253 258 pdpe = proved_dpe_new(self._lattice, precision, <double>eta, <double>delta) 254 259 _sig_on 255 pdpe.LLL()260 ret = pdpe.LLL() 256 261 _sig_off 257 262 proved_dpe_delete(pdpe) … … 259 264 pmpfr = proved_mpfr_new(self._lattice, precision, eta, delta) 260 265 _sig_on 261 pmpfr.LLL()266 ret = pmpfr.LLL() 262 267 _sig_off 263 268 proved_mpfr_delete(pmpfr) 269 270 if ret < 0: 271 raise RuntimeError, "fpLLL returned %d < 0"%ret 264 272 265 273 def fast(self, int precision=0, float eta=0.51, float delta=0.99, implementation=None): … … 312 320 313 321 cdef fast_double *pdouble 322 cdef int ret = 0 314 323 315 324 pdouble = fast_double_new(self._lattice, precision, eta, delta) 316 325 _sig_on 317 pdouble.LLL()326 ret = pdouble.LLL() 318 327 _sig_off 319 328 fast_double_delete(pdouble) 329 330 if ret < 0: 331 raise RuntimeError, "fpLLL returned %d < 0"%ret 320 332 321 333 def fast_early_red(self, int precision=0, float eta=0.51, float delta=0.99, implementation=None): … … 373 385 self._check_eta(eta) 374 386 self._check_delta(delta) 387 cdef int ret = 0 375 388 376 389 cdef fast_early_red_double *pdouble … … 378 391 pdouble = fast_early_red_double_new(self._lattice, precision, eta, delta) 379 392 _sig_on 380 pdouble.LLL()393 ret = pdouble.LLL() 381 394 _sig_off 382 395 fast_early_red_double_delete(pdouble) 396 397 if ret < 0: 398 raise RuntimeError, "fpLLL returned %d < 0"%ret 383 399 384 400 def heuristic(self, int precision=0, float eta=0.51, float delta=0.99, implementation=None): … … 433 449 cdef heuristic_mpfr *pmpfr 434 450 cdef heuristic_dpe *pdpe 451 cdef int ret = 0 435 452 436 453 if implementation is None: … … 438 455 439 456 if implementation == "double": 440 pdouble = heuristic_double_new(self._lattice, precision, eta, delta)441 _sig_on442 pdouble.LLL()443 _sig_off444 heuristic_double_delete(pdouble)457 pdouble = heuristic_double_new(self._lattice, precision, eta, delta) 458 _sig_on 459 ret = pdouble.LLL() 460 _sig_off 461 heuristic_double_delete(pdouble) 445 462 elif implementation == "dpe": 446 pdpe = heuristic_dpe_new(self._lattice, precision, <double>eta, <double>delta)447 _sig_on448 pdpe.LLL()449 _sig_off450 heuristic_dpe_delete(pdpe)463 pdpe = heuristic_dpe_new(self._lattice, precision, <double>eta, <double>delta) 464 _sig_on 465 ret = pdpe.LLL() 466 _sig_off 467 heuristic_dpe_delete(pdpe) 451 468 elif implementation == "mpfr": 452 pmpfr = heuristic_mpfr_new(self._lattice, precision, eta, delta) 453 _sig_on 454 pmpfr.LLL() 455 _sig_off 456 heuristic_mpfr_delete(pmpfr) 469 pmpfr = heuristic_mpfr_new(self._lattice, precision, eta, delta) 470 _sig_on 471 ret = pmpfr.LLL() 472 _sig_off 473 heuristic_mpfr_delete(pmpfr) 474 475 if ret < 0: 476 raise RuntimeError, "fpLLL returned %d < 0"%ret 477 457 478 458 479 def heuristic_early_red(self, int precision=0, float eta=0.51, float delta=0.99, implementation=None): … … 514 535 cdef heuristic_early_red_mpfr *pmpfr 515 536 cdef heuristic_early_red_dpe *pdpe 537 cdef int ret = 0 516 538 517 539 if implementation is None: … … 521 543 pdouble = heuristic_early_red_double_new(self._lattice, precision, eta, delta) 522 544 _sig_on 523 pdouble.LLL()545 ret = pdouble.LLL() 524 546 _sig_off 525 547 heuristic_early_red_double_delete(pdouble) … … 527 549 pdpe = heuristic_early_red_dpe_new(self._lattice, precision, <double>eta, <double>delta) 528 550 _sig_on 529 pdpe.LLL()551 ret = pdpe.LLL() 530 552 _sig_off 531 553 heuristic_early_red_dpe_delete(pdpe) … … 533 555 pmpfr = heuristic_early_red_mpfr_new(self._lattice, precision, eta, delta) 534 556 _sig_on 535 pmpfr.LLL()557 ret = pmpfr.LLL() 536 558 _sig_off 537 559 heuristic_early_red_mpfr_delete(pmpfr) 538 560 561 if ret < 0: 562 raise RuntimeError, "fpLLL returned %d < 0"%ret 539 563 540 564 def gen_intrel(int d, int b): -
sage/matrix/matrix_integer_dense.pyx
r7099 r7383 1553 1553 self. 1554 1554 1555 A lattice is (delta, eta)-LLL-reduce if the two following 1556 conditions hold: 1557 1558 (a) For any $i>j$, we have $|mu_{i, j}| <= \eta$, 1559 (b) For any $i<d$, we have 1560 $\delta |b_i^*|^2 <= |b_{i + 1}^* + mu_{i + 1, i} b_{i + 1}^* |^2$, 1561 1555 1562 The lattice is returned as a matrix. Also the rank (and the 1556 1563 determinant) of self are cached if those are computed during 1557 1564 the reduction. 1558 1565 1559 More specifically, elementary row transformations are 1560 performed on a copy of self so that the non-zero rows of R 1561 form an LLL-reduced basis for the lattice spanned by the rows 1562 of self. The default reduction parameters are $\delta=3/4$ and 1563 $eta=0.501$. 1564 1565 For a basis reduced with parameter $\delta$, the squared 1566 length of the first non-zero basis vector is no more than 1567 $1/(\delta-1/4)^{r-1}$ times that of the shortest vector in 1568 the lattice. 1566 The default reduction parameters are $\delta=3/4$ and 1567 $eta=0.501$. The parameters $\delta$ and $\eta$ must satisfy: 1568 $0.25 < \delta <= 1.0$ and $0.5 <= \eta < sqrt(\delta)$. 1569 1569 1570 1570 If we can compute the determinant of self using this method, … … 1608 1608 [ 2 1 0] 1609 1609 [-1 1 3] 1610 1611 We compute the extended GCD of a list of integers using LLL, 1612 this example is from the Magma handbook: 1613 1614 sage: Q = [ 67015143, 248934363018, 109210, 25590011055, 74631449, \ 1615 10230248, 709487, 68965012139, 972065, 864972271 ] 1616 sage: n = len(Q) 1617 sage: S = 100 1618 sage: X = Matrix(ZZ, n, n + 1) 1619 sage: for i in xrange(n): 1620 ... X[i,i + 1] = 1 1621 sage: for i in xrange(n): 1622 ... X[i,0] = S*Q[i] 1623 sage: L = X.LLL() 1624 sage: M = L[n-1].list()[1:] 1625 sage: M 1626 [-3, -1, 13, -1, -4, 2, 3, 4, 5, -1] 1627 sage: add([Q[i]*M[i] for i in range(n)]) 1628 -1 1610 1629 1611 1630 ALGORITHM: Uses NTL or fpLLL.
Note: See TracChangeset
for help on using the changeset viewer.
