Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
linalg
/
__pycache__
/
File Content:
decomp_lu.cpython-35.opt-1.pyc
�<WW� � @ s� d Z d d l m Z m Z m Z d d l m Z d d l m Z m Z d d l m Z d d l m Z d d l m Z d d d g Z d d d d � Z d d d d d � Z d d d d d � Z d S)zLU decomposition functions.� )�division�print_function�absolute_import)�warn)�asarray�asarray_chkfinite� )�_datacopied)�get_lapack_funcs)�get_flinalg_funcs�lu�lu_solve� lu_factorFTc 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 k r� t d | � � | d k r� t d | t � | | f S) a� Compute pivoted LU decomposition of a matrix. The decomposition is:: A = P L U where P is a permutation matrix, L lower triangular with unit diagonal elements, and U upper triangular. Parameters ---------- a : (M, M) array_like Matrix to decompose overwrite_a : bool, optional Whether to overwrite data in A (may increase 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 ------- lu : (N, N) ndarray Matrix containing U in its upper triangle, and L in its lower triangle. The unit diagonal elements of L are not stored. piv : (N,) ndarray Pivot indices representing the permutation matrix P: row i of matrix was interchanged with row piv[i]. See also -------- lu_solve : solve an equation system using the LU factorization of a matrix Notes ----- This is a wrapper to the ``*GETRF`` routines from LAPACK. � r r zexpected square matrix�getrf�overwrite_az=illegal value in %d-th argument of internal getrf (lu_factor)z4Diagonal number %d is exactly zero. Singular matrix.)r ) r r �len�shape� ValueErrorr r r �RuntimeWarning)�ar �check_finite�a1r r �piv�info� r � /decomp_lu.pyr s (/ c C s� | \ } } | r! t | � } n t | � } | p? t | | � } | j d | j d k rh t d � � t d | | f � \ } | | | | d | d | �\ } } | d k r� | St d | � � d S) a� Solve an equation system, a x = b, given the LU factorization of a Parameters ---------- (lu, piv) Factorization of the coefficient matrix a, as given by lu_factor b : array Right-hand side trans : {0, 1, 2}, optional Type of system to solve: ===== ========= trans system ===== ========= 0 a x = b 1 a^T x = b 2 a^H x = b ===== ========= overwrite_b : bool, optional Whether to overwrite data in b (may increase 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 Solution to the system See also -------- lu_factor : LU factorize a matrix r zincompatible dimensions.�getrs�trans�overwrite_bz5illegal value in %d-th argument of internal gesv|posvN)r )r r r r r r )Z lu_and_piv�br r r r r Zb1r �xr r r r r K s $$c C s� | r t | � } n t | � } t | j � d k rB t d � � | pT t | | � } t d | f � \ } | | d | d | �\ } } } } | d k r� t d | � � | r� | | f S| | | f S) a Compute pivoted LU decomposition of a matrix. The decomposition is:: A = P L U where P is a permutation matrix, L lower triangular with unit diagonal elements, and U upper triangular. Parameters ---------- a : (M, N) array_like Array to decompose permute_l : bool, optional Perform the multiplication P*L (Default: do not permute) 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 ------- **(If permute_l == False)** p : (M, M) ndarray Permutation matrix l : (M, K) ndarray Lower triangular or trapezoidal matrix with unit diagonal. K = min(M, N) u : (K, N) ndarray Upper triangular or trapezoidal matrix **(If permute_l == True)** pl : (M, K) ndarray Permuted L matrix. K = min(M, N) u : (K, N) ndarray Upper triangular or trapezoidal matrix Notes ----- This is a LU factorization routine written for Scipy. r zexpected matrixr � permute_lr r z4illegal value in %d-th argument of internal lu.getrf)r )r r r r r r r ) r r"