Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
linalg
/
__pycache__
/
File Content:
decomp_cholesky.cpython-35.pyc
�<WW�% � @ s� d Z d d l m Z m Z m Z d d l m Z m Z d d l m Z m Z d d l m Z d d d d d g Z d d d d d d � Z d d d d d � Z d d d d d � Z d d d d � Z d d d d d � Z d d d d � Z d S)z!Cholesky decomposition functions.� )�division�print_function�absolute_import)�asarray_chkfinite�asarray� )�LinAlgError�_datacopied)�get_lapack_funcs�cholesky� cho_factor� cho_solve�cholesky_banded�cho_solve_bandedFTc C s� | r t | � } n t | � } t | j � d k sP | j d | j d k r\ t d � � | pn t | | � } t d | f � \ } | | d | d | d | �\ } } | d k r� t d | � � | d k r� t d | � � | | f S)z,Common code for cholesky() and cho_factor().� r r zexpected square matrix�potrf�lower�overwrite_a�cleanz)%d-th leading minor not positive definitez1illegal value in %d-th argument of internal potrf)r )r r �len�shape� ValueErrorr r r ) �ar r r �check_finiteZa1r �c�info� r �/decomp_cholesky.py� _cholesky s /$r c C s. t | d | d | d d d | �\ } } | S)a� Compute the Cholesky decomposition of a matrix. Returns the Cholesky decomposition, :math:`A = L L^*` or :math:`A = U^* U` of a Hermitian positive-definite matrix A. Parameters ---------- a : (M, M) array_like Matrix to be decomposed lower : bool, optional Whether to compute the upper or lower triangular Cholesky factorization. Default is upper-triangular. overwrite_a : bool, optional Whether to overwrite data in `a` (may improve performance). check_finite : bool, optional Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Returns ------- c : (M, M) ndarray Upper- or lower-triangular Cholesky factor of `a`. Raises ------ LinAlgError : if decomposition fails. Examples -------- >>> from scipy import array, linalg, dot >>> a = array([[1,-2j],[2j,5]]) >>> L = linalg.cholesky(a, lower=True) >>> L array([[ 1.+0.j, 0.+0.j], [ 0.+2.j, 1.+0.j]]) >>> dot(L, L.T.conj()) array([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) r r r Tr )r )r r r r r r r r r % s +c C s4 t | d | d | d d d | �\ } } | | f S)a= Compute the Cholesky decomposition of a matrix, to use in cho_solve Returns a matrix containing the Cholesky decomposition, ``A = L L*`` or ``A = U* U`` of a Hermitian positive-definite matrix `a`. The return value can be directly used as the first parameter to cho_solve. .. warning:: The returned matrix also contains random data in the entries not used by the Cholesky decomposition. If you need to zero these entries, use the function `cholesky` instead. Parameters ---------- a : (M, M) array_like Matrix to be decomposed lower : bool, optional Whether to compute the upper or lower triangular Cholesky factorization (Default: upper-triangular) overwrite_a : bool, optional Whether to overwrite data in a (may improve performance) check_finite : bool, optional Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Returns ------- c : (M, M) ndarray Matrix whose upper or lower triangle contains the Cholesky factor of `a`. Other parts of the matrix contain random data. lower : bool Flag indicating whether the factor is in the lower or upper triangle Raises ------ LinAlgError Raised if decomposition fails. See also -------- cho_solve : Solve a linear set equations using the Cholesky factorization of a matrix. r r r Fr )r )r r r r r r r r r U s .c C s | \ } } | r- t | � } t | � } n t | � } t | � } | j d k sn | j d | j d k rz t d � � | j d | j d k r� t d � � | p� t | | � } t d | | f � \ } | | | d | d | �\ } } | d k rt d | � � | S)a Solve the linear equations A x = b, given the Cholesky factorization of A. Parameters ---------- (c, lower) : tuple, (array, bool) Cholesky factorization of a, as given by cho_factor b : array Right-hand side overwrite_b : bool, optional Whether to overwrite data in b (may improve performance) check_finite : bool, optional Whether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. Returns ------- x : array The solution to the system A x = b See also -------- cho_factor : Cholesky factorization of a matrix r r r z$The factored matrix c is not square.zincompatible dimensions.�potrsr �overwrite_bz1illegal value in %d-th argument of internal potrs)r )r r �ndimr r r r ) Zc_and_lower�br r r r Zb1r �xr r r r r � s"