# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1338241628 25200
# Node ID 2ad0b81a1621461573d6dff62262709dc5a88553
# Parent d71f442df84788987a3c6572fd70bc3a90ba2aa8
cleanly separate Cholesky caching
diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
|
a
|
b
|
|
| 9298 | 9298 | .. WARNING:: |
| 9299 | 9299 | |
| 9300 | 9300 | ``cholesky_decomposition()`` is deprecated, |
| 9301 | | please use ``cholesky()`` instead. |
| | 9301 | please use :meth:`cholesky` instead. |
| 9302 | 9302 | |
| 9303 | 9303 | The computed decomposition is cached and returned on |
| 9304 | 9304 | subsequent calls. Methods such as :meth:`solve_left` may also |
| … |
… |
|
| 9467 | 9467 | sage: L*L.conjugate().transpose() |
| 9468 | 9468 | [ 1.0 -2.0*I] |
| 9469 | 9469 | [ 2.0*I 8.0] |
| | 9470 | |
| | 9471 | This test verifies that the caching of the two variants |
| | 9472 | of the Cholesky decomposition have been cleanly separated. |
| | 9473 | It can be safely removed as part of removing this method |
| | 9474 | at the end of the deprecation period. |
| | 9475 | (From :trac:`13045`.) :: |
| | 9476 | |
| | 9477 | sage: r = matrix(CDF, 2, 2, [ 0, -2*I, 2*I, 0 ]); r |
| | 9478 | [ 0.0 -2.0*I] |
| | 9479 | [ 2.0*I 0.0] |
| | 9480 | sage: r.cholesky_decomposition() |
| | 9481 | [ 0.0 0.0] |
| | 9482 | [NaN + NaN*I NaN + NaN*I] |
| | 9483 | sage: r.cholesky() |
| | 9484 | Traceback (most recent call last): |
| | 9485 | ... |
| | 9486 | ValueError: matrix is not positive definite |
| | 9487 | sage: r[0,0] = 0 # clears cache |
| | 9488 | sage: r.cholesky() |
| | 9489 | Traceback (most recent call last): |
| | 9490 | ... |
| | 9491 | ValueError: matrix is not positive definite |
| | 9492 | sage: r.cholesky_decomposition() |
| | 9493 | [ 0.0 0.0] |
| | 9494 | [NaN + NaN*I NaN + NaN*I] |
| 9470 | 9495 | """ |
| 9471 | 9496 | # deprecation added 2012-05-27 |
| 9472 | 9497 | from sage.misc.misc import deprecation |
| … |
… |
|
| 9482 | 9507 | |
| 9483 | 9508 | This generic implementation uses a standard recursion. |
| 9484 | 9509 | """ |
| 9485 | | L = self.fetch('cholesky') |
| | 9510 | L = self.fetch('cholesky_broken') |
| 9486 | 9511 | if L is None: |
| 9487 | 9512 | A = self.__copy__() |
| 9488 | 9513 | L = A.parent()(0) |
| … |
… |
|
| 9499 | 9524 | for i in range(j, n): |
| 9500 | 9525 | A[i, j] -= L[i, k]*L[j, k].conjugate() |
| 9501 | 9526 | L.set_immutable() |
| 9502 | | self.cache('cholesky', L) |
| | 9527 | self.cache('cholesky_broken', L) |
| 9503 | 9528 | return L |
| 9504 | 9529 | |
| 9505 | 9530 | def cholesky(self): |