Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
linalg
/
__pycache__
/
File Content:
decomp_qr.cpython-35.opt-1.pyc
=WW�1 � @ s� d Z d d l m Z m Z m Z d d l Z d d l m Z d d l m Z d d d g Z d d � Z d d d d d d d � Z d d d d d d d � Z d d d d d d � Z d S)zQR decomposition functions.� )�division�print_function�absolute_importN� )�get_lapack_funcs)�_datacopied�qr�qr_multiply�rqc O s� | j d d � } | d k rX d | d <| | | � } | d d j j t j � | d <| | | � } | d d k r� t d | d | f � � | d d � S)z[Call a LAPACK routine, determining lwork automatically and handling error return values�lworkNr � r z.illegal value in %d-th argument of internal %s���)Nr r ���r r r )�get�realZastype�numpy�int� ValueError)�f�name�args�kwargsr Zret� r � /decomp_qr.py�safecall s !r F�fullTc C s� | d k r t d � � | r0 t j | � } n t j | � } t | j � d k r` t d � � | j \ } } | p� t | | � } | r� t d | f � \ } t | d | d | �\ } } } | d 8} n9 t d | f � \ } t | d | d | d | �\ } } | d k s| | k r0t j | � } n% t j | d | � d d � f � } | rj| | f } n | f } | d k r�| S| d k r�| | f f | St d | f � \ } | | k r�t | d | d d � d | � f | d | d d �\ } n� | d k r1t | d | | d | d d �\ } ng | j j } t j | | f d | �} | | d d � d | � f <t | d | | d | d d �\ } | f | S)a@ Compute QR decomposition of a matrix. Calculate the decomposition ``A = Q R`` where Q is unitary/orthogonal and R upper triangular. Parameters ---------- a : (M, N) array_like Matrix to be decomposed overwrite_a : bool, optional Whether data in a is overwritten (may improve performance) lwork : int, optional Work array size, lwork >= a.shape[1]. If None or -1, an optimal size is computed. mode : {'full', 'r', 'economic', 'raw'}, optional Determines what information is to be returned: either both Q and R ('full', default), only R ('r') or both Q and R but computed in economy-size ('economic', see Notes). The final option 'raw' (added in Scipy 0.11) makes the function return two matrices (Q, TAU) in the internal format used by LAPACK. pivoting : bool, optional Whether or not factorization should include pivoting for rank-revealing qr decomposition. If pivoting, compute the decomposition ``A P = Q R`` as above, but where P is chosen such that the diagonal of R is non-increasing. 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 ------- Q : float or complex ndarray Of shape (M, M), or (M, K) for ``mode='economic'``. Not returned if ``mode='r'``. R : float or complex ndarray Of shape (M, N), or (K, N) for ``mode='economic'``. ``K = min(M, N)``. P : int ndarray Of shape (N,) for ``pivoting=True``. Not returned if ``pivoting=False``. Raises ------ LinAlgError Raised if decomposition fails Notes ----- This is an interface to the LAPACK routines dgeqrf, zgeqrf, dorgqr, zungqr, dgeqp3, and zgeqp3. If ``mode=economic``, the shapes of Q and R are (M, K) and (K, N) instead of (M,M) and (M,N), with ``K=min(M,N)``. Examples -------- >>> from scipy import random, linalg, dot, diag, all, allclose >>> a = random.randn(9, 6) >>> q, r = linalg.qr(a) >>> allclose(a, np.dot(q, r)) True >>> q.shape, r.shape ((9, 9), (9, 6)) >>> r2 = linalg.qr(a, mode='r') >>> allclose(r, r2) True >>> q3, r3 = linalg.qr(a, mode='economic') >>> q3.shape, r3.shape ((9, 6), (6, 6)) >>> q4, r4, p4 = linalg.qr(a, pivoting=True) >>> d = abs(diag(r4)) >>> all(d[1:] <= d[:-1]) True >>> allclose(a[:, p4], dot(q4, r4)) True >>> q4.shape, r4.shape, p4.shape ((9, 9), (9, 6), (6,)) >>> q5, r5, p5 = linalg.qr(a, mode='economic', pivoting=True) >>> q5.shape, r5.shape, p5.shape ((9, 6), (6, 6), (6,)) r r �r�economic�rawz?Mode argument should be one of ['full', 'r', 'economic', 'raw']r zexpected 2D array�geqp3�overwrite_ar �geqrfr N�orgqrz gorgqr/gungqr�dtype)r r r r r )r )r! )r r )r"