Ticket #13045: trac_13045-deprecate-cholesky-decomposition-update.patch

File trac_13045-deprecate-cholesky-decomposition-update.patch, 2.4 KB (added by rbeezer, 12 months ago)
  • sage/matrix/matrix2.pyx

    # 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  
    92989298        .. WARNING:: 
    92999299 
    93009300            ``cholesky_decomposition()`` is deprecated, 
    9301             please use ``cholesky()`` instead. 
     9301            please use :meth:`cholesky` instead. 
    93029302 
    93039303        The computed decomposition is cached and returned on 
    93049304        subsequent calls. Methods such as :meth:`solve_left` may also 
     
    94679467            sage: L*L.conjugate().transpose() 
    94689468            [   1.0 -2.0*I] 
    94699469            [ 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] 
    94709495        """ 
    94719496        # deprecation added 2012-05-27 
    94729497        from sage.misc.misc import deprecation 
     
    94829507 
    94839508        This generic implementation uses a standard recursion. 
    94849509        """ 
    9485         L = self.fetch('cholesky') 
     9510        L = self.fetch('cholesky_broken') 
    94869511        if L is None: 
    94879512            A = self.__copy__() 
    94889513            L = A.parent()(0) 
     
    94999524                    for i in range(j, n): 
    95009525                        A[i, j] -= L[i, k]*L[j, k].conjugate() 
    95019526            L.set_immutable() 
    9502             self.cache('cholesky', L) 
     9527            self.cache('cholesky_broken', L) 
    95039528        return L 
    95049529 
    95059530    def cholesky(self):