ó
~9­\c           @  s]  d  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 l
 m Z d d l m Z m Z m Z m Z m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l  m! Z" d d l# m$ Z$ d d l% m& Z& d e' f d „  ƒ  YZ( d e) e( f d „  ƒ  YZ* d e* f d „  ƒ  YZ+ d e, f d „  ƒ  YZ- d e- f d „  ƒ  YZ. d e- f d „  ƒ  YZ/ d e- f d „  ƒ  YZ0 d  e- f d! „  ƒ  YZ1 d" e- f d# „  ƒ  YZ2 d$ e2 e1 e0 e/ e. f d% „  ƒ  YZ3 d& e, f d' „  ƒ  YZ4 d( e, f d) „  ƒ  YZ5 d* „  Z6 e7 d+ „ Z8 d, „  Z9 d- S(.   sy   
Basic methods common to all matrices to be used
when creating more advanced matrices (e.g., matrices over rings,
etc.).
iÿÿÿÿ(   t   divisiont   print_function(   t   defaultdict(   t
   isfunction(   t   refine(   t   Atom(   t   Iterablet   as_intt   is_sequencet   ranget   reduce(   t   call_highest_priority(   t   Expr(   t	   count_ops(   t   S(   t   Symbol(   t   sympify(   t   Abs(   t   simplify(   t   SymPyDeprecationWarning(   t   flattent   MatrixErrorc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR      s   t
   ShapeErrorc           B  s   e  Z d  Z RS(   s   Wrong matrix shape(   R   R   t   __doc__(    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR       s   t   NonSquareMatrixErrorc           B  s   e  Z RS(    (   R   R   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR   %   s   t   MatrixRequiredc           B  sP   e  Z d  Z d Z d Z d Z d Z e d „  ƒ Z	 d „  Z
 d „  Z d „  Z RS(   s_   All subclasses of matrix objects must implement the
    required matrix properties listed here.c         O  s   t  d ƒ ‚ d S(   s†   `_new` must, at minimum, be callable as
        `_new(rows, cols, mat) where mat is a flat list of the
        elements of the matrix.s   Subclasses must implement this.N(   t   NotImplementedError(   t   clst   argst   kwargs(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _new1   s    c         C  s   t  d ƒ ‚ d  S(   Ns   Subclasses must implement this.(   R   (   t   selft   other(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __eq__8   s    c         C  s   t  d ƒ ‚ d S(   s  Implementations of __getitem__ should accept ints, in which
        case the matrix is indexed as a flat list, tuples (i,j) in which
        case the (i,j) entry is returned, slices, or mixed tuples (a,b)
        where a and b are any combintion of slices and integers.s   Subclasses must implement this.N(   R   (   R!   t   key(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __getitem__;   s    c         C  s   t  d ƒ ‚ d S(   s*   The total number of entries in the matrix.s   Subclasses must implement this.N(   R   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __len__B   s    N(   R   R   R   t   Nonet   rowst   colst   shapet	   _simplifyt   classmethodR    R#   R%   R&   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR   )   s   		t   MatrixShapingc           B  s
  e  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 „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z e d „  ƒ Z RS(   s;   Provides basic matrix shaping and extracting of submatricesc           s/   ‡  ‡ f d †  } ˆ j  ˆ j ˆ j d | ƒ S(   Nc           s,   | ˆ  k  r ˆ |  | f Sˆ |  | d f S(   Ni   (    (   t   it   j(   t   colR!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   entryK   s    i   (   R    R(   R)   (   R!   R0   R1   (    (   R0   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_col_delJ   s    c           sG   ˆ j  } ‡ ‡ ‡ f d †  ‰  ˆ j ˆ j ˆ j  ˆ j  ‡  f d †  ƒ S(   Nc           sd   | ˆ k  r ˆ |  | f Sˆ | k o8 ˆ ˆ  j  k  n rO ˆ  |  | ˆ f Sˆ |  | ˆ  j  f S(   N(   R)   (   R.   R/   (   R"   t   posR!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   R   s
    #c           s   ˆ  |  | ƒ S(   N(    (   R.   R/   (   R1   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   <lambda>Z   t    (   R)   R    R(   (   R!   R3   R"   R)   (    (   R1   R"   R3   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_col_insertO   s    	c           sP   ˆ j  ‰ ‡ ‡ ‡ f d †  ‰  t ˆ ˆ ƒ j ˆ j  ˆ j  ˆ j ‡  f d †  ƒ S(   Nc           s,   |  ˆ k  r ˆ |  | f Sˆ  |  ˆ | f S(   N(    (   R.   R/   (   R"   R(   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   _   s    c           s   ˆ  |  | ƒ S(   N(    (   R.   R/   (   R1   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   e   R5   (   R(   t   classofR    R)   (   R!   R"   (    (   R1   R"   R(   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_col_join\   s    	"c           sc   t  |  ƒ ‰ |  j ‰  ‡  ‡ f d †  | Dƒ } |  j t | ƒ t ˆ ƒ t  ‡ f d †  | Dƒ ƒ ƒ S(   Nc         3  s*   |  ]  } ˆ D] } | ˆ  | Vq q d  S(   N(    (   t   .0R.   R/   (   R)   t   colsList(    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>j   s    c         3  s   |  ] } ˆ  | Vq d  S(   N(    (   R9   R.   (   t   mat(    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>l   s    (   t   listR)   R    t   len(   R!   t   rowsListR:   t   indices(    (   R)   R:   R;   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_extractg   s
    	c           s&   g  ‰ ‡  ‡ f d †  ‰  ˆ  |  ƒ ˆ S(   Nc           s2  d } x%| |  j  d k r-| d k rW |  d | d  … f } |  | d  … d f } n8 |  d  | … | d  … f } |  | d  … d  | … f } t | ƒ s§ t | ƒ r· | d 7} q	 q	 ˆ j |  d  | … d  | … f ƒ |  j  |  d  | … d  | … f j  k rd  Sˆ  |  | d  … | d  … f ƒ d  Sq	 Wd  S(   Ni   i    (   R*   t   anyt   append(   t   MR.   t   to_the_rightt   to_the_bottom(   t   recurse_sub_blockst
   sub_blocks(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRF   q   s    
#( (    (   R!   (    (   RF   RG   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_get_diag_blocksn   s    
c           s/   ‡  ‡ f d †  } ˆ j  ˆ j d ˆ j | ƒ S(   Nc           s,   |  ˆ  k  r ˆ |  | f Sˆ |  d | f S(   Ni   (    (   R.   R/   (   t   rowR!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   ‰   s    i   (   R    R(   R)   (   R!   RI   R1   (    (   RI   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_row_delˆ   s    c         C  sL   t  |  ƒ } | |  j } t  | ƒ | | | +|  j |  j | j |  j | ƒ S(   N(   R<   R)   R    R(   (   R!   R3   R"   t   entriest
   insert_pos(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_row_insert   s    c           sP   ˆ j  ‰  ‡  ‡ ‡ f d †  ‰ t ˆ ˆ ƒ j ˆ j ˆ j  ˆ j  ‡ f d †  ƒ S(   Nc           s,   | ˆ  k  r ˆ |  | f Sˆ |  | ˆ  f S(   N(    (   R.   R/   (   R)   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   –   s    c           s   ˆ  |  | ƒ S(   N(    (   R.   R/   (   R1   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   œ   R5   (   R)   R7   R    R(   (   R!   R"   (    (   R)   R1   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_row_join“   s    	"c         C  s6   g  t  |  j ƒ D]" } t |  | d  d  … f ƒ ^ q S(   N(   R	   R(   R<   (   R!   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_tolistž   s    c           s4   ˆ j  ‰  ‡  ‡ f d †  } ˆ j t ˆ ƒ d | ƒ S(   Nc           s&   |  ˆ  } |  | ˆ  } ˆ | | f S(   N(    (   t   nt   _R/   R.   (   R(   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   ¤   s    
i   (   R(   R    R=   (   R!   R1   (    (   R(   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt	   _eval_vec¡   s    	c         C  s`   | d k  r | |  j  7} n  d | k o6 |  j  k  n sS t d j | ƒ ƒ ‚ n  |  j | ƒ S(   s   Delete the specified column.i    s   Column {} out of range.(   R)   t
   ValueErrort   formatR2   (   R!   R0   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   col_del¬   s
    c         C  sŸ   |  s t  |  ƒ | ƒ St | ƒ } | d k  r> |  j | } n  | d k  rS d } n | |  j k rn |  j } n  |  j | j k r t d ƒ ‚ n  |  j | | ƒ S(   sy  Insert one or more columns at the given column position.

        Examples
        ========

        >>> from sympy import zeros, ones
        >>> M = zeros(3)
        >>> V = ones(3, 1)
        >>> M.col_insert(1, V)
        Matrix([
        [0, 1, 0, 0],
        [0, 1, 0, 0],
        [0, 1, 0, 0]])

        See Also
        ========

        col
        row_insert
        i    s5   `self` and `other` must have the same number of rows.(   t   typeR   R)   R(   R   R6   (   R!   R3   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt
   col_insert´   s    	c         C  sn   |  j  d k r@ |  j | j k r@ |  j d | j g  ƒ j | ƒ S|  j | j k ra t d ƒ ‚ n  |  j | ƒ S(   s†  Concatenates two matrices along self's last and other's first row.

        Examples
        ========

        >>> from sympy import zeros, ones
        >>> M = zeros(3)
        >>> V = ones(1, 3)
        >>> M.col_join(V)
        Matrix([
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [1, 1, 1]])

        See Also
        ========

        col
        row_join
        i    s8   `self` and `other` must have the same number of columns.(   R(   R)   R    t   col_joinR   R8   (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRX   Ü   s    !c         C  s   |  d d … | f S(   s4  Elementary column selector.

        Examples
        ========

        >>> from sympy import eye
        >>> eye(2).col(0)
        Matrix([
        [1],
        [0]])

        See Also
        ========

        row
        col_op
        col_swap
        col_del
        col_join
        col_insert
        N(    (   R!   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR0   û   s    c         C  s  t  | ƒ s t  | ƒ r) t d ƒ ‚ n  | rs t d „  | Dƒ ƒ rs g  t | ƒ D] \ } } | rR | ^ qR } n  | r½ t d „  | Dƒ ƒ r½ g  t | ƒ D] \ } } | rœ | ^ qœ } n  g  | D] } t | |  j ƒ ^ qÄ } g  | D] } t | |  j ƒ ^ qé } |  j | | ƒ S(   s  Return a submatrix by specifying a list of rows and columns.
        Negative indices can be given. All indices must be in the range
        -n <= i < n where n is the number of rows or columns.

        Examples
        ========

        >>> from sympy import Matrix
        >>> m = Matrix(4, 3, range(12))
        >>> m
        Matrix([
        [0,  1,  2],
        [3,  4,  5],
        [6,  7,  8],
        [9, 10, 11]])
        >>> m.extract([0, 1, 3], [0, 1])
        Matrix([
        [0,  1],
        [3,  4],
        [9, 10]])

        Rows or columns can be repeated:

        >>> m.extract([0, 0, 1], [-1])
        Matrix([
        [2],
        [2],
        [5]])

        Every other row can be taken by using range to provide the indices:

        >>> m.extract(range(0, m.rows, 2), [-1])
        Matrix([
        [2],
        [8]])

        RowsList or colsList can also be a list of booleans, in which case
        the rows or columns corresponding to the True values will be selected:

        >>> m.extract([0, 1, 2, 3], [True, False, True])
        Matrix([
        [0,  2],
        [3,  5],
        [6,  8],
        [9, 11]])
        s&   rowsList and colsList must be iterablec         s  s   |  ] } t  | t ƒ Vq d  S(   N(   t
   isinstancet   bool(   R9   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>F  s    c         s  s   |  ] } t  | t ƒ Vq d  S(   N(   RY   RZ   (   R9   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>H  s    (   R   t	   TypeErrort   allt	   enumeratet   a2idxR(   R)   R@   (   R!   R>   R:   t   indext   itemt   k(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   extract  s    0..%%c         C  s
   |  j  ƒ  S(   sz  Obtains the square sub-matrices on the main diagonal of a square matrix.

        Useful for inverting symbolic matrices or solving systems of
        linear equations which may be decoupled by having a block diagonal
        structure.

        Examples
        ========

        >>> from sympy import Matrix
        >>> from sympy.abc import x, y, z
        >>> A = Matrix([[1, 3, 0, 0], [y, z*z, 0, 0], [0, 0, x, 0], [0, 0, 0, 0]])
        >>> a1, a2, a3 = A.get_diag_blocks()
        >>> a1
        Matrix([
        [1,    3],
        [y, z**2]])
        >>> a2
        Matrix([[x]])
        >>> a3
        Matrix([[0]])

        (   RH   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   get_diag_blocksQ  s    c         G  s<   t  | ƒ d k r |  j ƒ  St | d ƒ } t | j | ƒ S(   s1  Return a matrix formed by joining args horizontally (i.e.
        by repeated application of row_join).

        Examples
        ========

        >>> from sympy.matrices import Matrix, eye
        >>> Matrix.hstack(eye(2), 2*eye(2))
        Matrix([
        [1, 0, 2, 0],
        [0, 1, 0, 2]])
        i    (   R=   R    RV   R
   t   row_join(   R   R   t   kls(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   hstackk  s    
c           sR   ˆ j  ˆ j | ˆ  k r3 t d | ˆ  f ƒ ‚ n  ˆ j | ˆ  ‡  ‡ f d †  ƒ S(   s§  Reshape the matrix. Total number of elements must remain the same.

        Examples
        ========

        >>> from sympy import Matrix
        >>> m = Matrix(2, 3, lambda i, j: 1)
        >>> m
        Matrix([
        [1, 1, 1],
        [1, 1, 1]])
        >>> m.reshape(1, 6)
        Matrix([[1, 1, 1, 1, 1, 1]])
        >>> m.reshape(3, 2)
        Matrix([
        [1, 1],
        [1, 1],
        [1, 1]])

        s    Invalid reshape parameters %d %dc           s   ˆ |  ˆ  | S(   N(    (   R.   R/   (   R)   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   –  R5   (   R(   R)   RS   R    (   R!   R(   R)   (    (   R)   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   reshape  s    c         C  s`   | d k  r | |  j  7} n  d | k o6 |  j  k  n sS t d j | ƒ ƒ ‚ n  |  j | ƒ S(   s   Delete the specified row.i    s   Row {} out of range.(   R(   RS   RT   RJ   (   R!   RI   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   row_del˜  s
    c         C  sœ   |  s |  j  | ƒ St | ƒ } | d k  r; |  j | } n  | d k  rP d } n | |  j k rk |  j } n  |  j | j k rŒ t d ƒ ‚ n  |  j | | ƒ S(   s}  Insert one or more rows at the given row position.

        Examples
        ========

        >>> from sympy import zeros, ones
        >>> M = zeros(3)
        >>> V = ones(1, 3)
        >>> M.row_insert(1, V)
        Matrix([
        [0, 0, 0],
        [1, 1, 1],
        [0, 0, 0],
        [0, 0, 0]])

        See Also
        ========

        row
        col_insert
        i    s8   `self` and `other` must have the same number of columns.(   R    R   R(   R)   R   RM   (   R!   R3   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt
   row_insert¡  s    	c         C  sn   |  j  d k r@ |  j | j k r@ |  j | j d g  ƒ j | ƒ S|  j | j k ra t d ƒ ‚ n  |  j | ƒ S(   s|  Concatenates two matrices along self's last and rhs's first column

        Examples
        ========

        >>> from sympy import zeros, ones
        >>> M = zeros(3)
        >>> V = ones(3, 1)
        >>> M.row_join(V)
        Matrix([
        [0, 0, 0, 1],
        [0, 0, 0, 1],
        [0, 0, 0, 1]])

        See Also
        ========

        row
        col_join
        i    s3   `self` and `rhs` must have the same number of rows.(   R)   R(   R    Rd   R   RN   (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRd   Ê  s    !c         C  s   |  | d d … f S(   s  Elementary row selector.

        Examples
        ========

        >>> from sympy import eye
        >>> eye(2).row(0)
        Matrix([[1, 0]])

        See Also
        ========

        col
        row_op
        row_swap
        row_del
        row_join
        row_insert
        N(    (   R!   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRI   è  s    c         C  s   |  j  |  j f S(   s  The shape (dimensions) of the matrix as the 2-tuple (rows, cols).

        Examples
        ========

        >>> from sympy.matrices import zeros
        >>> M = zeros(2, 3)
        >>> M.shape
        (2, 3)
        >>> M.rows
        2
        >>> M.cols
        3
        (   R(   R)   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR*   þ  s    c         C  s@   |  j  s g  S|  j s6 g  t |  j  ƒ D] } g  ^ q& S|  j ƒ  S(   s   Return the Matrix as a nested Python list.

        Examples
        ========

        >>> from sympy import Matrix, ones
        >>> m = Matrix(3, 3, range(9))
        >>> m
        Matrix([
        [0, 1, 2],
        [3, 4, 5],
        [6, 7, 8]])
        >>> m.tolist()
        [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
        >>> ones(3, 0).tolist()
        [[], [], []]

        When there are no rows then it will not be possible to tell how
        many columns were in the original matrix:

        >>> ones(0, 3).tolist()
        []

        (   R(   R)   R	   RO   (   R!   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   tolist  s
    		 c         C  s
   |  j  ƒ  S(   sŒ  Return the Matrix converted into a one column matrix by stacking columns

        Examples
        ========

        >>> from sympy import Matrix
        >>> m=Matrix([[1, 3], [2, 4]])
        >>> m
        Matrix([
        [1, 3],
        [2, 4]])
        >>> m.vec()
        Matrix([
        [1],
        [2],
        [3],
        [4]])

        See Also
        ========

        vech
        (   RR   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   vec/  s    c         G  s<   t  | ƒ d k r |  j ƒ  St | d ƒ } t | j | ƒ S(   sC  Return a matrix formed by joining args vertically (i.e.
        by repeated application of col_join).

        Examples
        ========

        >>> from sympy.matrices import Matrix, eye
        >>> Matrix.vstack(eye(2), 2*eye(2))
        Matrix([
        [1, 0],
        [0, 1],
        [2, 0],
        [0, 2]])
        i    (   R=   R    RV   R
   RX   (   R   R   Re   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   vstackI  s    
(   R   R   R   R2   R6   R8   R@   RH   RJ   RM   RN   RO   RR   RU   RW   RX   R0   Rb   Rc   R,   Rf   Rg   Rh   Ri   Rd   RI   t   propertyR*   Rj   Rk   Rl   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR-   G   s6   												(			>					)				t   MatrixSpecialc           B  s¶   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d d „ ƒ Z e d d d	 „ ƒ Z e d d
 „ ƒ Z e d d „ ƒ Z RS(   s    Construction of special matricesc           s"   ‡  f d †  } |  j  | | | ƒ S(   sU   diag_dict is a defaultdict containing
        all the entries of the diagonal matrix.c           s   ˆ  |  | f S(   N(    (   R.   R/   (   t	   diag_dict(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   g  s    (   R    (   R   R(   R)   Ro   R1   (    (   Ro   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt
   _eval_diagc  s    c         C  s   d „  } |  j  | | | ƒ S(   Nc         S  s   |  | k r t  j St  j S(   N(   R   t   Onet   Zero(   R.   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   m  s    (   R    (   R   R(   R)   R1   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt	   _eval_eyek  s    	t   upperc           s@   | d k r ‡  f d †  } n ‡  f d †  } |  j  | | | ƒ S(   Nt   lowerc           s.   |  | k r ˆ  S| d |  k r' t  j St  j S(   Ni   (   R   Rq   Rr   (   R.   R/   (   t
   eigenvalue(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   t  s
    c           s.   |  | k r ˆ  S|  d | k r' t  j St  j S(   Ni   (   R   Rq   Rr   (   R.   R/   (   Rv   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   {  s
    (   R    (   R   R(   R)   Rv   t   bandR1   (    (   Rv   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_jordan_blockq  s    c         C  s   d „  } |  j  | | | ƒ S(   Nc         S  s   t  j S(   N(   R   Rq   (   R.   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   …  s    (   R    (   R   R(   R)   R1   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt
   _eval_onesƒ  s    	c         C  s   d „  } |  j  | | | ƒ S(   Nc         S  s   t  j S(   N(   R   Rr   (   R.   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   ‹  s    (   R    (   R   R(   R)   R1   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_zeros‰  s    	c           sÛ  | j  d |  ƒ } t | ƒ d k rX t | d ƒ rX t | d d t ƒ rX | d } n  d „  ‰  t ‡  f d †  | Dƒ ƒ } t ‡  f d †  | Dƒ ƒ } | j  d | ƒ } | j  d	 | ƒ } | | k  sÕ | | k  rö t d
 j | | | | ƒ ƒ ‚ n  t d „  ƒ } d \ }	 }
 x´ | D]¬ } t	 | d ƒ r xS t
 | j ƒ D]B } x9 t
 | j ƒ D]( } | | | f | | |	 | |
 f <qSWq=W|	 | j 7}	 |
 | j 7}
 q| | |	 |
 f <|	 d 7}	 |
 d 7}
 qW| j | | | ƒ S(   sÆ  Returns a matrix with the specified diagonal.
        If matrices are passed, a block-diagonal matrix
        is created.

        kwargs
        ======

        rows : rows of the resulting matrix; computed if
               not given.

        cols : columns of the resulting matrix; computed if
               not given.

        cls : class for the resulting matrix

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> Matrix.diag(1, 2, 3)
        Matrix([
        [1, 0, 0],
        [0, 2, 0],
        [0, 0, 3]])
        >>> Matrix.diag([1, 2, 3])
        Matrix([
        [1, 0, 0],
        [0, 2, 0],
        [0, 0, 3]])

        The diagonal elements can be matrices; diagonal filling will
        continue on the diagonal from the last element of the matrix:

        >>> from sympy.abc import x, y, z
        >>> a = Matrix([x, y, z])
        >>> b = Matrix([[1, 2], [3, 4]])
        >>> c = Matrix([[5, 6]])
        >>> Matrix.diag(a, 7, b, c)
        Matrix([
        [x, 0, 0, 0, 0, 0],
        [y, 0, 0, 0, 0, 0],
        [z, 0, 0, 0, 0, 0],
        [0, 7, 0, 0, 0, 0],
        [0, 0, 1, 2, 0, 0],
        [0, 0, 3, 4, 0, 0],
        [0, 0, 0, 0, 5, 6]])

        A given band off the diagonal can be made by padding with a
        vertical or horizontal "kerning" vector:

        >>> hpad = Matrix(0, 2, [])
        >>> vpad = Matrix(2, 0, [])
        >>> Matrix.diag(vpad, 1, 2, 3, hpad) + Matrix.diag(hpad, 4, 5, 6, vpad)
        Matrix([
        [0, 0, 4, 0, 0],
        [0, 0, 0, 5, 0],
        [1, 0, 0, 0, 6],
        [0, 2, 0, 0, 0],
        [0, 0, 3, 0, 0]])

        The type of the resulting matrix can be affected with the ``cls``
        keyword.

        >>> type(Matrix.diag(1))
        <class 'sympy.matrices.dense.MutableDenseMatrix'>
        >>> from sympy.matrices import ImmutableMatrix
        >>> type(Matrix.diag(1, cls=ImmutableMatrix))
        <class 'sympy.matrices.immutable.ImmutableDenseMatrix'>
        R   i   i    t	   is_Matrixc         S  s#   t  |  d ƒ r |  j |  j f Sd S(   s&   Compute the size of the diagonal blockR(   i   (   i   i   (   t   hasattrR(   R)   (   t   m(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   sizeÜ  s    c         3  s   |  ] } ˆ  | ƒ d  Vq d S(   i    N(    (   R9   R}   (   R~   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>á  s    c         3  s   |  ] } ˆ  | ƒ d  Vq d S(   i   N(    (   R9   R}   (   R~   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>â  s    R(   R)   sO   A {} x {} diagnal matrix cannot accommodate adiagonal of size at least {} x {}.c           S  s   t  j S(   N(   R   Rr   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ë  R5   (   i    i    (   t   getR=   R   t   getattrt   Falset   sumRS   RT   R   R|   R	   R(   R)   Rp   (   Re   R   R   t   klasst	   diag_rowst	   diag_colsR(   R)   t   diag_entriest   row_post   col_posR}   R.   R/   (    (   R~   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   diag  s2    H9		*
c         K  sP   | d k r | } n  | j d |  ƒ } t | ƒ t | ƒ } } | j | | ƒ S(   sã   Returns an identity matrix.

        Args
        ====

        rows : rows of the matrix
        cols : cols of the matrix (if None, cols=rows)

        kwargs
        ======
        cls : class of the returned matrix
        R   N(   R'   R   R   Rs   (   Re   R(   R)   R   Rƒ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   eyeü  s
    	c   	   	   K  sÀ  d | k s d | k r@ t  d d d d d d d	 d
 ƒ j ƒ  n  | j d |  ƒ } | j d d ƒ } | j d d ƒ } | j d d ƒ } | j d d ƒ } | d k rÁ | d k rÁ t d ƒ ‚ nN | | k rú d | | f k rú t d j | | ƒ ƒ ‚ n | d k	 r| } n  | | | f d k r3t d ƒ ‚ n  | d k	 rO| | } } nB | d k	 rp| d k rp| } n! | d k	 r‘| d k r‘| } n  t | ƒ t | ƒ } } | j | | | | ƒ S(   s   Returns a Jordan block

        Parameters
        ==========

        size : Integer, optional
            Specifies the shape of the Jordan block matrix.

        eigenvalue : Number or Symbol
            Specifies the value for the main diagonal of the matrix.

            .. note::
                The keyword ``eigenval`` is also specified as an alias
                of this keyword, but it is not recommended to use.

                We may deprecate the alias in later release.

        band : 'upper' or 'lower', optional
            Specifies the position of the off-diagonal to put `1` s on.

        cls : Matrix, optional
            Specifies the matrix class of the output form.

            If it is not specified, the class type where the method is
            being executed on will be returned.

        rows, cols : Integer, optional
            Specifies the shape of the Jordan block matrix. See Notes
            section for the details of how these key works.

            .. note::
                This feature will be deprecated in the future.


        Returns
        =======

        Matrix
            A Jordan block matrix.

        Raises
        ======

        ValueError
            If insufficient arguments are given for matrix size
            specification, or no eigenvalue is given.

        Examples
        ========

        Creating a default Jordan block:

        >>> from sympy import Matrix
        >>> from sympy.abc import x
        >>> Matrix.jordan_block(4, x)
        Matrix([
        [x, 1, 0, 0],
        [0, x, 1, 0],
        [0, 0, x, 1],
        [0, 0, 0, x]])

        Creating an alternative Jordan block matrix where `1` is on
        lower off-diagonal:

        >>> Matrix.jordan_block(4, x, band='lower')
        Matrix([
        [x, 0, 0, 0],
        [1, x, 0, 0],
        [0, 1, x, 0],
        [0, 0, 1, x]])

        Creating a Jordan block with keyword arguments

        >>> Matrix.jordan_block(size=4, eigenvalue=x)
        Matrix([
        [x, 1, 0, 0],
        [0, x, 1, 0],
        [0, 0, x, 1],
        [0, 0, 0, x]])

        Notes
        =====

        .. note::
            This feature will be deprecated in the future.

        The keyword arguments ``size``, ``rows``, ``cols`` relates to
        the Jordan block size specifications.

        If you want to create a square Jordan block, specify either
        one of the three arguments.

        If you want to create a rectangular Jordan block, specify
        ``rows`` and ``cols`` individually.

        +--------------------------------+---------------------+
        |        Arguments Given         |     Matrix Shape    |
        +----------+----------+----------+----------+----------+
        |   size   |   rows   |   cols   |   rows   |   cols   |
        +==========+==========+==========+==========+==========+
        |   size   |         Any         |   size   |   size   |
        +----------+----------+----------+----------+----------+
        |          |        None         |     ValueError      |
        |          +----------+----------+----------+----------+
        |   None   |   rows   |   None   |   rows   |   rows   |
        |          +----------+----------+----------+----------+
        |          |   None   |   cols   |   cols   |   cols   |
        +          +----------+----------+----------+----------+
        |          |   rows   |   cols   |   rows   |   cols   |
        +----------+----------+----------+----------+----------+

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/Jordan_matrix
        R(   R)   t   features"   Keyword arguments 'rows' or 'cols't   issueiæ>  t
   useinsteads(   a more generic banded matrix constructort   deprecated_since_versions   1.4R   Rw   Rt   t   eigenvals   Must supply an eigenvalues=   Inconsistent values are given: 'eigenval'={}, 'eigenvalue'={}s   Must supply a matrix sizeN(   NNN(	   R   t   warnt   popR'   R   RS   RT   R   Rx   (	   Re   R~   Rv   R   Rƒ   Rw   R(   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   jordan_block  s:    v			c         K  sP   | d k r | } n  | j d |  ƒ } t | ƒ t | ƒ } } | j | | ƒ S(   sá   Returns a matrix of ones.

        Args
        ====

        rows : rows of the matrix
        cols : cols of the matrix (if None, cols=rows)

        kwargs
        ======
        cls : class of the returned matrix
        R   N(   R'   R   R   Ry   (   Re   R(   R)   R   Rƒ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   ones­  s
    	c         K  sP   | d k r | } n  | j d |  ƒ } t | ƒ t | ƒ } } | j | | ƒ S(   sâ   Returns a matrix of zeros.

        Args
        ====

        rows : rows of the matrix
        cols : cols of the matrix (if None, cols=rows)

        kwargs
        ======
        cls : class of the returned matrix
        R   N(   R'   R   R   Rz   (   Re   R(   R)   R   Rƒ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   zerosÂ  s
    	N(   R   R   R   R,   Rp   Rs   Rx   Ry   Rz   R‰   R'   RŠ   R’   R“   R”   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRn   `  s    m›t   MatrixPropertiesc           B  s[  e  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 „  Z d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z e d „ Z d „  Z e e d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z e d „ Z e d „  ƒ Z e d „  ƒ Z  e d „  ƒ Z! d „  Z" RS(   s&   Provides basic properties of a matrix.c         G  s4   t  ƒ  } x$ |  D] } | j | j | Œ  ƒ q W| S(   N(   t   sett   updatet   atoms(   R!   t   typest   resultR.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_atomsÛ  s    	c         C  s   t  ƒ  j d „  |  Dƒ Œ  S(   Nc         s  s   |  ] } | j  Vq d  S(   N(   t   free_symbols(   R9   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>â  s    (   R–   t   union(   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_free_symbolsá  s    c           s   t  ‡  f d †  |  Dƒ ƒ S(   Nc         3  s   |  ] } | j  ˆ  Œ  Vq d  S(   N(   t   has(   R9   t   a(   t   patterns(    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>å  s    (   RA   (   R!   R¡   (    (   R¡   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt	   _eval_hasä  s    c           s0   t  ‡  ‡ f d †  t ˆ  j ƒ Dƒ ƒ s, t St S(   Nc         3  sL   |  ]B } t  ˆ  j ƒ D], } ˆ ˆ  | | f ˆ  | | f ƒ j Vq q d  S(   N(   R	   R)   t   is_zero(   R9   R.   R/   (   R!   t   simpfunc(    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>è  s    (   R\   R	   R(   R   t   True(   R!   R¤   (    (   R!   R¤   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_anti_symmetricç  s    (c         C  sX   xQ t  |  j ƒ D]@ } x7 t  |  j ƒ D]& } | | k r& |  | | f r& t Sq& Wq Wt S(   N(   R	   R(   R)   R   R¥   (   R!   R.   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_diagonalì  s
    c           s.   ˆ  j  ˆ  j ˆ  j ‡  ‡ f d †  ƒ } | j S(   Nc           s(   ˆ ˆ  |  | f ˆ  | |  f j  ƒ  ƒ S(   N(   t	   conjugate(   R.   R/   (   R!   R¤   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ÷  R5   (   R    R(   R)   R£   (   R!   R¤   R;   (    (   R!   R¤   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_matrix_hermitianö  s    'c           s/   d „  ‰  t  ‡  ‡ f d †  t ˆ j ƒ Dƒ ƒ S(   Nc         S  s   |  | k r d Sd S(   Ni   i    (    (   R.   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   diracû  s    c         3  sD   |  ]: } t  ˆ j ƒ D]$ } ˆ | | f ˆ  | | ƒ k Vq q d  S(   N(   R	   R)   (   R9   R.   R/   (   Rª   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>   s    (   R\   R	   R(   (   R!   (    (   Rª   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_Identityú  s    	c           s#   t  ‡  f d †  t ˆ  j ƒ Dƒ ƒ S(   Nc         3  s?   |  ]5 } t  | d  ˆ  j ƒ D] } ˆ  | | f j Vq q d S(   i   N(   R	   R)   R£   (   R9   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>  s   (   R\   R	   R(   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_lower_hessenberg  s    c           s#   t  ‡  f d †  t ˆ  j ƒ Dƒ ƒ S(   Nc         3  s?   |  ]5 } t  | d  ˆ  j ƒ D] } ˆ  | | f j Vq q d S(   i   N(   R	   R)   R£   (   R9   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>	  s   (   R\   R	   R(   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_lower  s    c         C  s   |  j  t ƒ S(   N(   RŸ   R   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_symbolic  s    c           s.   ˆ  j  ˆ  j ˆ  j ‡  ‡ f d †  ƒ } | j S(   Nc           s"   ˆ ˆ  |  | f ˆ  | |  f ƒ S(   N(    (   R.   R/   (   R!   R¤   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4     R5   (   R    R(   R)   R£   (   R!   R¤   R;   (    (   R!   R¤   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_symmetric  s    'c         C  s8   t  d „  |  Dƒ ƒ r t St  d „  |  Dƒ ƒ r4 d  St S(   Nc         s  s   |  ] } | j  t k Vq d  S(   N(   R£   R   (   R9   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>  s    c         s  s   |  ] } | j  d  k Vq d  S(   N(   R£   R'   (   R9   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>  s    (   RA   R   R'   R¥   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_zero  s
    c           s&   t  ‡  f d †  t d ˆ  j ƒ Dƒ ƒ S(   Nc         3  sE   |  ]; } t  t ˆ  j | d  ƒ ƒ D] } ˆ  | | f j Vq# q d S(   i   N(   R	   t   minR)   R£   (   R9   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>  s   i   (   R\   R	   R(   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_is_upper_hessenberg  s    c         C  s    g  |  D] } | j  s | ^ q S(   N(   R£   (   R!   R.   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_values   s    c         G  s5   t  d „  | Dƒ ƒ } | s( t f } n  |  j | Œ  S(   s  Returns the atoms that form the current object.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy.matrices import Matrix
        >>> Matrix([[x]])
        Matrix([[x]])
        >>> _.atoms()
        {x}
        c         s  s0   |  ]& } t  | t ƒ r | n	 t | ƒ Vq d  S(   N(   RY   RV   (   R9   t   t(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>1  s    (   t   tupleR   R›   (   R!   R™   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR˜   #  s    c         C  s
   |  j  ƒ  S(   sâ   Returns the free symbols within the matrix.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy.matrices import Matrix
        >>> Matrix([[x], [1]]).free_symbols
        {x}
        (   Rž   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRœ   6  s    c         G  s   |  j  | Œ  S(   sû  Test whether any subexpression matches any of the patterns.

        Examples
        ========

        >>> from sympy import Matrix, SparseMatrix, Float
        >>> from sympy.abc import x, y
        >>> A = Matrix(((1, x), (0.2, 3)))
        >>> B = SparseMatrix(((1, x), (0.2, 3)))
        >>> A.has(x)
        True
        >>> A.has(y)
        False
        >>> A.has(Float)
        True
        >>> B.has(x)
        True
        >>> B.has(y)
        False
        >>> B.has(Float)
        True
        (   R¢   (   R!   R¡   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRŸ   D  s    c         C  sD   | } t  | ƒ s* | r t n d „  } n  |  j s7 t S|  j | ƒ S(   s  Check if matrix M is an antisymmetric matrix,
        that is, M is a square matrix with all M[i, j] == -M[j, i].

        When ``simplify=True`` (default), the sum M[i, j] + M[j, i] is
        simplified before testing to see if it is zero. By default,
        the SymPy simplify function is used. To use a custom function
        set simplify to a function that accepts a single argument which
        returns a simplified expression. To skip simplification, set
        simplify to False but note that although this will be faster,
        it may induce false negatives.

        Examples
        ========

        >>> from sympy import Matrix, symbols
        >>> m = Matrix(2, 2, [0, 1, -1, 0])
        >>> m
        Matrix([
        [ 0, 1],
        [-1, 0]])
        >>> m.is_anti_symmetric()
        True
        >>> x, y = symbols('x y')
        >>> m = Matrix(2, 3, [0, 0, x, -y, 0, 0])
        >>> m
        Matrix([
        [ 0, 0, x],
        [-y, 0, 0]])
        >>> m.is_anti_symmetric()
        False

        >>> from sympy.abc import x, y
        >>> m = Matrix(3, 3, [0, x**2 + 2*x + 1, y,
        ...                   -(x + 1)**2 , 0, x*y,
        ...                   -y, -x*y, 0])

        Simplification of matrix elements is done by default so even
        though two elements which should be equal and opposite wouldn't
        pass an equality test, the matrix is still reported as
        anti-symmetric:

        >>> m[0, 1] == -m[1, 0]
        False
        >>> m.is_anti_symmetric()
        True

        If 'simplify=False' is used for the case when a Matrix is already
        simplified, this will speed things up. Here, we see that without
        simplification the matrix does not appear anti-symmetric:

        >>> m.is_anti_symmetric(simplify=False)
        False

        But if the matrix were already expanded, then it would appear
        anti-symmetric and simplification in the is_anti_symmetric routine
        is not needed:

        >>> m = m.expand()
        >>> m.is_anti_symmetric(simplify=False)
        True
        c         S  s   |  S(   N(    (   t   x(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ž  R5   (   R   R+   t	   is_squareR   R¦   (   R!   R   R¤   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_anti_symmetric]  s    ?	c         C  s
   |  j  ƒ  S(   s  Check if matrix is diagonal,
        that is matrix in which the entries outside the main diagonal are all zero.

        Examples
        ========

        >>> from sympy import Matrix, diag
        >>> m = Matrix(2, 2, [1, 0, 0, 2])
        >>> m
        Matrix([
        [1, 0],
        [0, 2]])
        >>> m.is_diagonal()
        True

        >>> m = Matrix(2, 2, [1, 1, 0, 2])
        >>> m
        Matrix([
        [1, 1],
        [0, 2]])
        >>> m.is_diagonal()
        False

        >>> m = diag(1, 2, 3)
        >>> m
        Matrix([
        [1, 0, 0],
        [0, 2, 0],
        [0, 0, 3]])
        >>> m.is_diagonal()
        True

        See Also
        ========

        is_lower
        is_upper
        is_diagonalizable
        diagonalize
        (   R§   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_diagonal¤  s    )c         C  sD   |  j  s t S| } t | ƒ s7 | r+ t n d „  } n  |  j | ƒ S(   sp  Checks if the matrix is Hermitian.

        In a Hermitian matrix element i,j is the complex conjugate of
        element j,i.

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> from sympy import I
        >>> from sympy.abc import x
        >>> a = Matrix([[1, I], [-I, 1]])
        >>> a
        Matrix([
        [ 1, I],
        [-I, 1]])
        >>> a.is_hermitian
        True
        >>> a[0, 0] = 2*I
        >>> a.is_hermitian
        False
        >>> a[0, 0] = x
        >>> a.is_hermitian
        >>> a[0, 1] = a[1, 0]*I
        >>> a.is_hermitian
        False
        c         S  s   |  S(   N(    (   R¶   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ñ  R5   (   R·   R   R   R+   R©   (   R!   R   R¤   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_hermitianÏ  s    	c         C  s   |  j  s t S|  j ƒ  S(   N(   R·   R   R«   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_Identityõ  s    	c         C  s
   |  j  ƒ  S(   s6  Checks if the matrix is in the lower-Hessenberg form.

        The lower hessenberg matrix has zero entries
        above the first superdiagonal.

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> a = Matrix([[1, 2, 0, 0], [5, 2, 3, 0], [3, 4, 3, 7], [5, 6, 1, 1]])
        >>> a
        Matrix([
        [1, 2, 0, 0],
        [5, 2, 3, 0],
        [3, 4, 3, 7],
        [5, 6, 1, 1]])
        >>> a.is_lower_hessenberg
        True

        See Also
        ========

        is_upper_hessenberg
        is_lower
        (   R¬   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_lower_hessenbergû  s    c         C  s
   |  j  ƒ  S(   sm  Check if matrix is a lower triangular matrix. True can be returned
        even if the matrix is not square.

        Examples
        ========

        >>> from sympy import Matrix
        >>> m = Matrix(2, 2, [1, 0, 0, 1])
        >>> m
        Matrix([
        [1, 0],
        [0, 1]])
        >>> m.is_lower
        True

        >>> m = Matrix(4, 3, [0, 0, 0, 2, 0, 0, 1, 4 , 0, 6, 6, 5])
        >>> m
        Matrix([
        [0, 0, 0],
        [2, 0, 0],
        [1, 4, 0],
        [6, 6, 5]])
        >>> m.is_lower
        True

        >>> from sympy.abc import x, y
        >>> m = Matrix(2, 2, [x**2 + y, y**2 + x, 0, x + y])
        >>> m
        Matrix([
        [x**2 + y, x + y**2],
        [       0,    x + y]])
        >>> m.is_lower
        False

        See Also
        ========

        is_upper
        is_diagonal
        is_lower_hessenberg
        (   R­   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_lower  s    +c         C  s   |  j  |  j k S(   s/  Checks if a matrix is square.

        A matrix is square if the number of rows equals the number of columns.
        The empty matrix is square by definition, since the number of rows and
        the number of columns are both zero.

        Examples
        ========

        >>> from sympy import Matrix
        >>> a = Matrix([[1, 2, 3], [4, 5, 6]])
        >>> b = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
        >>> c = Matrix([])
        >>> a.is_square
        False
        >>> b.is_square
        True
        >>> c.is_square
        True
        (   R(   R)   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR·   E  s    c         C  s
   |  j  ƒ  S(   sü   Checks if any elements contain Symbols.

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> from sympy.abc import x, y
        >>> M = Matrix([[x, y], [1, 0]])
        >>> M.is_symbolic()
        True

        (   R®   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_symbolic]  s    c         C  sD   | } t  | ƒ s* | r t n d „  } n  |  j s7 t S|  j | ƒ S(   s‘  Check if matrix is symmetric matrix,
        that is square matrix and is equal to its transpose.

        By default, simplifications occur before testing symmetry.
        They can be skipped using 'simplify=False'; while speeding things a bit,
        this may however induce false negatives.

        Examples
        ========

        >>> from sympy import Matrix
        >>> m = Matrix(2, 2, [0, 1, 1, 2])
        >>> m
        Matrix([
        [0, 1],
        [1, 2]])
        >>> m.is_symmetric()
        True

        >>> m = Matrix(2, 2, [0, 1, 2, 0])
        >>> m
        Matrix([
        [0, 1],
        [2, 0]])
        >>> m.is_symmetric()
        False

        >>> m = Matrix(2, 3, [0, 0, 0, 0, 0, 0])
        >>> m
        Matrix([
        [0, 0, 0],
        [0, 0, 0]])
        >>> m.is_symmetric()
        False

        >>> from sympy.abc import x, y
        >>> m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2 , 2, 0, y, 0, 3])
        >>> m
        Matrix([
        [         1, x**2 + 2*x + 1, y],
        [(x + 1)**2,              2, 0],
        [         y,              0, 3]])
        >>> m.is_symmetric()
        True

        If the matrix is already simplified, you may speed-up is_symmetric()
        test by using 'simplify=False'.

        >>> bool(m.is_symmetric(simplify=False))
        False
        >>> m1 = m.expand()
        >>> m1.is_symmetric(simplify=False)
        True
        c         S  s   |  S(   N(    (   R¶   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ¥  R5   (   R   R+   R·   R   R¯   (   R!   R   R¤   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_symmetricl  s    7	c         C  s
   |  j  ƒ  S(   s1  Checks if the matrix is the upper-Hessenberg form.

        The upper hessenberg matrix has zero entries
        below the first subdiagonal.

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> a = Matrix([[1, 4, 2, 3], [3, 4, 1, 7], [0, 2, 3, 4], [0, 0, 1, 3]])
        >>> a
        Matrix([
        [1, 4, 2, 3],
        [3, 4, 1, 7],
        [0, 2, 3, 4],
        [0, 0, 1, 3]])
        >>> a.is_upper_hessenberg
        True

        See Also
        ========

        is_lower_hessenberg
        is_upper
        (   R²   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_upper_hessenberg¬  s    c           s&   t  ‡  f d †  t d ˆ  j ƒ Dƒ ƒ S(   s%  Check if matrix is an upper triangular matrix. True can be returned
        even if the matrix is not square.

        Examples
        ========

        >>> from sympy import Matrix
        >>> m = Matrix(2, 2, [1, 0, 0, 1])
        >>> m
        Matrix([
        [1, 0],
        [0, 1]])
        >>> m.is_upper
        True

        >>> m = Matrix(4, 3, [5, 1, 9, 0, 4 , 6, 0, 0, 5, 0, 0, 0])
        >>> m
        Matrix([
        [5, 1, 9],
        [0, 4, 6],
        [0, 0, 5],
        [0, 0, 0]])
        >>> m.is_upper
        True

        >>> m = Matrix(2, 3, [4, 2, 5, 6, 1, 1])
        >>> m
        Matrix([
        [4, 2, 5],
        [6, 1, 1]])
        >>> m.is_upper
        False

        See Also
        ========

        is_lower
        is_diagonal
        is_upper_hessenberg
        c         3  sA   |  ]7 } t  t | ˆ  j ƒ ƒ D] } ˆ  | | f j Vq q d  S(   N(   R	   R±   R)   R£   (   R9   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>ó  s   i   (   R\   R	   R(   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   is_upperÉ  s    *c         C  s
   |  j  ƒ  S(   s	  Checks if a matrix is a zero matrix.

        A matrix is zero if every element is zero.  A matrix need not be square
        to be considered zero.  The empty matrix is zero by the principle of
        vacuous truth.  For a matrix that may or may not be zero (e.g.
        contains a symbol), this will be None

        Examples
        ========

        >>> from sympy import Matrix, zeros
        >>> from sympy.abc import x
        >>> a = Matrix([[0, 0], [0, 0]])
        >>> b = zeros(3, 4)
        >>> c = Matrix([[0, 1], [0, 0]])
        >>> d = Matrix([])
        >>> e = Matrix([[x, 0], [0, 0]])
        >>> a.is_zero
        True
        >>> b.is_zero
        True
        >>> c.is_zero
        False
        >>> d.is_zero
        True
        >>> e.is_zero
        (   R°   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR£   ÷  s    c         C  s
   |  j  ƒ  S(   s   Return non-zero values of self.(   R³   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   values  s    (#   R   R   R   R›   Rž   R¢   R¦   R§   R©   R«   R¬   R­   R®   R¯   R°   R²   R³   R˜   Rm   Rœ   RŸ   R¥   R¸   R¹   Rº   R»   R¼   R½   R·   R¾   R¿   RÀ   RÁ   R£   RÂ   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR•   Ø  s@   					
												G	+%-	@.t   MatrixOperationsc        	   B  sv  e  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 „  Z d „  Z d! d „ Z e d! e e e e e e d „ Z e d „  ƒ Z d d d „ Z d d „ Z d d „ Z e d „ Z e d „ Z d e e e d „ Z d „  Z d „  Z d „  Z  e e  d! d! d ƒ Z! e e d! d! d ƒ Z" e Z# d „  Z$ e Z% d  „  Z& RS("   sa   Provides basic matrix shape and elementwise
    operations.  Should not be instantiated directly.c         C  s   |  j  ƒ  j ƒ  S(   N(   t	   transposeR¨   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_adjoint  s    c         C  s8   |  j  |  j |  j g  |  D] } | | ƒ ^ q ƒ } | S(   N(   R    R(   R)   (   R!   t   fR¶   t   out(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_applyfunc"  s    4c         C  s2   d d l  m } m } |  j | ƒ |  j | ƒ f S(   Niÿÿÿÿ(   t   ret   im(   t$   sympy.functions.elementary.complexesRÉ   RÊ   t	   applyfunc(   R!   RÉ   RÊ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_as_real_imag&  s    c         C  s   |  j  d „  ƒ S(   Nc         S  s
   |  j  ƒ  S(   N(   R¨   (   R¶   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ,  R5   (   RÌ   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_conjugate+  s    c           s7   t  | ƒ ‰  ‡  ‡ f d †  } ˆ j ˆ j ˆ j | ƒ S(   Nc           s   ˆ |  ˆ  | f S(   N(    (   R.   R/   (   t   mappingR!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   2  s    (   R<   R    R(   R)   (   R!   t   permR1   (    (   RÏ   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_permute_cols.  s    c           s7   t  | ƒ ‰  ‡  ‡ f d †  } ˆ j ˆ j ˆ j | ƒ S(   Nc           s   ˆ ˆ  |  | f S(   N(    (   R.   R/   (   RÏ   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   ;  s    (   R<   R    R(   R)   (   R!   RÐ   R1   (    (   RÏ   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_permute_rows7  s    c           s#   t  ‡  f d †  t ˆ  j ƒ Dƒ ƒ S(   Nc         3  s   |  ] } ˆ  | | f Vq d  S(   N(    (   R9   R.   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>A  s    (   R‚   R	   R(   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_trace@  s    c           s"   ˆ  j  ˆ  j ˆ  j ‡  f d †  ƒ S(   Nc           s   ˆ  | |  f S(   N(    (   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   D  R5   (   R    R)   R(   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_transposeC  s    c         C  s
   |  j  ƒ  S(   s-   Conjugate transpose or Hermitian conjugation.(   RÅ   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   adjointF  s    c         C  s(   t  | ƒ s t d ƒ ‚ n  |  j | ƒ S(   sL  Apply a function to each element of the matrix.

        Examples
        ========

        >>> from sympy import Matrix
        >>> m = Matrix(2, 2, lambda i, j: i*2+j)
        >>> m
        Matrix([
        [0, 1],
        [2, 3]])
        >>> m.applyfunc(lambda i: 2*i)
        Matrix([
        [0, 2],
        [4, 6]])

        s   `f` must be callable.(   t   callableR[   RÈ   (   R!   RÆ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRÌ   J  s    c         C  s
   |  j  ƒ  S(   s@   Returns a tuple containing the (real, imaginary) part of matrix.(   RÍ   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   as_real_imaga  s    c         C  s
   |  j  ƒ  S(   s$  Return the by-element conjugation.

        Examples
        ========

        >>> from sympy.matrices import SparseMatrix
        >>> from sympy import I
        >>> a = SparseMatrix(((1, 2 + I), (3, 4), (I, -I)))
        >>> a
        Matrix([
        [1, 2 + I],
        [3,     4],
        [I,    -I]])
        >>> a.C
        Matrix([
        [ 1, 2 - I],
        [ 3,     4],
        [-I,     I]])

        See Also
        ========

        transpose: Matrix transposition
        H: Hermite conjugation
        D: Dirac conjugation
        (   RÎ   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR¨   e  s    c         K  s   |  j  d „  ƒ S(   Nc         S  s
   |  j  ƒ  S(   N(   t   doit(   R¶   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ƒ  R5   (   RÌ   (   R!   R   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRØ   ‚  s    c           s   |  j  ‡  ‡ f d †  ƒ S(   s&   Apply evalf() to each element of self.c           s   |  j  ˆ ˆ   S(   N(   t   evalf(   R.   (   t   optionst   prec(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ‡  R5   (   RÌ   (   R!   RÛ   RÚ   (    (   RÚ   RÛ   s4   lib/python2.7/site-packages/sympy/matrices/common.pyRÙ   …  s    c	   
   
     s.   |  j  ‡  ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ f	 d †  ƒ S(   s-  Apply core.function.expand to each entry of the matrix.

        Examples
        ========

        >>> from sympy.abc import x
        >>> from sympy.matrices import Matrix
        >>> Matrix(1, 1, [x*(x+1)])
        Matrix([[x*(x + 1)]])
        >>> _.expand()
        Matrix([[x**2 + x]])

        c      
     s%   |  j  ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ  ˆ  S(   N(   t   expand(   R¶   (	   t   basict   deept   hintst   logt   modulust   mult   multinomialt
   power_baset	   power_exp(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ˜  s   (   RÌ   (
   R!   RÞ   Rá   Rä   Rå   Râ   Rà   Rã   RÝ   Rß   (    (	   RÝ   RÞ   Rß   Rà   Rá   Râ   Rã   Rä   Rå   s4   lib/python2.7/site-packages/sympy/matrices/common.pyRÜ   ‰  s    c         C  s
   |  j  j S(   s™  Return Hermite conjugate.

        Examples
        ========

        >>> from sympy import Matrix, I
        >>> m = Matrix((0, 1 + I, 2, 3))
        >>> m
        Matrix([
        [    0],
        [1 + I],
        [    2],
        [    3]])
        >>> m.H
        Matrix([[0, 1 - I, 2, 3]])

        See Also
        ========

        conjugate: By-element conjugation
        D: Dirac conjugation
        (   t   Tt   C(   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   Hœ  s    R(   t   forwardc           sØ  | d k r d } n  | d k r* d } n  | d k r? d } n  | d k rc t  d j | ƒ ƒ ‚ n  | d k r‡ t  d	 j | ƒ ƒ ‚ n  | d k rœ |  j n |  j ‰  t ‡  f d
 †  t t | ƒ ƒ Dƒ ƒ sÜ t d ƒ ‚ n  y‡ t | d ƒ d k sû t	 ‚ | d k rt
 | ƒ } n  t t ˆ  ƒ ƒ } x1 | D]) \ } } | | | | | | <| | <q/W| } Wn t  t	 t f k
 rn Xd d l m } | | d ˆ  ƒ} | d k r»|  j | ƒ S| d k rÔ|  j | ƒ Sd S(   s~  Permute the rows or columns of a matrix by the given list of swaps.

        Parameters
        ==========

        perm : a permutation.  This may be a list swaps (e.g., `[[1, 2], [0, 3]]`),
            or any valid input to the `Permutation` constructor, including a `Permutation()`
            itself.  If `perm` is given explicitly as a list of indices or a `Permutation`,
            `direction` has no effect.
        orientation : ('rows' or 'cols') whether to permute the rows or the columns
        direction : ('forward', 'backward') whether to apply the permutations from
            the start of the list first, or from the back of the list first

        Examples
        ========

        >>> from sympy.matrices import eye
        >>> M = eye(3)
        >>> M.permute([[0, 1], [0, 2]], orientation='rows', direction='forward')
        Matrix([
        [0, 0, 1],
        [1, 0, 0],
        [0, 1, 0]])

        >>> from sympy.matrices import eye
        >>> M = eye(3)
        >>> M.permute([[0, 1], [0, 2]], orientation='rows', direction='backward')
        Matrix([
        [0, 1, 0],
        [0, 0, 1],
        [1, 0, 0]])

        t   forwardsRé   t	   backwardst   backwardt   columnsR)   s?   direction='{}' is an invalid kwarg. Try 'forward' or 'backward'R(   s:   orientation='{}' is an invalid kwarg. Try 'rows' or 'cols'c         3  s+   |  ]! } d  | k o  ˆ  k n Vq d S(   i    N(    (   R9   R´   (   t	   max_index(    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>ê  s    s   `swap` indices out of range.i    i   iÿÿÿÿ(   t   PermutationR~   N(   Ré   Rì   (   R(   R)   (   R[   RT   R(   R)   R\   R   R<   t
   IndexErrorR=   t   AssertionErrort   reversedR	   t   sympy.combinatoricsRï   RÒ   RÑ   (   R!   RÐ   t   orientationt	   directionRÏ   R.   R/   Rï   (    (   Rî   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   permute¶  s>    $					(!
c         C  s   |  j  | d d d | ƒS(   s…   Alias for `self.permute(swaps, orientation='cols', direction=direction)`

        See Also
        ========

        permute
        Rô   R)   Rõ   (   Rö   (   R!   t   swapsRõ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   permute_cols  s    c         C  s   |  j  | d d d | ƒS(   s…   Alias for `self.permute(swaps, orientation='rows', direction=direction)`

        See Also
        ========

        permute
        Rô   R(   Rõ   (   Rö   (   R!   R÷   Rõ   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   permute_rows  s    c           s   |  j  ‡  f d †  ƒ S(   s²  Apply refine to each element of the matrix.

        Examples
        ========

        >>> from sympy import Symbol, Matrix, Abs, sqrt, Q
        >>> x = Symbol('x')
        >>> Matrix([[Abs(x)**2, sqrt(x**2)],[sqrt(x**2), Abs(x)**2]])
        Matrix([
        [ Abs(x)**2, sqrt(x**2)],
        [sqrt(x**2),  Abs(x)**2]])
        >>> _.refine(Q.real(x))
        Matrix([
        [  x**2, Abs(x)],
        [Abs(x),   x**2]])

        c           s   t  |  ˆ  ƒ S(   N(   R   (   R¶   (   t   assumptions(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   +  R5   (   RÌ   (   R!   Rú   (    (   Rú   s4   lib/python2.7/site-packages/sympy/matrices/common.pyR     s    c           s   |  j  ‡  ‡ ‡ f d †  ƒ S(   s«  Replaces Function F in Matrix entries with Function G.

        Examples
        ========

        >>> from sympy import symbols, Function, Matrix
        >>> F, G = symbols('F, G', cls=Function)
        >>> M = Matrix(2, 2, lambda i, j: F(i+j)) ; M
        Matrix([
        [F(0), F(1)],
        [F(1), F(2)]])
        >>> N = M.replace(F,G)
        >>> N
        Matrix([
        [G(0), G(1)],
        [G(1), G(2)]])
        c           s   |  j  ˆ  ˆ ˆ ƒ S(   N(   t   replace(   R¶   (   t   Ft   Gt   map(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ?  R5   (   RÌ   (   R!   Rü   Rý   Rþ   (    (   Rü   Rý   Rþ   s4   lib/python2.7/site-packages/sympy/matrices/common.pyRû   -  s    g333333û?c           s   |  j  ‡  ‡ ‡ ‡ f d †  ƒ S(   su  Apply simplify to each element of the matrix.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy import sin, cos
        >>> from sympy.matrices import SparseMatrix
        >>> SparseMatrix(1, 1, [x*sin(y)**2 + x*cos(y)**2])
        Matrix([[x*sin(y)**2 + x*cos(y)**2]])
        >>> _.simplify()
        Matrix([[x]])
        c      	     s"   |  j  d ˆ d ˆ d ˆ d ˆ  ƒ S(   Nt   ratiot   measuret   rationalt   inverse(   R   (   R¶   (   R  R   Rÿ   R  (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   O  s   (   RÌ   (   R!   Rÿ   R   R  R  (    (   R  R   Rÿ   R  s4   lib/python2.7/site-packages/sympy/matrices/common.pyR   A  s    c           s   |  j  ‡  ‡ f d †  ƒ S(   sd  Return a new matrix with subs applied to each entry.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy.matrices import SparseMatrix, Matrix
        >>> SparseMatrix(1, 1, [x])
        Matrix([[x]])
        >>> _.subs(x, y)
        Matrix([[y]])
        >>> Matrix(_).subs(y, x)
        Matrix([[x]])
        c           s   |  j  ˆ  ˆ Ž  S(   N(   t   subs(   R¶   (   R   R   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   a  R5   (   RÌ   (   R!   R   R   (    (   R   R   s4   lib/python2.7/site-packages/sympy/matrices/common.pyR  R  s    c         C  s(   |  j  |  j k r t ƒ  ‚ n  |  j ƒ  S(   sú   
        Returns the trace of a square matrix i.e. the sum of the
        diagonal elements.

        Examples
        ========

        >>> from sympy import Matrix
        >>> A = Matrix(2, 2, [1, 2, 3, 4])
        >>> A.trace()
        5

        (   R(   R)   R   RÓ   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   tracec  s    c         C  s
   |  j  ƒ  S(   sa  
        Returns the transpose of the matrix.

        Examples
        ========

        >>> from sympy import Matrix
        >>> A = Matrix(2, 2, [1, 2, 3, 4])
        >>> A.transpose()
        Matrix([
        [1, 3],
        [2, 4]])

        >>> from sympy import Matrix, I
        >>> m=Matrix(((1, 2+I), (3, 4)))
        >>> m
        Matrix([
        [1, 2 + I],
        [3,     4]])
        >>> m.transpose()
        Matrix([
        [    1, 3],
        [2 + I, 4]])
        >>> m.T == m.transpose()
        True

        See Also
        ========

        conjugate: By-element conjugation

        (   RÔ   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRÄ   u  s    !s   Matrix transposition.s   By-element conjugation.c           s   |  j  ‡  f d †  ƒ S(   st  Return a new matrix with xreplace applied to each entry.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> from sympy.matrices import SparseMatrix, Matrix
        >>> SparseMatrix(1, 1, [x])
        Matrix([[x]])
        >>> _.xreplace({x: y})
        Matrix([[y]])
        >>> Matrix(_).xreplace({y: x})
        Matrix([[x]])
        c           s   |  j  ˆ  ƒ S(   N(   t   xreplace(   R¶   (   t   rule(    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ­  R5   (   RÌ   (   R!   R  (    (   R  s4   lib/python2.7/site-packages/sympy/matrices/common.pyR  ž  s    c           s)   d d l  m ‰ |  j ‡  ‡ f d †  ƒ S(   Niÿÿÿÿ(   t   trigsimpc           s   ˆ |  ˆ   S(   N(    (   R¶   (   t   optsR  (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ³  R5   (   t   sympy.simplifyR  RÌ   (   R!   R  (    (   R  R  s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_trigsimp±  s    N('   R   R   R   RÅ   RÈ   RÍ   RÎ   RÑ   RÒ   RÓ   RÔ   RÕ   RÌ   R×   R¨   RØ   R'   RÙ   R¥   RÜ   Rm   Rè   Rö   Rø   Rù   R   R   Rû   R   R   R  R  RÄ   Ræ   Rç   RP   R  t   _eval_simplifyR
  (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRÃ     sB   															O

			#	t   MatrixArithmeticc           B  sg  e  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 e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z d „  Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d  „  ƒ Z e d! ƒ d" „  ƒ Z d# „  Z RS($   sU   Provides basic matrix arithmetic operations.
    Should not be instantiated directly.g…ëQ¸$@c           s"   ˆ  j  ˆ  j ˆ  j ‡  f d †  ƒ S(   Nc           s   t  ˆ  |  | f ƒ S(   N(   R   (   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ½  R5   (   R    R(   R)   (   R!   (    (   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt	   _eval_Abs¼  s    c           s%   ˆ j  ˆ j ˆ j ‡  ‡ f d †  ƒ S(   Nc           s   ˆ |  | f ˆ  |  | f S(   N(    (   R.   R/   (   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   Á  R5   (   R    R(   R)   (   R!   R"   (    (   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt	   _eval_add¿  s    c           s+   ‡  ‡ f d †  } ˆ j  ˆ j ˆ  j | ƒ S(   Nc           s¦   y0 t  ‡  ‡ ‡ ‡ f d †  t ˆ j ƒ Dƒ ƒ SWno t k
 r¡ ˆ ˆ  d f ˆ d ˆ f } x< t d ˆ j ƒ D]( } | ˆ ˆ  | f ˆ | ˆ f 7} qq W| SXd  S(   Nc         3  s-   |  ]# } ˆ ˆ  | f ˆ | ˆ f Vq d  S(   N(    (   R9   Ra   (   R.   R/   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>Æ  s    i    i   (   R‚   R	   R)   R[   (   R.   R/   t   retRa   (   R"   R!   (   R.   R/   s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   Ä  s    0&(   R    R(   R)   (   R!   R"   R1   (    (   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_matrix_mulÃ  s    c           s%   ˆ j  ˆ j ˆ j ‡  ‡ f d †  ƒ S(   Nc           s   ˆ |  | f ˆ  |  | f S(   N(    (   R.   R/   (   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   Õ  R5   (   R    R(   R)   (   R!   R"   (    (   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_matrix_mul_elementwiseÔ  s    c           s+   ‡  ‡ f d †  } ˆ j  ˆ  j ˆ j | ƒ S(   Nc           s,   t  ‡  ‡ ‡ ‡ f d †  t ˆ j ƒ Dƒ ƒ S(   Nc         3  s-   |  ]# } ˆ ˆ  | f ˆ | ˆ f Vq d  S(   N(    (   R9   Ra   (   R.   R/   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>Ù  s    (   R‚   R	   R)   (   R.   R/   (   R"   R!   (   R.   R/   s4   lib/python2.7/site-packages/sympy/matrices/common.pyR1   Ø  s    (   R    R(   R)   (   R!   R"   R1   (    (   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_matrix_rmul×  s    c         C  sP   | d k r |  S| d d k r5 |  |  j  | d ƒ S|  j  | d ƒ } | | S(   Ni   i   (   t   _eval_pow_by_recursion(   R!   t   numR  (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR  Ü  s    c           s%   ˆ j  ˆ j ˆ j ‡  ‡ f d †  ƒ S(   Nc           s   ˆ |  | f ˆ  S(   N(    (   R.   R/   (   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   å  R5   (   R    R(   R)   (   R!   R"   (    (   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_scalar_mulä  s    c           s%   ˆ j  ˆ j ˆ j ‡  ‡ f d †  ƒ S(   Nc           s   ˆ  ˆ |  | f S(   N(    (   R.   R/   (   R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   è  R5   (   R    R(   R)   (   R!   R"   (    (   R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _eval_scalar_rmulç  s    c           s8   d d l  m ‰  ˆ j ˆ j ˆ j ‡  ‡ ‡ f d †  ƒ S(   Niÿÿÿÿ(   t   Modc           s   ˆ  ˆ |  | f ˆ ƒ S(   N(    (   R.   R/   (   R  R"   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   ì  R5   (   t   sympyR  R    R(   R)   (   R!   R"   (    (   R  R"   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt	   _eval_Modê  s    c         C  s
   |  j  ƒ  S(   s5   Returns a new matrix with entry-wise absolute values.(   R  (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __abs__ï  s    t   __radd__c         C  së   t  | ƒ } t | d ƒ rO |  j | j k rO t d |  j | j f ƒ ‚ qO n  t | d t ƒ r£ |  | } } | j t | | ƒ k r– | | } } n  | j | ƒ St | d t ƒ rÅ t	 j |  | ƒ St
 d t |  ƒ t | ƒ f ƒ ‚ d S(   s>   Return self + other, raising ShapeError if shapes don't match.R*   s   Matrix size mismatch: %s + %sR{   t   is_MatrixLikes   cannot add %s and %sN(   t
   _matrixifyR|   R*   R   R€   R   t	   __class__R7   R  R  R[   RV   (   R!   R"   R    t   b(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __add__ó  s    t   __rdiv__c         C  s   |  t  j | S(   N(   R   Rq   (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __div__  s    t   __rmatmul__c         C  sC   t  | ƒ } t | d t ƒ r6 t | d t ƒ r6 t S|  j | ƒ S(   NR{   R  (   R  R€   R   t   NotImplementedt   __mul__(   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt
   __matmul__  s    &t   __rmul__c         C  sè   t  | ƒ } t | d ƒ rl t | j ƒ d k rl |  j d | j d k rl t d |  j | j f ƒ ‚ ql n  t | d t ƒ r‹ |  j | ƒ St | d t ƒ r­ t j |  | ƒ St	 | t
 ƒ sä y |  j | ƒ SWqä t k
 rà qä Xn  t S(   s  Return self*other where other is either a scalar or a matrix
        of compatible dimensions.

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> A = Matrix([[1, 2, 3], [4, 5, 6]])
        >>> 2*A == A*2 == Matrix([[2, 4, 6], [8, 10, 12]])
        True
        >>> B = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
        >>> A*B
        Matrix([
        [30, 36, 42],
        [66, 81, 96]])
        >>> B*A
        Traceback (most recent call last):
        ...
        ShapeError: Matrices size mismatch.
        >>>

        See Also
        ========

        matrix_multiply_elementwise
        R*   i   i   i    s   Matrix size mismatch: %s * %s.R{   R  (   R  R|   R=   R*   R   R€   R   R  R  RY   R   R  R[   R$  (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR%    s    $c         C  s   |  j  d ƒ S(   Niÿÿÿÿ(   R  (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __neg__K  s    t   __rpow__c         C  sŸ  |  j  |  j k r t ƒ  ‚ n  |  } t | d d  ƒ } t | ƒ } | j r(| d d k r(| j  d k r… | j | d | g g ƒ S| d k r­ |  j |  j  |  j d „  ƒ S| d k  rÏ | } | j ƒ  } nL | j  d k r| d k r| d  k	 ry | | ƒ SWqt	 k
 rqXn  | j
 | ƒ S| j rp| j d  k rp| j ƒ  d k rpd d l m } | | | ƒ St | t t f ƒ r| | ƒ St d	 ƒ ‚ d  S(
   Nt   _matrix_pow_by_jordan_blocksi   i    c         S  s   t  |  | k ƒ S(   N(   t   int(   R.   R/   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR4   Y  R5   i   i † iÿÿÿÿ(   t   MatPowsI   Only SymPy expressions or integers are supported as exponent for matrices(   R(   R)   R   R€   R'   R   t	   is_NumberR    t   invR   R  t   is_negativet   dett   sympy.matrices.expressionsR,  RY   R   t   floatR[   (   R!   R  R    t
   jordan_powR,  (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __pow__N  s4    '+
R   c         C  s   |  | S(   N(    (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR  o  s    R&  c         C  sC   t  | ƒ } t | d t ƒ r6 t | d t ƒ r6 t S|  j | ƒ S(   NR{   R  (   R  R€   R   R$  R'  (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR#  s  s    &R%  c         C  sâ   t  | ƒ } t | d ƒ r\ t | j ƒ d k r\ |  j d | j d k r\ t d ƒ ‚ q\ n  t | d t ƒ r… | j | j ƒ  |  ƒ St | d t ƒ r§ t	 j
 |  | ƒ St | t ƒ sÞ y |  j | ƒ SWqÞ t k
 rÚ qÞ Xn  t S(   NR*   i   i    i   s   Matrix size mismatch.R{   R  (   R  R|   R=   R*   R   R€   R   R    t
   as_mutableR  R  RY   R   R  R[   R$  (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR'  {  s    $t   __sub__c         C  s	   |  | S(   N(    (   R!   R    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __rsub__”  s    R7  c         C  s	   |  | S(   N(    (   R!   R    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR6  ˜  s    t   __rtruediv__c         C  s   |  j  | ƒ S(   N(   R"  (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __truediv__œ  s    c         C  s@   |  j  | j  k r3 t d j |  j  | j  ƒ ƒ ‚ n  |  j | ƒ S(   s²  Return the Hadamard product (elementwise product) of A and B

        Examples
        ========

        >>> from sympy.matrices import Matrix
        >>> A = Matrix([[0, 1, 2], [3, 4, 5]])
        >>> B = Matrix([[1, 10, 100], [100, 10, 1]])
        >>> A.multiply_elementwise(B)
        Matrix([
        [  0, 10, 200],
        [300, 40,   5]])

        See Also
        ========

        cross
        dot
        multiply
        s!   Matrix shapes must agree {} != {}(   R*   R   RT   R  (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   multiply_elementwise   s    !(   R   R   R   t   _op_priorityR  R  R  R  R  R  R  R  R  R  R   R   R"  R&  R%  R(  R4  R  R#  R'  R7  R6  R9  R:  (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR  ¶  s2   										4	!t   MatrixCommonc           B  s   e  Z d  Z e Z RS(   ss   All common matrix operations including basic arithmetic, shaping,
    and special matrices like `zeros`, and `eye`.(   R   R   R   R¥   t	   _diff_wrt(    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR<  »  s   t   _MinimalMatrixc           B  sƒ   e  Z d  Z e Z e e ƒ Z d Z e Z	 e
 Z e d „  ƒ Z d	 d	 d „ Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(
   sû  Class providing the minimum functionality
    for a matrix-like object and implementing every method
    required for a `MatrixRequired`.  This class does not have everything
    needed to become a full-fledged sympy object, but it will satisfy the
    requirements of anything inheriting from `MatrixRequired`.  If you wish
    to make a specialized matrix type, make sure to implement these
    methods and properties with the exception of `__init__` and `__repr__`
    which are included for convenience.i   c         O  s   |  | | Ž  S(   N(    (   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR    Ó  s    c           sW  t  ˆ ƒ r4 t ‡  ‡ f d †  t | ƒ Dƒ ƒ ‰ n  ˆ  d  k rU ˆ d  k rU | ‰ n  t ˆ d | ˆ  f ƒ \ } ‰  yg ˆ  d  k r— ˆ d  k r— | ‰ n  t ˆ d ƒ ‰  t ˆ ƒ } g  ˆ D] } | D] } | ^ qÄ qº ‰ Wn t t f k
 ró n Xt ‡ f d †  ˆ Dƒ ƒ ˆ _	 | ˆ  ˆ _
 ˆ _ ˆ j
 d  k sDˆ j d  k rSt d ƒ ‚ n  d  S(   Nc         3  s1   |  ]' } t  ˆ  ƒ D] } ˆ | | ƒ Vq q d  S(   N(   R	   (   R9   R.   R/   (   R)   R;   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>Ú  s    R*   i    c         3  s   |  ] } ˆ  j  | ƒ Vq d  S(   N(   t   _sympify(   R9   R¶   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>ç  s    s.   Cannot initialize matrix with given parameters(   R   R<   R	   R'   R€   R=   Rð   R[   Rµ   R;   R(   R)   R   (   R!   R(   R)   R;   t   lR¶   (    (   R)   R;   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __init__×  s"    (		*c           s
  ‡ f d †  } ‡ f d †  } t  | t ƒ rÿ | \ } } t  | t ƒ sW t  | t ƒ rí | | | ƒ \ } } t t ˆ j ƒ ƒ | t t ˆ j ƒ ƒ | } ‰  ‡  ‡ f d †  | Dƒ } ˆ j t | ƒ t ˆ  ƒ t ‡ f d †  | Dƒ ƒ ƒ S| | | ƒ } n  ˆ j	 | S(   Nc           sŠ   t  |  t ƒ s( t |  |  d d ƒ }  n  t |  j ˆ  j ƒ Œ  }  t  | t ƒ sh t | | d d ƒ } n  t | j ˆ  j ƒ Œ  } |  | f S(   s“   Ensure that row_slice and col_slice don't have
            `None` in their arguments.  Any integers are converted
            to slices of length 1i   N(   RY   t   sliceR'   R?   R(   R)   (   t	   row_slicet	   col_slice(   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _normalize_slicesí  s    c           s   |  ˆ  j  | S(   sX   Return the index in _mat corresponding
            to the (i,j) position in the matrix. (   R)   (   R.   R/   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   _coord_to_indexû  s    c         3  s-   |  ]# } ˆ  D] } | ˆ j  | Vq q d  S(   N(   R)   (   R9   R.   R/   (   R:   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>		  s    c         3  s   |  ] } ˆ  j  | Vq d  S(   N(   R;   (   R9   R.   (   R!   (    s4   lib/python2.7/site-packages/sympy/matrices/common.pys	   <genexpr>	  s    (
   RY   Rµ   RB  R<   R	   R(   R)   R    R=   R;   (   R!   R$   RE  RF  R.   R/   R>   R?   (    (   R:   R!   s4   lib/python2.7/site-packages/sympy/matrices/common.pyR%   ì  s    c         C  sN   y t  |  | ƒ Wn t k
 r% t SX|  j | j k oM t |  ƒ t | ƒ k S(   N(   R7   R[   R   R*   R<   (   R!   R"   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR#   	  s
    c         C  s   |  j  |  j S(   N(   R(   R)   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR&   	  s    c         C  s   d j  |  j |  j |  j ƒ S(   Ns   _MinimalMatrix({}, {}, {})(   RT   R(   R)   R;   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __repr__	  s    c         C  s   |  j  |  j f S(   N(   R(   R)   (   R!   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR*   "	  s    N(   R   R   R   R¥   R  t   staticmethodR   R?  t   _class_priorityR{   R   t   is_MatrixExprR,   R    R'   RA  R%   R#   R&   RG  Rm   R*   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR>  Â  s   	'			t   _MatrixWrapperc           B  s2   e  Z d  Z e Z d d „ Z d „  Z d „  Z RS(   s8  Wrapper class providing the minimum functionality
    for a matrix-like object: .rows, .cols, .shape, indexability,
    and iterability.  CommonMatrix math operations should work
    on matrix-like objects.  For example, wrapping a numpy
    matrix in a MatrixWrapper allows it to be passed to CommonMatrix.
    c         C  s4   | |  _  | d  k r | j n | \ |  _ |  _ d  S(   N(   R;   R'   R*   R(   R)   (   R!   R;   R*   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRA  0	  s    	c         C  s   t  |  j | ƒ S(   sM   Most attribute access is passed straight through
        to the stored matrix(   R€   R;   (   R!   t   attr(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   __getattr__4	  s    c         C  s   |  j  j | ƒ S(   N(   R;   R%   (   R!   R$   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR%   9	  s    N(	   R   R   R   R¥   R  R'   RA  RM  R%   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyRK  '	  s
   	c         C  sK   t  |  d t ƒ r |  St |  d ƒ rG t |  j ƒ d k rG t |  ƒ Sn  |  S(   s‘   If `mat` is a Matrix or is matrix-like,
    return a Matrix or MatrixWrapper object.  Otherwise
    `mat` is passed through without modification.R{   R*   i   (   R€   R   R|   R=   R*   RK  (   R;   (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR  =	  s    c         C  s²   t  |  ƒ t k	 rR t |  d d ƒ } | d k	 r< | ƒ  }  qR t d |  f ƒ ‚ n  | d k	 r¨ |  d k  rw |  | 7}  n  |  d k oŒ |  | k  s¨ t d |  f ƒ ‚ q¨ n  t |  ƒ S(   s>   Return integer after making positive and validating against n.t	   __index__s   Invalid index a[%r]i    s   Index out of range: a[%s]N(   RV   R+  R€   R'   Rð   (   R/   RP   t   jindex(    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR^   I	  s    c         C  sÏ   t  |  d d ƒ } t  | d d ƒ } d | | f k rY |  j | j k rO |  j S| j Sn  y d d l } Wn t k
 r| n3 Xt |  | j ƒ r– | j St | | j ƒ r¯ |  j St d |  j | j f ƒ ‚ d S(   sÊ  
    Get the type of the result when combining matrices of different types.

    Currently the strategy is that immutability is contagious.

    Examples
    ========

    >>> from sympy import Matrix, ImmutableMatrix
    >>> from sympy.matrices.common import classof
    >>> M = Matrix([[1, 2], [3, 4]]) # a Mutable Matrix
    >>> IM = ImmutableMatrix([[1, 2], [3, 4]])
    >>> classof(M, IM)
    <class 'sympy.matrices.immutable.ImmutableDenseMatrix'>
    RI  iÿÿÿÿNs   Incompatible classes %s, %s(	   R€   R'   RI  R  t   numpyt   ImportErrorRY   t   ndarrayR[   (   t   At   Bt
   priority_At
   priority_BRP  (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyR7   Y	  s    
N(:   R   t
   __future__R    R   t   collectionsR   t   inspectR   t   sympy.assumptions.refineR   t   sympy.core.basicR   t   sympy.core.compatibilityR   R   R   R	   R
   t   sympy.core.decoratorsR   t   sympy.core.exprR   t   sympy.core.functionR   t   sympy.core.singletonR   t   sympy.core.symbolR   t   sympy.core.sympifyR   t   sympy.functionsR   R	  R   R+   t   sympy.utilities.exceptionsR   t   sympy.utilities.iterablesR   t	   ExceptionR   RS   R   R   t   objectR   R-   Rn   R•   RÃ   R  R<  R>  RK  R  R'   R^   R7   (    (    (    s4   lib/python2.7/site-packages/sympy/matrices/common.pyt   <module>   sN   (ÿ ÿ ÿ yÿ ÿ Eÿ œÿ e	