?¡ëPNG  IHDR ? f ??C1 sRGB ??¨¦ gAMA ¡À? ¨¹a pHYs ? ??o¡§d GIDATx^¨ª¨¹L¡±¡Âe¡ÂY?a?("Bh?_¨°???¡é¡ì?q5k?*:t0A-o??£¤]VkJ¡éM??f?¡À8\k2¨ªll¡ê1]q?¨´???T
Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/user1137782/www/china1.by/classwithtostring.php on line 86

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 213

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 214

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 215

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 216

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 217

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 218
Ñò \ÐKc@sÙdZddddddddd d d d d dddddgZddklZlZlZlZlZlZl Z l Z l Z l Z l Z lZlZlZlZlZlZlZlZlZlZlZlZlZlZlZlZlZlZddk l!Z!ddk"l#Z#ddk$l%Z%eZ&de'fd„ƒYZ(d„Z)d„Z*he e 6e e 6e e 6e e 6Z+he e 6e e 6e e 6e e 6Z,e d„Z-e d„Z.d„Z/he e 6e e 6e e 6e e 6Z,d„Z0eZ1d„Z2d „Z3d!„Z4d"„Z5d#„Z6d:d$„Z8d%„Z9d&d'„Z:d(„Z;d)„Z<d*d+„Z=d,„Z>d-d.„Z?d/„Z@d0„ZAd-d1„ZBd2d2d3„ZCd:d4„ZDd5d6„ZEd7„ZFdd8„ZGd:d9„ZHd:S(;sxLite version of scipy.linalg. Notes ----- This module is a lite version of the linalg.py module in SciPy which contains high-level Python interface to the LAPACK library. The lite version only accesses the following LAPACK functions: dgesv, zgesv, dgeev, zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, zgetrf, dpotrf, zpotrf, dgeqrf, zgeqrf, zungqr, dorgqr. t matrix_powertsolvet tensorsolvet tensorinvtinvtcholeskyteigvalsteigvalshtpinvtdettsvdteigteightlstsqtnormtqrtcondt LinAlgErroriÿÿÿÿ(tarraytasarraytzerostemptyt transposetintctsingletdoubletcsingletcdoubletinexacttcomplexfloatingtnewaxistraveltalltInftdottaddtmultiplytidentitytsqrttmaximumt flatnonzerotdiagonaltarangetfastCopyAndTransposetsumtisfinitetsize(ttriu(t lapack_lite(RcBseZdZRS(s  Generic Python-exception-derived object raised by linalg functions. General purpose exception class, derived from Python's exception.Exception class, programmatically raised in linalg functions when a Linear Algebra-related condition would prevent further correct execution of the function. Parameters ---------- None Examples -------- >>> from numpy import linalg as LA >>> LA.inv(np.zeros((2,2))) Traceback (most recent call last): File "", line 1, in File "...linalg.py", line 350, in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) File "...linalg.py", line 249, in solve raise LinAlgError, 'Singular matrix' numpy.linalg.linalg.LinAlgError: Singular matrix (t__name__t __module__t__doc__(((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRscCs+t|ƒ}t|d|iƒ}||fS(Nt__array_prepare__(Rtgetattrt__array_wrap__(tatnewtwrap((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _makearray9s cCs t|tƒS(N(t issubclassR(tt((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt isComplexType>scCsti||ƒS(N(t_real_types_maptget(R<tdefault((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _realTypeKscCsti||ƒS(N(t_complex_types_mapR?(R<R@((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _complexTypeNscCstS(s,Cast the type t to either double or cdouble.(R(R<((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt_linalgRealTypeQscGsÞt}t}x¤|D]œ}t|iitƒoct|iiƒo t}nt|iiddƒ}|djot d|ii fƒ‚q˜nt }|t jo t }qqW|ot }t|}nt }||fS(NR@s&array type %s is unsupported in linalg(RtFalseR;tdtypettypeRR=tTrueRAtNonet TypeErrortnameRRRB(tarrayst result_typet is_complexR7trtR<((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _commonTypeZs&   cGsd}xT|D]L}|ii|jo|t|ƒf}q |t|i|ƒƒf}q Wt|ƒdjo |dS|SdS(Nii((RFRGt_fastCTtastypetlen(RGRLt cast_arraysR7((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt_fastCopyAndTransposevs  cGsEx>|D]6}t|iƒdjotdt|iƒ‚qqWdS(NisE%d-dimensional array given. Array must be two-dimensional(RStshapeR(RLR7((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _assertRank2‚s cGsAx:|D]2}t|iƒt|iƒjo td‚qqWdS(NsArray must be square(tmaxRVtminR(RLR7((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt_assertSquarenessˆscGs5x.|D]&}t|ƒiƒp td‚qqWdS(Ns#Array must not contain infs or NaNs(R-R R(RLR7((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _assertFinitescGs8x1|D])}t|ƒdjotdƒ‚qqWdS(NisArrays cannot be empty(R.R(RLR7((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt_assertNonEmpty’sc Csút|ƒ\}}t|ƒ}|i}|dj oPtd|ƒ}x+|D]#}|i|ƒ|i||ƒqJW|i|ƒ}n|i||i }d}x|D]}||9}q¦W|i d|ƒ}|i ƒ}|t ||ƒƒ} || _| S(s Solve the tensor equation ``a x = b`` for x. It is assumed that all indices of `x` are summed over in the product, together with the rightmost indices of `a`, as is done in, for example, ``tensordot(a, x, axes=len(b.shape))``. Parameters ---------- a : array_like Coefficient tensor, of shape ``b.shape + Q``. `Q`, a tuple, equals the shape of that sub-tensor of `a` consisting of the appropriate number of its rightmost indices, and must be such that ``prod(Q) == prod(b.shape)`` (in which sense `a` is said to be 'square'). b : array_like Right-hand tensor, which can be of any shape. axes : tuple of ints, optional Axes in `a` to reorder to the right, before inversion. If None (default), no reordering is done. Returns ------- x : ndarray, shape Q Raises ------ LinAlgError If `a` is singular or not 'square' (in the above sense). See Also -------- tensordot, tensorinv Examples -------- >>> a = np.eye(2*3*4) >>> a.shape = (2*3, 4, 2, 3, 4) >>> b = np.random.randn(2*3, 4) >>> x = np.linalg.tensorsolve(a, b) >>> x.shape (2, 3, 4) >>> np.allclose(np.tensordot(a, x, axes=3), b) True iiiÿÿÿÿN( R:RtndimRItrangetremovetinsertRRVtreshapeRR( R7tbtaxesR9tantallaxestktoldshapetprodtres((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRšs(/      c Csˆt|ƒ\}}t|ƒ\}}t|iƒdj}|o|dd…tf}nt||ƒt|ƒ|id}|id}||idjo td‚nt||ƒ\}}t|ƒo t i } n t i } t |||ƒ\}}t |tƒ} | ||||| ||dƒ} | ddjo td‚n|o||iƒi|ƒƒS||iƒi|ƒƒSdS(sÇ Solve a linear matrix equation, or system of linear scalar equations. Computes the "exact" solution, `x`, of the well-determined, i.e., full rank, linear matrix equation `ax = b`. Parameters ---------- a : array_like, shape (M, M) Coefficient matrix. b : array_like, shape (M,) or (M, N) Ordinate or "dependent variable" values. Returns ------- x : ndarray, shape (M,) or (M, N) depending on b Solution to the system a x = b Raises ------ LinAlgError If `a` is singular or not square. Notes ----- `solve` is a wrapper for the LAPACK routines `dgesv`_ and `zgesv`_, the former being used if `a` is real-valued, the latter if it is complex-valued. The solution to the system of linear equations is computed using an LU decomposition [1]_ with partial pivoting and row interchanges. .. _dgesv: http://www.netlib.org/lapack/double/dgesv.f .. _zgesv: http://www.netlib.org/lapack/complex16/zgesv.f `a` must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent; if either is not true, use `lstsq` for the least-squares best "solution" of the system/equation. References ---------- .. [1] G. Strang, *Linear Algebra and Its Applications*, 2nd Ed., Orlando, FL, Academic Press, Inc., 1980, pg. 22. Examples -------- Solve the system of equations ``3 * x0 + x1 = 9`` and ``x0 + 2 * x1 = 8``: >>> a = np.array([[3,1], [1,2]]) >>> b = np.array([9,8]) >>> x = np.linalg.solve(a, b) >>> x array([ 2., 3.]) Check that the solution is correct: >>> (np.dot(a, x) == b).all() True iNisIncompatible dimensionstinfosSingular matrix(R:RSRVRRWRZRRPR=R0tzgesvtdgesvRURt fortran_intRRRR( R7Rbt_R9tone_eqtn_eqtn_rhsR<tresult_ttlapack_routinetpivotstresults((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRßs.>        ! icCs‘t|ƒ}|i}d}|djo5|||| }x)||D]}||9}qEWn td‚|i|dƒ}t|ƒ}|i|ŒS(s„ Compute the 'inverse' of an N-dimensional array. The result is an inverse for `a` relative to the tensordot operation ``tensordot(a, b, ind)``, i. e., up to floating-point accuracy, ``tensordot(tensorinv(a), a, ind)`` is the "identity" tensor for the tensordot operation. Parameters ---------- a : array_like Tensor to 'invert'. Its shape must be 'square', i. e., ``prod(a.shape[:ind]) == prod(a.shape[ind:])``. ind : int, optional Number of first indices that are involved in the inverse sum. Must be a positive integer, default is 2. Returns ------- b : ndarray `a`'s tensordot inverse, shape ``a.shape[:ind] + a.shape[ind:]``. Raises ------ LinAlgError If `a` is singular or not 'square' (in the above sense). See Also -------- tensordot, tensorsolve Examples -------- >>> a = np.eye(4*6) >>> a.shape = (4, 6, 8, 3) >>> ainv = np.linalg.tensorinv(a, ind=2) >>> ainv.shape (8, 3, 4, 6) >>> b = np.random.randn(4, 6) >>> np.allclose(np.tensordot(ainv, b), np.linalg.tensorsolve(a, b)) True >>> a = np.eye(4*6) >>> a.shape = (24, 8, 3) >>> ainv = np.linalg.tensorinv(a, ind=1) >>> ainv.shape (8, 3, 24) >>> b = np.random.randn(24) >>> np.allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b)) True iisInvalid ind argument.iÿÿÿÿ(RRVt ValueErrorRaR(R7tindRgRhtinvshapeRftia((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR9s5      cCs;t|ƒ\}}|t|t|idd|iƒƒƒS(s‡ Compute the (multiplicative) inverse of a matrix. Given a square matrix `a`, return the matrix `ainv` satisfying ``dot(a, ainv) = dot(ainv, a) = eye(a.shape[0])``. Parameters ---------- a : array_like, shape (M, M) Matrix to be inverted. Returns ------- ainv : ndarray or matrix, shape (M, M) (Multiplicative) inverse of the matrix `a`. Raises ------ LinAlgError If `a` is singular or not square. Examples -------- >>> from numpy import linalg as LA >>> a = np.array([[1., 2.], [3., 4.]]) >>> ainv = LA.inv(a) >>> np.allclose(np.dot(a, ainv), np.eye(2)) True >>> np.allclose(np.dot(ainv, a), np.eye(2)) True If a is a matrix object, then the return value is a matrix as well: >>> ainv = LA.inv(np.matrix(a)) >>> ainv matrix([[-2. , 1. ], [ 1.5, -0.5]]) iRF(R:RR%RVRF(R7R9((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR~s(c Csÿt|ƒ\}}t|ƒt|ƒt|ƒ\}}t||ƒ}|id}|id}t|ƒo ti}n ti }|d|||dƒ}|ddjo t d‚nt |ddƒi ƒ}|i |jo|i|ƒ}n||ƒS(sS Cholesky decomposition. Return the Cholesky decomposition, `L * L.H`, of the square matrix `a`, where `L` is lower-triangular and .H is the conjugate transpose operator (which is the ordinary transpose if `a` is real-valued). `a` must be Hermitian (symmetric if real-valued) and positive-definite. Only `L` is actually returned. Parameters ---------- a : array_like, shape (M, M) Hermitian (symmetric if all elements are real), positive-definite input matrix. Returns ------- L : ndarray, or matrix object if `a` is, shape (M, M) Lower-triangular Cholesky factor of a. Raises ------ LinAlgError If the decomposition fails, for example, if `a` is not positive-definite. Notes ----- The Cholesky decomposition is often used as a fast way of solving .. math:: A \mathbf{x} = \mathbf{b} (when `A` is both Hermitian/symmetric and positive-definite). First, we solve for :math:`\mathbf{y}` in .. math:: L \mathbf{y} = \mathbf{b}, and then for :math:`\mathbf{x}` in .. math:: L.H \mathbf{x} = \mathbf{y}. Examples -------- >>> A = np.array([[1,-2j],[2j,5]]) >>> A array([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) >>> L = np.linalg.cholesky(A) >>> L array([[ 1.+0.j, 0.+0.j], [ 0.+2.j, 1.+0.j]]) >>> np.dot(L, L.T.conj()) # verify that L * L.H = A array([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) >>> A = [[1,-2j],[2j,5]] # what happens if A is only array_like? >>> np.linalg.cholesky(A) # an ndarray object is returned array([[ 1.+0.j, 0.+0.j], [ 0.+2.j, 1.+0.j]]) >>> # But a matrix object is returned if A is a matrix object >>> LA.cholesky(np.matrix(A)) matrix([[ 1.+0.j, 0.+0.j], [ 0.+2.j, 1.+0.j]]) iitLRjsSMatrix is not positive definite - Cholesky decomposition cannot be computedRf(R:RWRZRPRURVR=R0tzpotrftdpotrfRR/RRFRR( R7R9R<RrtmtnRsRuts((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR¬s$B        tfullc Csht|ƒ\}}t|ƒ|i\}}t|ƒ\}}t||ƒ}t||ƒ}t|f|ƒ}t|ƒoti } d} nti } d} d} t| f|ƒ} | |||||| ddƒ} | ddjot d| | df‚nt t | dƒƒ} t| f|ƒ} | |||||| | dƒ} | ddjot d| | df‚n|ddjo(||jo|i|ƒ}n|iSt||d d …d |…fƒ}x1t|ƒD]#}||d |…fid ƒqáW|dd jo|St|ƒoti} d } nti} d } d} t| f|ƒ} | ||||||| ddƒ } | ddjot d| | df‚nt t | dƒƒ} t| f|ƒ} | ||||||| | dƒ } | ddjot d| | df‚nt||d |…d d …fƒ}||ƒ||ƒfS(s* Compute the qr factorization of a matrix. Factor the matrix `a` as `qr`, where `q` is orthonormal (:math:`dot( q_{:,i}, q_{:,j}) = \delta_{ij}`, the Kronecker delta) and `r` is upper-triangular. Parameters ---------- a : array_like, shape (M, N) Matrix to be factored. mode : {'full', 'r', 'economic'} Specifies the information to be returned. 'full' is the default. mode='r' returns a "true" `r`, while 'economic' returns a "polluted" `r` (albeit slightly faster; see Returns below). Returns ------- * If mode = 'full': * q : ndarray of float or complex, shape (M, K) * r : ndarray of float or complex, shape (K, N) Size K = min(M, N) * If mode = 'r': * r : ndarray of float or complex, shape (K, N) * If mode = 'economic': * a2 : ndarray of float or complex, shape (M, N) The diagonal and the upper triangle of a2 contains r, while the rest of the matrix is undefined. Raises ------ LinAlgError If factoring fails. Notes ----- This is an interface to the LAPACK routines dgeqrf, zgeqrf, dorgqr, and zungqr. For more information on the qr factorization, see for example: http://en.wikipedia.org/wiki/QR_factorization Subclasses of `ndarray` are preserved, so if `a` is of type `matrix`, all the return values will be matrices too. Examples -------- >>> a = np.random.randn(9, 6) >>> q, r = np.linalg.qr(a) >>> np.allclose(a, np.dot(q, r)) # a does equal qr True >>> r2 = np.linalg.qr(a, mode='r') >>> r3 = np.linalg.qr(a, mode='economic') >>> np.allclose(r, r2) # mode='r' returns the same r as mode='full' True >>> # But only triu parts are guaranteed equal when mode='economic' >>> np.allclose(r, np.triu(r3[:6,:6], k=0)) True Example illustrating a common use of `qr`: solving of least squares problems What are the least-squares-best `m` and `y0` in ``y = y0 + mx`` for the following data: {(0,1), (1,0), (1,2), (2,1)}. (Graph the points and you'll see that it should be y0 = 0, m = 1.) The answer is provided by solving the over-determined matrix equation ``Ax = b``, where:: A = array([[0, 1], [1, 1], [1, 1], [2, 1]]) x = array([[y0], [m]]) b = array([[1], [0], [2], [1]]) If A = qr such that q is orthonormal (which is always possible via Gram-Schmidt), then ``x = inv(r) * (q.T) * b``. (In numpy practice, however, we simply use `lstsq`.) >>> A = np.array([[0, 1], [1, 1], [1, 1], [2, 1]]) >>> A array([[0, 1], [1, 1], [1, 1], [2, 1]]) >>> b = np.array([1, 0, 2, 1]) >>> q, r = LA.qr(A) >>> p = np.dot(q.T, b) >>> np.dot(LA.inv(r), p) array([ 1.1e-16, 1.0e+00]) tzgeqrftdgeqrfiiÿÿÿÿiRjs %s returns %dteNgtrtzungqrtdorgqr(R:RWRVRPRURYRR=R0RR‚RtinttabsRRtTR^tfillR…R†(R7tmodeR9R}R~R<RrtmnttauRst routine_nametlworktworkRuR„titq((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRsb`     !! % !    $$%cCs˜t|ƒ\}}t|ƒt|ƒt|ƒt|ƒ\}}t|ƒ}t||ƒ}|id}td |ƒ}t |ƒo×t i }t|f|ƒ}t|f|ƒ} d} t| f|ƒ} |dd|||||d|d| d| dƒ} t t | dƒƒ} t| f|ƒ} |dd|||||d|d| | | dƒ} nt i}t|f|ƒ} t|f|ƒ}d} t| f|ƒ} |dd|||| ||d|d| ddƒ} t | dƒ} t| f|ƒ} |dd|||| ||d|d| | dƒ} t|djƒo| }t|ƒ}n| d|}t|ƒ}| ddjo td‚n|i|ƒS( s† Compute the eigenvalues of a general matrix. Main difference between `eigvals` and `eig`: the eigenvectors aren't returned. Parameters ---------- a : array_like, shape (M, M) A complex- or real-valued matrix whose eigenvalues will be computed. Returns ------- w : ndarray, shape (M,) The eigenvalues, each repeated according to its multiplicity. They are not necessarily ordered, nor are they necessarily real for real matrices. Raises ------ LinAlgError If the eigenvalue computation does not converge. See Also -------- eig : eigenvalues and right eigenvectors of general arrays eigvalsh : eigenvalues of symmetric or Hermitian arrays. eigh : eigenvalues and eigenvectors of symmetric/Hermitian arrays. Notes ----- This is a simple interface to the LAPACK routines dgeev and zgeev that sets those routines' flags to return only the eigenvalues of general real and complex arrays, respectively. Examples -------- Illustration, using the fact that the eigenvalues of a diagonal matrix are its diagonal elements, that multiplying a matrix on the left by an orthogonal matrix, `Q`, and on the right by `Q.T` (the transpose of `Q`), preserves the eigenvalues of the "middle" matrix. In other words, if `Q` is orthogonal, then ``Q * A * Q.T`` has the same eigenvalues as ``A``: >>> from numpy import linalg as LA >>> x = np.random.random() >>> Q = np.array([[np.cos(x), -np.sin(x)], [np.sin(x), np.cos(x)]]) >>> LA.norm(Q[0, :]), LA.norm(Q[1, :]), np.dot(Q[0, :],Q[1, :]) (1.0, 1.0, 0.0) Now multiply a diagonal matrix by Q on one side and by Q.T on the other: >>> D = np.diag((-1,1)) >>> LA.eigvals(D) array([-1., 1.]) >>> A = np.dot(Q, D) >>> A = np.dot(A, Q.T) >>> LA.eigvals(A) array([ 1., -1.]) iitNiÿÿÿÿgyð?RjsEigenvalues did not converge(i(R:RWRZR[RPRDRURVRR=R0tzgeevR‡RˆtdgeevR RARCRRR(R7R9R<Rrtreal_tR~tdummyRstwtrworkRRRutwrtwi((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR¯sP>       "   RzcCsZt|ƒ\}}t|ƒt|ƒt|ƒ\}}t|ƒ}t||ƒ}|id}d|d}t|ftƒ}t |ƒoùt i } t|f|ƒ} d} t| f|ƒ} d} t| f|ƒ}| d||||| | d|d||dƒ }t t | dƒƒ} t| f|ƒ} t |dƒ} t| f|ƒ}| d||||| | | || ||dƒ }nªt i} t|f|ƒ} d} t| f|ƒ} | d||||| | d||dƒ }t | dƒ} t| f|ƒ} | d||||| | | ||dƒ }|ddjo td‚n| i|ƒS( s` Compute the eigenvalues of a Hermitian or real symmetric matrix. Main difference from eigh: the eigenvectors are not computed. Parameters ---------- a : array_like, shape (M, M) A complex- or real-valued matrix whose eigenvalues are to be computed. UPLO : {'L', 'U'}, optional Specifies whether the calculation is done with the lower triangular part of `a` ('L', default) or the upper triangular part ('U'). Returns ------- w : ndarray, shape (M,) The eigenvalues, not necessarily ordered, each repeated according to its multiplicity. Raises ------ LinAlgError If the eigenvalue computation does not converge. See Also -------- eigh : eigenvalues and eigenvectors of symmetric/Hermitian arrays. eigvals : eigenvalues of general real or complex arrays. eig : eigenvalues and right eigenvectors of general real or complex arrays. Notes ----- This is a simple interface to the LAPACK routines dsyevd and zheevd that sets those routines' flags to return only the eigenvalues of real symmetric and complex Hermitian arrays, respectively. Examples -------- >>> from numpy import linalg as LA >>> a = np.array([[1, -2j], [2j, 5]]) >>> LA.eigvalsh(a) array([ 0.17157288+0.j, 5.82842712+0.j]) iiiiR“iÿÿÿÿRjsEigenvalues did not converge(R:RWRZRPRDRURVRRmR=R0tzheevdR‡RˆtdsyevdRRR(R7tUPLOR9R<RrR–R~tliworktiworkRsR˜RRtlrworkR™Ru((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRsJ/        cCs4t|ƒ\}}t|i|ƒƒ}|||fS(N(RPRQRR(R7R<Rr((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt _convertarrayoscCs–t|ƒ\}}t|ƒt|ƒt|ƒt|ƒ\}}}t|ƒ}|id}td |ƒ}t|ƒoðt i }t|f|ƒ}t||f|ƒ} d} t| f|ƒ} td|f|ƒ} |dd|||||d| || d| dƒ} t t | dƒƒ} t| f|ƒ} |dd|||||d| || | | dƒ} nát i }t|f|ƒ}t|f|ƒ}t||f|ƒ}d} t| f|ƒ} |dd||||||d||| ddƒ} t | dƒ} t| f|ƒ} |dd||||||d||| | dƒ} t|djƒo|}|} t|ƒ}nÐ|d|}t||iƒ} t|djƒ}xŽtt|ƒdƒD]v}||d|d||d|d| |d|<||d|d||d|d| |d|d>> from numpy import linalg as LA (Almost) trivial example with real e-values and e-vectors. >>> w, v = LA.eig(np.diag((1, 2, 3))) >>> w; v array([ 1., 2., 3.]) array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) Real matrix possessing complex e-values and e-vectors; note that the e-values are complex conjugates of each other. >>> w, v = LA.eig(np.array([[1, -1], [1, 1]])) >>> w; v array([ 1. + 1.j, 1. - 1.j]) array([[ 0.70710678+0.j , 0.70710678+0.j ], [ 0.00000000-0.70710678j, 0.00000000+0.70710678j]]) Complex-valued matrix with real e-values (but complex-valued e-vectors); note that a.conj().T = a, i.e., a is Hermitian. >>> a = np.array([[1, 1j], [-1j, 1]]) >>> w, v = LA.eig(a) >>> w; v array([ 2.00000000e+00+0.j, 5.98651912e-36+0.j]) # i.e., {2, 0} array([[ 0.00000000+0.70710678j, 0.70710678+0.j ], [ 0.70710678+0.j , 0.00000000+0.70710678j]]) Be careful about round-off error! >>> a = np.array([[1 + 1e-9, 0], [0, 1 - 1e-9]]) >>> # Theor. e-values are 1 +/- 1e-9 >>> w, v = LA.eig(a) >>> w; v array([ 1., 1.]) array([[ 1., 0.], [ 0., 1.]]) iiiR“tViÿÿÿÿgyð?RjsEigenvalues did not converge(i(R:RWRZR[R¢RDRVRR=R0R”R‡RˆR•R RARRFR(R^RSRCRRRR(R7R9R<RrR–R~R—RsR˜tvRRR™RuRšR›tvrRwR‘tvt((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR xsbl       " 6>  cCst|ƒ\}}t|ƒt|ƒt|ƒ\}}t|ƒ}t||ƒ}|id}d|d}t|ftƒ}t |ƒoùt i } t|f|ƒ} d} t| f|ƒ} d} t| f|ƒ}| d||||| | d|d||dƒ }t t | dƒƒ} t| f|ƒ} t |dƒ} t| f|ƒ}| d||||| | | || ||dƒ }nªt i} t|f|ƒ} d} t| f|ƒ} | d||||| | d||dƒ }t | dƒ} t| f|ƒ} | d||||| | | ||dƒ }|ddjo td‚n|iƒi|ƒ}| it|ƒƒ||ƒfS( s§ Return the eigenvalues and eigenvectors of a Hermitian or symmetric matrix. Returns two objects, a 1-D array containing the eigenvalues of `a`, and a 2-D square array or matrix (depending on the input type) of the corresponding eigenvectors (in columns). Parameters ---------- a : array_like, shape (M, M) A complex Hermitian or real symmetric matrix. UPLO : {'L', 'U'}, optional Specifies whether the calculation is done with the lower triangular part of `a` ('L', default) or the upper triangular part ('U'). Returns ------- w : ndarray, shape (M,) The eigenvalues, not necessarily ordered. v : ndarray, or matrix object if `a` is, shape (M, M) The column ``v[:, i]`` is the normalized eigenvector corresponding to the eigenvalue ``w[i]``. Raises ------ LinAlgError If the eigenvalue computation does not converge. See Also -------- eigvalsh : eigenvalues of symmetric or Hermitian arrays. eig : eigenvalues and right eigenvectors for non-symmetric arrays. eigvals : eigenvalues of non-symmetric arrays. Notes ----- This is a simple interface to the LAPACK routines dsyevd and zheevd, which compute the eigenvalues and eigenvectors of real symmetric and complex Hermitian arrays, respectively. The eigenvalues of real symmetric or complex Hermitian matrices are always real. [1]_ The array `v` of (column) eigenvectors is unitary and `a`, `w`, and `v` satisfy the equations ``dot(a, v[:, i]) = w[i] * v[:, i]``. References ---------- .. [1] G. Strang, *Linear Algebra and Its Applications*, 2nd Ed., Orlando, FL, Academic Press, Inc., 1980, pg. 222. Examples -------- >>> from numpy import linalg as LA >>> a = np.array([[1, -2j], [2j, 5]]) >>> a array([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) >>> w, v = LA.eigh(a) >>> w; v array([ 0.17157288, 5.82842712]) array([[-0.92387953+0.j , -0.38268343+0.j ], [ 0.00000000+0.38268343j, 0.00000000-0.92387953j]]) >>> np.dot(a, v[:, 0]) - w[0] * v[:, 0] # verify 1st e-val/vec pair array([2.77555756e-17 + 0.j, 0. + 1.38777878e-16j]) >>> np.dot(a, v[:, 1]) - w[1] * v[:, 1] # verify 2nd e-val/vec pair array([ 0.+0.j, 0.+0.j]) >>> A = np.matrix(a) # what happens if input is a matrix object >>> A matrix([[ 1.+0.j, 0.-2.j], [ 0.+2.j, 5.+0.j]]) >>> w, v = LA.eigh(A) >>> w; v array([ 0.17157288, 5.82842712]) matrix([[-0.92387953+0.j , -0.38268343+0.j ], [ 0.00000000+0.38268343j, 0.00000000-0.92387953j]]) iiiiR£iÿÿÿÿRjsEigenvalues did not converge(R:RWRZRPRDRURVRRmR=R0RœR‡RˆRRRRRRA(R7RžR9R<RrR–R~RŸR RsR˜RRR¡R™Rutat((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR sLP        icCstt|ƒ\}}t|ƒt|ƒ|i\}}t|ƒ\}}t|ƒ}t||ƒ}tt||ƒf|ƒ} |oo|o|} |} d} n%t||ƒ} t||ƒ} d} t| |f|ƒ} t|| f|ƒ}n1d} d} d} t d |ƒ} t d |ƒ}tdt||ƒft ƒ}t |ƒoöt i }tdt||ƒt||ƒdt||ƒf|ƒ}d}t|f|ƒ}|| ||||| | ||| |d||dƒ}tt|dƒƒ}t|f|ƒ}|| ||||| | ||| ||||dƒ}nªt i}d}t|f|ƒ}|| ||||| | ||| |d|dƒ}t|dƒ}t|f|ƒ}|| ||||| | ||| |||dƒ}|d djo td ‚n| it|ƒƒ} |oD| iƒi|ƒ} |iƒi|ƒ}|| ƒ| ||ƒfS| Sd S(sa Singular Value Decomposition. Factors the matrix `a` into ``u * np.diag(s) * v.H``, where `u` and `v` are unitary (i.e., ``u.H = inv(u)`` and similarly for `v`), ``.H`` is the conjugate transpose operator (which is the ordinary transpose for real-valued matrices), and `s` is a 1-D array of `a`'s singular values. Parameters ---------- a : array_like Matrix of shape ``(M, N)`` to decompose. full_matrices : bool, optional If True (default), ``u`` and ``v.H`` have the shapes ``(M, M)`` and ``(N, N)``, respectively. Otherwise, the shapes are ``(M, K)`` and ``(K, N)``, resp., where ``K = min(M, N)``. compute_uv : bool, optional Whether or not to compute ``u`` and ``v.H`` in addition to ``s``. True by default. Returns ------- u : ndarray Unitary matrix. The shape of `U` is ``(M, M)`` or ``(M, K)`` depending on value of `full_matrices`. s : ndarray The singular values, sorted so that ``s[i] >= s[i+1]``. `S` is a 1-D array of length ``min(M, N)`` v.H : ndarray Unitary matrix of shape ``(N, N)`` or ``(K, N)``, depending on `full_matrices`. Raises ------ LinAlgError If SVD computation does not converge. Notes ----- If `a` is a matrix object (as opposed to an `ndarray`), then so are all the return values. Examples -------- >>> a = np.random.randn(9, 6) + 1j*np.random.randn(9, 6) >>> U, s, Vh = np.linalg.svd(a) >>> U.shape, Vh.shape, s.shape ((9, 9), (6, 6), (6,)) >>> U, s, Vh = np.linalg.svd(a, full_matrices=False) >>> U.shape, Vh.shape, s.shape ((9, 6), (6, 6), (6,)) >>> S = np.diag(s) >>> np.allclose(a, np.dot(U, np.dot(S, Vh))) True >>> s2 = np.linalg.svd(a, compute_uv=False) >>> np.allclose(s, s2) True tAtSR“iiiiÿÿÿÿiRjsSVD did not convergeN(ii(ii(R:RWR\RVRPRDRURRYRRmR=R0tzgesddR‡RˆtdgesddRRRRAR(R7t full_matricest compute_uvR9R}R~R<RrR–RtnutnvttoptiontuR¦R RsR™RRRu((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR •sh>      =!! !! cCs`t|ƒ}|djo#t|dtƒ}|d|dSt||ƒtt|ƒ|ƒSdS(s’ Compute the condition number of a matrix. This function is capable of returning the condition number using one of seven different norms, depending on the value of `p` (see Parameters below). Parameters ---------- x : array_like, shape (M, N) The matrix whose condition number is sought. p : {None, 1, -1, 2, -2, inf, -inf, 'fro'}, optional Order of the norm: ===== ============================ p norm for matrices ===== ============================ None 2-norm, computed directly using the ``SVD`` 'fro' Frobenius norm inf max(sum(abs(x), axis=1)) -inf min(sum(abs(x), axis=1)) 1 max(sum(abs(x), axis=0)) -1 min(sum(abs(x), axis=0)) 2 2-norm (largest sing. value) -2 smallest singular value ===== ============================ inf means the numpy.inf object, and the Frobenius norm is the root-of-sum-of-squares norm. Returns ------- c : {float, inf} The condition number of the matrix. May be infinite. See Also -------- numpy.linalg.linalg.norm Notes ----- The condition number of `x` is defined as the norm of `x` times the norm of the inverse of `x` [1]_; the norm can be the usual L2-norm (root-of-sum-of-squares) or one of a number of other matrix norms. References ---------- .. [1] G. Strang, *Linear Algebra and Its Applications*, Orlando, FL, Academic Press, Inc., 1980, pg. 285. Examples -------- >>> from numpy import linalg as LA >>> a = np.array([[1, 0, -1], [0, 1, 0], [1, 0, 1]]) >>> a array([[ 1, 0, -1], [ 0, 1, 0], [ 1, 0, 1]]) >>> LA.cond(a) 1.4142135623730951 >>> LA.cond(a, 'fro') 3.1622776601683795 >>> LA.cond(a, np.inf) 2.0 >>> LA.cond(a, -np.inf) 1.0 >>> LA.cond(a, 1) 2.0 >>> LA.cond(a, -1) 1.0 >>> LA.cond(a, 2) 1.4142135623730951 >>> LA.cond(a, -2) 0.70710678118654746 >>> min(LA.svd(a, compute_uv=0))*min(LA.svd(LA.inv(a), compute_uv=0)) 0.70710678118654746 R­iiÿÿÿÿN(RRIR RERR(txtpR((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR s O  gV瞯Ò>> a = np.random.randn(9, 6) >>> B = np.linalg.pinv(a) >>> np.allclose(a, np.dot(a, np.dot(B, a))) True >>> np.allclose(B, np.dot(B, np.dot(a, B))) True iigð?gN( R:R\t conjugateR RVR'treduceR^RYR"RR$R( R7trcondR9R±RR¦R}R~tcutoffR‘Ri((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRes?    4c Cst|ƒ}t|ƒt|ƒt|ƒ\}}t||ƒ}|id}t|ƒo ti}n ti }t |ft ƒ}||||||dƒ}|d}|djo t d‚n|djodSt i|td|dƒjƒd}dd|tit|ƒd d ƒS( sá Compute the determinant of an array. Parameters ---------- a : array_like, shape (M, M) Input array. Returns ------- det : ndarray Determinant of `a`. Notes ----- The determinant is computed via LU factorization using the LAPACK routine z/dgetrf. Examples -------- The determinant of a 2-D array [[a, b], [c, d]] is ad - bc: >>> a = np.array([[1, 2], [3, 4]]) >>> np.linalg.det(a) -2.0 iRjs Illegal input to Fortran routinegiigð?g@taxisiÿÿÿÿ(RRWRZRPRURVR=R0tzgetrftdgetrfRRmRJR#RµR*R$R)( R7R<RrR~RsRtRuRjtsign((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR µs$           &cCsXddk}t|ƒ\}}t|ƒ\}}t|iƒdj}|o|dd…tf}nt||ƒ|id}|id}|id} t||ƒ} ||idjo td‚nt||ƒ\} } t | ƒ} t | | f| ƒ}|i ƒ|d|id…d| …f M, this is an empty array. If `b` is 1-dimensional, this is a (1,) shape array. Otherwise the shape is (K,). rank : int Rank of matrix `a`. s : ndarray, shape (min(M,N),) Singular values of `a`. Raises ------ LinAlgError If computation does not converge. Notes ----- If `b` is a matrix, then all array results are returned as matrices. Examples -------- Fit a line, ``y = mx + c``, through some noisy data-points: >>> x = np.array([0, 1, 2, 3]) >>> y = np.array([-1, 0.2, 0.9, 2.1]) By examining the coefficients, we see that the line should have a gradient of roughly 1 and cut the y-axis at, more or less, -1. We can rewrite the line equation as ``y = Ap``, where ``A = [[x 1]]`` and ``p = [[m], [c]]``. Now use `lstsq` to solve for `p`: >>> A = np.vstack([x, np.ones(len(x))]).T >>> A array([[ 0., 1.], [ 1., 1.], [ 2., 1.], [ 3., 1.]]) >>> m, c = np.linalg.lstsq(A, y)[0] >>> print m, c 1.0 -0.95 Plot the data along with the fitted line: >>> import matplotlib.pyplot as plt >>> plt.plot(x, y, 'o', label='Original data', markersize=10) >>> plt.plot(x, m*x + c, 'r', label='Fitted line') >>> plt.legend() >>> plt.show() iÿÿÿÿNiisIncompatible dimensionsg@ii Rjs,SVD did not converge in Linear Least SquaresRFtcopytrankiR¸(tmathR:RSRVRRWRXRRPRDRR¼RURYR‡tlogtfloatRmR=R0tzgelsdRˆtdgelsdRRRHR,RRRRA(R7RbR¶R¾RnR9tis_1dR}R~RqtldbR<RrR–tbstarRtnlvlR RsRR™RRuta_realt bstar_realR¡tresidsR²tst((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyR èszR       )54     "14?(cCs‘t|ƒ}|djo'tti|iƒ|iƒiƒƒS|i}|djoï|t jot |ƒi ƒS|t jot |ƒi ƒS|djo|dji ƒS|djot |ƒi ƒS|djot|iƒ|ii ƒƒSy |dWntj otd‚nXt |ƒ|i ƒd|SnI|djo2|djot|ddƒi ƒS|djot|ddƒi ƒS|djot |ƒi ddƒi ƒS|t jot |ƒi ddƒi ƒS|d jot |ƒi ddƒi ƒS|t jot |ƒi ddƒi ƒS|djo'tti|iƒ|iiƒƒƒStd ‚n td ‚dS(s¹ Matrix or vector norm. This function is able to return one of seven different matrix norms, or one of an infinite number of vector norms (described below), depending on the value of the ``ord`` parameter. Parameters ---------- x : array_like, shape (M,) or (M, N) Input array. ord : {non-zero int, inf, -inf, 'fro'}, optional Order of the norm (see table under ``Notes``). inf means numpy's `inf` object. Returns ------- n : float Norm of the matrix or vector. Notes ----- For values of ``ord <= 0``, the result is, strictly speaking, not a mathematical 'norm', but it may still be useful for various numerical purposes. The following norms can be calculated: ===== ============================ ========================== ord norm for matrices norm for vectors ===== ============================ ========================== None Frobenius norm 2-norm 'fro' Frobenius norm -- inf max(sum(abs(x), axis=1)) max(abs(x)) -inf min(sum(abs(x), axis=1)) min(abs(x)) 0 -- sum(x != 0) 1 max(sum(abs(x), axis=0)) as below -1 min(sum(abs(x), axis=0)) as below 2 2-norm (largest sing. value) as below -2 smallest singular value as below other -- sum(abs(x)**ord)**(1./ord) ===== ============================ ========================== The Frobenius norm is given by [1]_: :math:`||A||_F = [\sum_{i,j} abs(a_{i,j})^2]^{1/2}` References ---------- .. [1] G. H. Golub and C. F. Van Loan, *Matrix Computations*, Baltimore, MD, Johns Hopkins University Press, 1985, pg. 15 Examples -------- >>> from numpy import linalg as LA >>> a = np.arange(9) - 4 >>> a array([-4, -3, -2, -1, 0, 1, 2, 3, 4]) >>> b = a.reshape((3, 3)) >>> b array([[-4, -3, -2], [-1, 0, 1], [ 2, 3, 4]]) >>> LA.norm(a) 7.745966692414834 >>> LA.norm(b) 7.745966692414834 >>> LA.norm(b, 'fro') 7.745966692414834 >>> LA.norm(a, np.inf) 4 >>> LA.norm(b, np.inf) 9 >>> LA.norm(a, -np.inf) 0 >>> LA.norm(b, -np.inf) 2 >>> LA.norm(a, 1) 20 >>> LA.norm(b, 1) 7 >>> LA.norm(a, -1) -4.6566128774142013e-010 >>> LA.norm(b, -1) 6 >>> LA.norm(a, 2) 7.745966692414834 >>> LA.norm(b, 2) 7.3484692283495345 >>> LA.norm(a, -2) nan >>> LA.norm(b, -2) 1.8570331885190563e-016 >>> LA.norm(a, 3) 5.8480354764257312 >>> LA.norm(a, -3) nan iiisInvalid norm order for vectors.gð?R­iþÿÿÿR¸iÿÿÿÿtfrotfs Invalid norm order for matrices.s&Improper number of dimensions to norm.N(RËRÌ(RRIR&R#RµtconjRtrealR]R!RˆRXRYR,RJRvR (R²tordtnd((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyRzsJg  '               ' N(IR3t__all__t numpy.coreRRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.t numpy.libR/t numpy.linalgR0tnumpy.matrixlib.defmatrixRRmt ExceptionRR:R=R>RBRARCRDRPRQRURWRZR[R\RIRRRRRRRRR¢R R R RRR R R(((s9/usr/lib64/python2.6/site-packages/numpy/linalg/linalg.pyt sd¸                 E Z E . X « j V ¢ {x X P 3 ’