Ñò
ÀåØIc           @   sN  d  d d d g Z  d d k Z d d k Z d d k l Z l Z l Z l Z d d k l	 Z	 e
 g d Z x$ e d ƒ D] Z e e ƒ e e <qv Wd	 i e ƒ Z d
 Z g  Z x, e D]$ Z e e j o e i e ƒ n q² Wd	 i e ƒ Z [ d „  Z d „  Z e
 d „ Z d „  Z d  e i f d „  ƒ  YZ d „  Z e
 e
 d „ Z e Z d S(   t   matrixt   bmatt   matt   asmatrixiÿÿÿÿN(   t   concatenatet   isscalart   binary_reprt   identity(   t
   issubdtypei   t    s   0123456789.-+jeELc         C   s   t  |  i t t ƒ ƒ S(   N(   t   evalt	   translatet   _tablet	   _todelete(   t   astr(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   _eval   s    c   
      C   sÌ   |  i  d ƒ } g  } d } xª | D]¢ } | i  d ƒ } g  } x0 | D]( } | i  ƒ  } | i t t | ƒ ƒ qD W| d j o t | ƒ }	 n! t | ƒ |	 j o t d ‚ n | d 7} | i | ƒ q" W| S(   Nt   ;i    t   ,s   Rows not the same size.i   (   t   splitt   extendt   mapR   t   lent
   ValueErrort   append(
   t   datat   rowst   newdatat   countt   rowt   trowt   newrowt   colt   tempt   Ncols(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   _convert_from_string   s$      
c         C   s   t  |  d | d t ƒS(   s  
    Interpret the input as a matrix.

    Unlike `matrix`, `asmatrix` does not make a copy if the input is already
    a matrix or an ndarray.  Equivalent to ``matrix(data, copy=False)``.

    Parameters
    ----------
    data : array_like
        Input data.

    Returns
    -------
    mat : matrix
        `data` interpreted as a matrix.

    Examples
    --------
    >>> x = np.array([[1, 2], [3, 4]])

    >>> m = np.asmatrix(x)

    >>> x[0,0] = 5

    >>> m
    matrix([[5, 2],
            [3, 4]])

    t   dtypet   copy(   R    t   False(   R   R#   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR   +   s    c   
      C   sá  t  |  i ƒ d j p |  i d |  i d j o t d ƒ ‚ n t t | ƒ t ƒ p t d ƒ ‚ n d d k l } | d j o% |  i	 ƒ  }  t
 |  i d ƒ |  (|  S| d j  o | |  ƒ }  | d 9} n |  } | d j o2 x* t | d ƒ D] } t i | |  ƒ } qô W| St | ƒ } |  d t  | ƒ } } } x: | | | d d	 j o  t i | | ƒ } | d 7} q>W| } x\ t | d | ƒ D]G }	 t i | | ƒ } | | |	 d d
 j o t i | | ƒ } q’q’W| S(   s¼  
    Raise a square matrix to the (integer) power n.

    For positive integers n, the power is computed by repeated matrix
    squarings and matrix multiplications. If n=0, the identity matrix
    of the same type as M is returned. If n<0, the inverse is computed
    and raised to the exponent.

    Parameters
    ----------
    M : array_like
        Must be a square array (that is, of dimension two and with
        equal sizes).
    n : integer
        The exponent can be any integer or long integer, positive
        negative or zero.

    Returns
    -------
    M to the power n
        The return value is a an array the same shape and size as M;
        if the exponent was positive or zero then the type of the
        elements is the same as those of M. If the exponent was negative
        the elements are floating-point.

    Raises
    ------
    LinAlgException
        If the matrix is not numerically invertible, an exception is raised.

    See Also
    --------
    The matrix() class provides an equivalent function as the exponentiation
    operator.

    Examples
    --------
    >>> np.linalg.matrix_power(np.array([[0,1],[-1,0]]),10)
    array([[-1,  0],
           [ 0, -1]])

    i   i    i   s   input must be a square arrays   exponent must be an integeriÿÿÿÿ(   t   invi   t   0t   1(   R   t   shapeR   R   t   typet   intt	   TypeErrort   numpy.linalgR&   R$   R   t   ranget   Nt   dotR   (
   t   Mt   nR&   t   resultt   _t   betat   Zt   qt   tt   k(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   matrix_powerK   s>    +1   c           B   sî  e  Z d  Z d Z d' e d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d' d' d' d „ Z 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 „ Z d' d' d „ Z d' d' d „ Z d' d' d „ Z d' d' d „ Z d' d' d „ Z d' d' d „ Z d „  Z d „  Z  d „  Z! d „  Z" d  „  Z# e$ e" d' d! d" ƒZ% e$ e  d' d! d# ƒZ& e$ e! d' d! d$ ƒZ' e$ e# d' d! d% ƒZ( e$ e d' d! d& ƒZ) RS((   sÄ  
    matrix(data, dtype=None, copy=True)

    Returns a matrix from an array-like object, or from a string
    of data.  A matrix is a specialized 2-d array that retains
    its 2-d nature through operations.  It has certain special
    operators, such as ``*`` (matrix multiplication) and
    ``**`` (matrix power).

    Parameters
    ----------
    data : array_like or string
       If data is a string, the string is interpreted as a matrix
       with commas or spaces separating columns, and semicolons
       separating rows.
    dtype : data-type
       Data-type of the output matrix.
    copy : bool
       If data is already an ndarray, then this flag determines whether
       the data is copied, or whether a view is constructed.

    See Also
    --------
    array

    Examples
    --------
    >>> a = np.matrix('1 2; 3 4')
    >>> print a
    [[1 2]
     [3 4]]

    >>> np.matrix([[1, 2], [3, 4]])
    matrix([[1, 2],
            [3, 4]])

    g      $@c         C   só  t  | t ƒ oH | i } | d  j o
 | } n | | j o | o | S| i | ƒ St  | t i ƒ op | d  j o | i } n t i | ƒ } | i |  ƒ } | | i j o | i | ƒ S| o | i ƒ  S| Sn t  | t	 ƒ o t
 | ƒ } n t i | d | d | ƒ} | i } | i }	 | d j o t d ‚ n9 | d j o
 d	 }	 n" | d j o d |	 d f }	 n t }
 | d j o | i i o
 t }
 n |
 p
 | i i p | i ƒ  } n t i i |  |	 | i d | d |
 ƒ} | S(
   NR#   R$   i   s   matrix must be 2-dimensionali    i   t   buffert   order(   i   i   (   t
   isinstanceR    R#   t   Nonet   astypeR/   t   ndarrayt   viewR$   t   strR"   t   arrayt   ndimR)   R   R%   t   flagst   fortrant   Truet
   contiguoust   __new__(   t   subtypeR   R#   R$   t   dtype2t   intypet   newt   arrRD   R)   R<   t   ret(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRI   Á   sJ    	
 		

	c         C   s  t  |  _ t | t ƒ o | i o d  S|  i } | d j o d  S| d j o€ t g  } |  i D] } | d j o | | qa qa ~ ƒ } t | ƒ } | d j o | |  _ d  S| d j o t d ‚ qÙ n
 |  i } | d j o d |  _ n% | d j o d | d f |  _ n d  S(   Ni   i   s   shape too large to be a matrix.i    (   i   i   (	   R%   t   _getitemR=   R    RD   t   tupleR)   R   R   (   t   selft   objRD   t   _[1]t   xt   newshape(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __array_finalize__ï   s(    	 	;		c      	   C   så   t  |  _ z t i i |  | ƒ } Wd  t |  _ Xt | t i ƒ p | S| i d j o	 | d S| i d j oq | i d } y t	 | ƒ } Wn d } n X| d j o$ t
 | d ƒ o | d f | _ qá d | f | _ n | S(   Ni    i   (    (   RG   RP   R/   R@   t   __getitem__R%   R=   RD   R)   R   R   (   RR   t   indext   outt   shR2   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRX     s$    	
	
c         C   sf   t  | t i t t f ƒ o t i |  t | ƒ ƒ St | ƒ p t | d ƒ o t i |  | ƒ St	 S(   Nt   __rmul__(
   R=   R/   R@   t   listRQ   R0   R   R   t   hasattrt   NotImplemented(   RR   t   other(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __mul__  s
    c         C   s   t  i | |  ƒ S(   N(   R/   R0   (   RR   R`   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR\   '  s    c         C   s   |  | |  (|  S(   N(    (   RR   R`   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __imul__*  s    c         C   s   t  |  | ƒ S(   N(   R:   (   RR   R`   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __pow__.  s    c         C   s   |  | |  (|  S(   N(    (   RR   R`   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __ipow__1  s    c         C   s   t  S(   N(   R_   (   RR   R`   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __rpow__5  s    c         C   sx   t  |  i ƒ  ƒ i d d ƒ } | i ƒ  } x> t d t | ƒ ƒ D]' } | | o d | | | | <q@ q@ Wd i | ƒ S(   NRC   R    i   t    s   
(   t   reprt	   __array__t   replacet
   splitlinesR.   R   t   join(   RR   t   st   lt   i(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __repr__8  s     c         C   s   t  |  i ƒ  ƒ S(   N(   RB   Rh   (   RR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   __str__B  s    c         C   sM   | d j o	 |  d S| d j o |  S| d j o |  i ƒ  St d ‚ d S(   s^   A convenience function for operations that need to preserve axis
        orientation.
        i    i   s   unsupported axisN(   i    i    (   R>   t	   transposeR   (   RR   t   axis(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   _alignE  s    	c         C   s   |  i  ƒ  i ƒ  S(   N(   Rh   t   tolist(   RR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRt   T  s    c         C   s"   t  i i |  | | | ƒ i | ƒ S(   s­   Sum the matrix over the given axis.  If the axis is None, sum
        over all dimensions.  This preserves the orientation of the
        result as a row or column.
        (   R/   R@   t   sumRs   (   RR   Rr   R#   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRu   X  s    c         C   s"   t  i i |  | | | ƒ i | ƒ S(   sè  Compute the mean along the specified axis.

        Returns the average of the array elements.  The average is taken over
        the flattened array by default, otherwise over the specified axis.

        Parameters
        ----------
        axis : integer
            Axis along which the means are computed. The default is
            to compute the standard deviation of the flattened array.

        dtype : type
            Type to use in computing the means. For arrays of integer type
            the default is float32, for arrays of float types it is the
            same as the array type.

        out : ndarray
            Alternative output array in which to place the result. It must
            have the same shape as the expected output but the type will be
            cast if necessary.

        Returns
        -------
        mean : The return type varies, see above.
            A new array holding the result is returned unless out is
            specified, in which case a reference to out is returned.

        SeeAlso
        -------
        var : variance
        std : standard deviation

        Notes
        -----
        The mean is the sum of the elements along the axis divided by the
        number of elements.
        (   R/   R@   t   meanRs   (   RR   Rr   R#   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRv   _  s    &i    c         C   s%   t  i i |  | | | | ƒ i | ƒ S(   sk  Compute the standard deviation along the specified axis.

        Returns the standard deviation of the array elements, a measure of the
        spread of a distribution. The standard deviation is computed for the
        flattened array by default, otherwise over the specified axis.

        Parameters
        ----------
        axis : integer
            Axis along which the standard deviation is computed. The
            default is to compute the standard deviation of the flattened
            array.
        dtype : type
            Type to use in computing the standard deviation. For arrays of
            integer type the default is float32, for arrays of float types
            it is the same as the array type.
        out : ndarray
            Alternative output array in which to place the result. It must
            have the same shape as the expected output but the type will be
            cast if necessary.
        ddof : {0, integer}
            Means Delta Degrees of Freedom.  The divisor used in calculations
            is N-ddof.

        Returns
        -------
        standard deviation : The return type varies, see above.
            A new array holding the result is returned unless out is
            specified, in which case a reference to out is returned.

        SeeAlso
        -------
        var : variance
        mean : average

        Notes
        -----
        The standard deviation is the square root of the
        average of the squared deviations from the mean, i.e. var =
        sqrt(mean(abs(x - x.mean())**2)).  The computed standard
        deviation is computed by dividing by the number of elements,
        N-ddof. The option ddof defaults to zero, that is, a biased
        estimate. Note that for complex numbers std takes the absolute
        value before squaring, so that the result is always real
        and nonnegative.

        (   R/   R@   t   stdRs   (   RR   Rr   R#   RZ   t   ddof(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRw   ‡  s    0c         C   s%   t  i i |  | | | | ƒ i | ƒ S(   sð  Compute the variance along the specified axis.

        Returns the variance of the array elements, a measure of the spread of
        a distribution.  The variance is computed for the flattened array by
        default, otherwise over the specified axis.

        Parameters
        ----------
        axis : integer
            Axis along which the variance is computed. The default is to
            compute the variance of the flattened array.
        dtype : data-type
            Type to use in computing the variance. For arrays of integer
            type the default is float32, for arrays of float types it is
            the same as the array type.
        out : ndarray
            Alternative output array in which to place the result. It must
            have the same shape as the expected output but the type will be
            cast if necessary.
        ddof : {0, integer}
            Means Delta Degrees of Freedom.  The divisor used in calculations
            is N-ddof.

        Returns
        -------
        variance : depends, see above
            A new array holding the result is returned unless out is
            specified, in which case a reference to out is returned.

        SeeAlso
        -------
        std : standard deviation
        mean : average

        Notes
        -----

        The variance is the average of the squared deviations from the
        mean, i.e.  var = mean(abs(x - x.mean())**2).  The mean is
        computed by dividing by N-ddof, where N is the number of elements.
        The argument ddof defaults to zero; for an unbiased estimate
        supply ddof=1. Note that for complex numbers the absolute value
        is taken before squaring, so that the result is always real
        and nonnegative.
        (   R/   R@   t   varRs   (   RR   Rr   R#   RZ   Rx   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRy   ¹  s    .c         C   s"   t  i i |  | | | ƒ i | ƒ S(   N(   R/   R@   t   prodRs   (   RR   Rr   R#   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyRz   é  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   anyRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR{   ì  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   allRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR|   ï  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   maxRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR}   ò  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   argmaxRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR~   õ  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   minRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR   ø  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   argminRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR€   û  s    c         C   s   t  i i |  | | ƒ i | ƒ S(   N(   R/   R@   t   ptpRs   (   RR   Rr   RZ   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR   þ  s    c         C   sP   |  i  \ } } | | j o d d k l } n d d k l } t | |  ƒ ƒ S(   Niÿÿÿÿ(   R&   (   t   pinv(   R)   t
   numpy.dualR&   R‚   R   (   RR   R1   R/   t   func(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   getI  s
    c         C   s
   |  i  ƒ  S(   N(   Rh   (   RR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   getA	  s    c         C   s   |  i  ƒ  i ƒ  S(   N(   Rh   t   ravel(   RR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   getA1  s    c         C   s
   |  i  ƒ  S(   s=  
        m.T

        Returns the transpose of m.

        Examples
        --------
        >>> m = np.matrix('[1, 2; 3, 4]')
        >>> m
        matrix([[1, 2],
                [3, 4]])
        >>> m.T
        matrix([[1, 3],
                [2, 4]])

        See Also
        --------
        transpose

        (   Rq   (   RR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   getT  s    c         C   s8   t  |  i i t i ƒ o |  i ƒ  i ƒ  S|  i ƒ  Sd  S(   N(   t
   issubclassR#   R*   R/   t   complexfloatingRq   t	   conjugate(   RR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   getH&  s    t   docRq   s
   base arrays   1-d base arrays   hermitian (conjugate) transposet   inverseN(*   t   __name__t
   __module__t   __doc__t   __array_priority__R>   RG   RI   RW   RX   Ra   R\   Rb   Rc   Rd   Re   Ro   Rp   Rs   Rt   Ru   Rv   Rw   Ry   Rz   R{   R|   R}   R~   R   R€   R   R…   R†   Rˆ   R‰   R   t   propertyt   Tt   At   A1t   Ht   I(    (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR    š   sJ   %.									
			(20					c      
   C   s  |  i  d ƒ } g  } xî | D]æ } | i  d ƒ } g  } x! | D] } | i | i  ƒ  ƒ q> W| } g  }	 x | D]w }
 |
 i ƒ  }
 y | |
 } WnG t j
 o; y | |
 } WqØ t j
 o t d |
 f ‚ qØ Xn X|	 i | ƒ qn W| i t |	 d d ƒƒ q Wt | d d ƒS(   NR   R   s   %s not foundRr   iÿÿÿÿi    (   R   R   t   stript   KeyErrorR   R   (   RB   t   gdictt   ldictR   t   rowtupR   R   R   RU   t   coltupR   t   thismat(    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   _from_string2  s0       c         C   s  t  |  t ƒ oU | d j o% t i ƒ  i } | i } | i } n | } | } t t	 |  | | ƒ ƒ St  |  t
 t f ƒ oq g  } xQ |  D]I } t  | t i ƒ o t t |  d d ƒƒ S| i t | d d ƒƒ qˆ Wt t | d d ƒƒ St  |  t i ƒ o t |  ƒ Sd S(   s  
    Build a matrix object from a string, nested sequence, or array.

    Parameters
    ----------
    obj : string, sequence or array
        Input data.  Variables names in the current scope may
        be referenced, even if `obj` is a string.

    Returns
    -------
    out : matrix
        Returns a matrix object, which is a specialized 2-D array.

    See Also
    --------
    matrix

    Examples
    --------
    >>> A = np.mat('1 1; 1 1')
    >>> B = np.mat('2 2; 2 2')
    >>> C = np.mat('3 4; 5 6')
    >>> D = np.mat('7 8; 9 0')

    All the following expressions construct the same block matrix:

    >>> np.bmat([[A, B], [C, D]])
    matrix([[1, 1, 2, 2],
            [1, 1, 2, 2],
            [3, 4, 7, 8],
            [5, 6, 9, 0]])
    >>> np.bmat(np.r_[np.c_[A, B], np.c_[C, D]])
    matrix([[1, 1, 2, 2],
            [1, 1, 2, 2],
            [3, 4, 7, 8],
            [5, 6, 9, 0]])
    >>> np.bmat('A,B; C,D')
    matrix([[1, 1, 2, 2],
            [1, 1, 2, 2],
            [3, 4, 7, 8],
            [5, 6, 9, 0]])

    Rr   iÿÿÿÿi    N(   R=   RB   R>   t   syst	   _getframet   f_backt	   f_globalst   f_localsR    R¡   RQ   R]   R/   R@   R   R   (   RS   R   Rœ   t   framet	   glob_dictt   loc_dictt   arr_rowsR   (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyR   K  s$    -	 (   t   __all__R¢   t   numericR/   R   R   R   R   t   numerictypesR   R>   R   R.   R9   t   chrRk   t	   _numcharsR   R   R   R"   R   R:   R@   R    R¡   R   R   (    (    (    sD   P:\graphics\tools\Python26\lib\site-packages\numpy\core\defmatrix.pyt   <module>   s4   "  		 	Oÿ ™	E