
ʽXc           @` sz  d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l m	 Z	 d d l
 m Z m Z m Z m Z m Z d d d	 d
 d g Z d
 e f d     YZ d e f d     YZ d e f d     YZ i d d g d 6d d g d 6d d g d 6d d g d 6d d g d 6d d g d 6d  d! g d" 6d# d$ g d% 6d& d' g d( 6d) d* g d+ 6d, d- g d. 6d/ d0 g d1 6d2 d3 g d4 6d5 d6 g d7 6d8 d9 g d: 6d; d< g d= 6d> d? g d@ 6dA dB g dC 6dD dE g dF 6dG dH g dI 6Z e e j e j e j e j e j e j e j e j e j e j  e j! e j" e j# e j$ e j% e j& e j' e j( g  Z) dJ Z* d e+ f dK     YZ, dL   Z- e- Z. d S(M   s   Base class for sparse matricesi    (   t   divisiont   print_functiont   absolute_importN(   t   xrangei   (   t   isdenset   isscalarliket	   isintliket   get_sum_dtypet   validateaxist   spmatrixt
   isspmatrixt   issparset   SparseWarningt   SparseEfficiencyWarningc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR      s   t   SparseFormatWarningc           B` s   e  Z RS(    (   R   R   (    (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR      s   c           B` s   e  Z RS(    (   R   R   (    (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR      s   s   Compressed Sparse Columnt   cscs   Compressed Sparse Rowt   csri   s   Dictionary Of Keyst   doki   s   LInked Listt   lili   s   Dictionary of Dictionariest   dodi   s   Symmetric Sparse Skylinet   sssi   t
   COOrdinatet   cooi   s   Linpack BAndedt   lbai   s#   Ellpack-itpack Generalized Diagonalt   egdi	   t   DIAgonalt   diai
   s   Block Sparse Rowt   bsri   s   Modified compressed Sparse Rowt   msri   s   Block Sparse Columnt   bsci   s!   Modified compressed Sparse Columnt   msci   s   Symmetric SKylinet   sski   s   Nonsymmetric SKylinet   nski   s   JAgged Diagonalt   jadi   s   Unsymmetric Sparse Skylinet   ussi   s   Variable Block Rowt   vbri   t	   Undefinedt   undi2   c           B` sh  e  Z d  Z d Z d Z e d  Z d   Z d   Z e	 d e d e  Z
 d d	  Z d
   Z d   Z d   Z d   Z d   Z dW d  Z e	 d    Z d   Z d   Z d   Z d   Z e Z d   Z d   Z d   Z d   Z d   Z d   Z dW 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/ d,   Z0 d-   Z1 d.   Z2 e3 e3 d/  Z4 d0   Z5 d1   Z6 d2   Z7 d3   Z8 d4   Z9 d5   Z: d6   Z; d7   Z< d8   Z= d9   Z> d:   Z? d;   Z@ dW e3 d<  ZA d=   ZB d>   ZC eB j eC _ d?   ZD d@   ZE dA   ZF dB   ZG dC   ZH dD   ZI dW dW dE  ZJ dW dW dF  ZK e3 dG  ZL e3 dH  ZM e3 dI  ZN e3 dJ  ZO e3 dK  ZP dW e3 dL  ZQ e3 dM  ZR dN   ZS dW dW dW dO  ZT dW dW dW dP  ZU dQ   ZV dR dS  ZW dT   ZX dU   ZY dV   ZZ RS(X   s    This class provides a base class for all sparse matrices.  It
    cannot be instantiated.  Most of the work is provided by subclasses.
    g333333$@i   c         C` s7   d  |  _ |  j j d k r* t d   n  | |  _ d  S(   NR	   s7   This class is not intended to be instantiated directly.(   t   Nonet   _shapet	   __class__R   t
   ValueErrort   maxprint(   t   selfR,   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __init__F   s    	c         C` s  t  |  } t |  d k r- t d   n  y$ t | d  t | d  f } Wn t d   n X| d d k o | d d k s t d   n  |  j | k r |  j d k	 r y |  j |  }  Wq t k
 r t d |  j	 j
   q Xn  | |  _ d S(   s   See `reshape`.i   s1   Only two-dimensional sparse arrays are supported.i    i   s   invalid shapes!   Reshaping not implemented for %s.N(   t   tuplet   lenR+   t   intt	   TypeErrorR)   R(   t   reshapet   NotImplementedErrorR*   R   (   R-   t   shape(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt	   set_shapeM   s     $ c         C` s   |  j  S(   s   Get shape of a matrix.(   R)   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt	   get_shaped   s    t   fgett   fsett   Cc         C` s   t  d |  j j   d S(   s  
        Gives a new shape to a sparse matrix without changing its data.

        Parameters
        ----------
        shape : length-2 tuple of ints
            The new shape should be compatible with the original shape.
        order : 'C', optional
            This argument is in the signature *solely* for NumPy
            compatibility reasons. Do not pass in anything except
            for the default value, as this argument is not used.

        Returns
        -------
        reshaped_matrix : `self` with the new dimensions of `shape`

        See Also
        --------
        np.matrix.reshape : NumPy's implementation of 'reshape' for matrices
        s!   Reshaping not implemented for %s.N(   R4   R*   R   (   R-   R5   t   order(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR3   j   s    c         C` s   |  j    j |  j |  j  S(   s   Cast the matrix elements to a specified type.

        The data will be copied.

        Parameters
        ----------
        t : string or numpy dtype
            Typecode or data-type to which to cast the data.
        (   t   tocsrt   astypet   asformatt   format(   R-   t   t(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR=      s    
c         C` sx   d d d d g } |  j  j | k r( |  Sx3 | D]+ } |  j  t j  |  k r/ |  j |  Sq/ Wt d |  j  j   d S(   s7   Upcast matrix to a floating point format (if necessary)t   ft   dt   Ft   Ds-   cannot upcast [%s] to a floating point formatN(   t   dtypet   chart   npR=   R2   t   name(   R-   t   fp_typest   fp_type(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   asfptype   s    c         c` s7   x0 t  |  j d  D] } |  | d  d   f Vq Wd  S(   Ni    (   R   R5   (   R-   t   r(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __iter__   s    c         C` s   |  j  S(   s3   Maximum number of elements to display when printed.(   R,   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   getmaxprint   s    c         C` s   t  d |  j j   d S(   s(  Number of non-zero entries, equivalent to

        np.count_nonzero(a.toarray())

        Unlike getnnz() and the nnz property, which return the number of stored
        entries (the length of the data attribute), this method counts the
        actual number of non-zero entries in data.
        s%   count_nonzero not implemented for %s.N(   R4   R*   R   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   count_nonzero   s    	c         C` s   t  d |  j j   d S(   sJ  Number of stored values, including explicit zeros.

        Parameters
        ----------
        axis : None, 0, or 1
            Select between the number of values across the whole matrix, in
            each column, or in each row.

        See also
        --------
        count_nonzero : Number of non-zero entries
        s   getnnz not implemented for %s.N(   R4   R*   R   (   R-   t   axis(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   getnnz   s    c         C` s
   |  j    S(   s   Number of stored values, including explicit zeros.

        See also
        --------
        count_nonzero : Number of non-zero entries
        (   RQ   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   nnz   s    c         C` s   t  |  d d  S(   s.   Format of a matrix representation as a string.R?   R'   (   t   getattr(   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt	   getformat   s    c         C` s7   t  |  j   \ } } d |  j |  j j |  j | f S(   NsH   <%dx%d sparse matrix of type '%s'
	with %d stored elements in %s format>(   t   _formatsRT   R5   RE   t   typeRR   (   R-   t   _t   format_name(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __repr__   s    c         C` s   |  j    } |  j   } d   } |  j | k r | d } | | j |  | j |  | j |   } | d 7} | | d } | | | j | | j | | j |  7} n | | j | j | j  } | S(   Nc         S` sB   t  t t  |  |   |  } d j g  | D] } d | ^ q+  S(   Ns   
s     %s	%s(   t   zipt   listt   join(   t   rowt   colt   datat   triplesR@   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   tostr   s    i   s   
  :	:
(   RN   t   tocooRR   R]   R^   R_   (   R-   R,   t   ARa   t   halft   out(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __str__   s    	
'
1c         C` s,   |  j  d k r |  j d k St d   d  S(   Ni   i    s\   The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().(   i   i   (   R5   RR   R+   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __bool__   s    c         C` s   t  d   d  S(   Ns;   sparse matrix length is ambiguous; use getnnz() or shape[0](   R2   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __len__   s    c         C` s7   | d k s | |  j k r |  St |  d |    Sd S(   s  Return this matrix in a given sparse format

        Parameters
        ----------
        format : {string, None}
            desired sparse matrix format
                - None for no format conversion
                - "csr" for csr_matrix format
                - "csc" for csc_matrix format
                - "lil" for lil_matrix format
                - "dok" for dok_matrix format and so on

        t   toN(   R(   R?   RS   (   R-   R?   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR>      s    c         C` s   |  j    j |  S(   s4   Point-wise multiplication by another matrix
        (   R<   t   multiply(   R-   t   other(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRj     s    c         C` s   |  j    j |  S(   s5   Element-wise maximum between this and another matrix.(   R<   t   maximum(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRl     s    c         C` s   |  j    j |  S(   s5   Element-wise minimum between this and another matrix.(   R<   t   minimum(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRm     s    c         C` s   |  | S(   s1  Ordinary dot product

        Examples
        --------
        >>> import numpy as np
        >>> from scipy.sparse import csr_matrix
        >>> A = csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]])
        >>> v = np.array([1, 0, -1])
        >>> A.dot(v)
        array([ 1, -3, -1], dtype=int64)

        (    (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   dot!  s    c         C` s   |  j    j | d | S(   s   Element-wise power.RE   (   R<   t   power(   R-   t   nRE   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRo   0  s    c         C` s   |  j    j |  S(   N(   R<   t   __eq__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRq   4  s    c         C` s   |  j    j |  S(   N(   R<   t   __ne__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRr   7  s    c         C` s   |  j    j |  S(   N(   R<   t   __lt__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRs   :  s    c         C` s   |  j    j |  S(   N(   R<   t   __gt__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRt   =  s    c         C` s   |  j    j |  S(   N(   R<   t   __le__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRu   @  s    c         C` s   |  j    j |  S(   N(   R<   t   __ge__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRv   C  s    c         C` s   t  |  j    S(   N(   t   absR<   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __abs__F  s    c         C` s   |  j    j |  S(   N(   R<   t   __add__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRy   I  s    c         C` s   |  j    j |  S(   N(   R<   t   __radd__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRz   L  s    c         C` s   |  j    j |  S(   N(   R<   t   __sub__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR{   O  s    c         C` s   |  j    j |  S(   N(   R<   t   __rsub__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR|   S  s    c      	   C` s  |  j  \ } } | j t j k r | j  | f k r@ |  j |  S| j  | d f k rt |  j | j    j | d  S| j d k r | j  d | k r |  j |  Sn  t	 |  r |  j
 |  St |  r|  j  d | j  d k r t d   n  |  j |  St j |  } | j d k r5| j t j k r5t Sy | j  Wn t k
 rY| } n X| j d k s| j d k r8| j  d d k r8| j  | f k r| j  | d f k rt d   n  |  j t j |   } t | t j  rt j |  } n  | j d k r4| j  d d k r4| j d d  } n  | S| j d k r| j  d |  j  d k rpt d   n  |  j t j |   } t | t j  rt j |  } n  | St d   d S(   s   interpret other and call one of the following

        self._mul_scalar()
        self._mul_vector()
        self._mul_multivector()
        self._mul_sparse_matrix()
        i   i   i    s   dimension mismatchis   could not interpret dimensionsN(   R5   R*   RG   t   ndarrayt   _mul_vectort   ravelR3   t   ndimt   _mul_multivectorR   t   _mul_scalarR   R+   t   _mul_sparse_matrixt
   asanyarrayRE   t   object_t   NotImplementedt   AttributeErrort
   isinstancet   matrixt   asmatrixt   asarray(   R-   Rk   t   Mt   Nt   other_at   result(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __mul__V  sL    	"!
1'"c         C` s   |  j    j |  S(   N(   R<   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s   |  j    j |  S(   N(   R<   R~   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR~     s    c         C` s   |  j    j |  S(   N(   R<   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s   |  j    j |  S(   N(   R<   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` sj   t  |  r |  j |  Sy | j   } Wn& t k
 rQ t j |  j   } n X|  j   | j   Sd  S(   N(   R   R   t	   transposeR   RG   R   (   R-   Rk   t   tr(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __rmul__  s    c         C` s(   t  |  r t d   n  |  j |  S(   Ns0   Scalar operands are not allowed, use '*' instead(   R   R+   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt
   __matmul__  s    c         C` s(   t  |  r t d   n  |  j |  S(   Ns0   Scalar operands are not allowed, use '*' instead(   R   R+   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __rmatmul__  s    c         C` s  t  |  r | rG | r. t j | |  j    St j | |  j    Sn  | r t j |  j t j  r |  j t j  j	 d |  S|  j	 d |  } t j
 |  j } t j |  j t j  r t j | t j  r | j |  j  S| Sn t |  rg| s2| rt j |  j   |  St j |  j   |  Sq| rNt j | |  j    St j | |  j    Sn t |  r| r| j |  | d t S|  j   } | rt j |  j t j  r| j t j  j |  S| j |  Sn t Sd  S(   Ng      ?t   rdivide(   R   RG   t   true_dividet   todenset   dividet   can_castRE   t   float_R=   R   R   t
   issubdtypet   integerR   R
   t   _dividet   FalseR<   t   _divide_sparseR   (   R-   Rk   R   R   RL   t   scalar_dtypet   self_csr(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s:    c         C` s   |  j  | d t S(   NR   (   R   t   True(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __truediv__  s    c         C` s   |  j  | d t S(   NR   (   R   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __div__  s    c         C` s   t  S(   N(   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __rtruediv__  s    c         C` s   t  S(   N(   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __rdiv__  s    c         C` s   |  j    S(   N(   R<   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __neg__  s    c         C` s   t  S(   N(   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __iadd__
  s    c         C` s   t  S(   N(   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __isub__  s    c         C` s   t  S(   N(   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __imul__  s    c         C` s   |  j  |  S(   N(   t   __itruediv__(   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __idiv__  s    c         C` s   t  S(   N(   R   (   R-   Rk   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s   |  j  d |  j  d k r) t d   n  t |  r t |  } | d k  r\ t d   n  | d k r d d l m } | |  j  d d |  j S| d k r |  j   S|  j	 | d  } | d r |  | | S| | Sn t
 |  r t d   n t Sd  S(	   Ni    i   s   matrix is not squares   exponent must be >= 0(   t   eyeRE   i   s   exponent must be an integer(   R5   R2   R   R1   R+   t	   constructR   RE   t   copyt   __pow__R   R   (   R-   Rk   R   t   tmp(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s$    

c         C` s   | d k r |  j    S| d k r, |  j   S| d k rB |  j   S| d k rX |  j   S| d k rn |  j   S| d k r |  j   St | d   d  S(   NRc   t   Tt   Ht   realt   imagt   sizes
    not found(   t   toarrayR   t   getHt   _realt   _imagRQ   R   (   R-   t   attr(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __getattr__2  s    





c         C` s   |  j    j d | d |  S(   s  
        Reverses the dimensions of the sparse matrix.

        Parameters
        ----------
        axes : None, optional
            This argument is in the signature *solely* for NumPy
            compatibility reasons. Do not pass in anything except
            for the default value.
        copy : bool, optional
            Indicates whether or not attributes of `self` should be
            copied whenever possible. The degree to which attributes
            are copied varies depending on the type of sparse matrix
            being used.

        Returns
        -------
        p : `self` with the dimensions reversed.

        See Also
        --------
        np.matrix.transpose : NumPy's implementation of 'transpose'
                              for matrices
        t   axesR   (   R<   R   (   R-   R   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   B  s    c         C` s   |  j    j   S(   s   Element-wise complex conjugation.

        If the matrix is of non-complex data type, then this method does
        nothing and the data is not copied.
        (   R<   t   conj(   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   ]  s    c         C` s
   |  j    S(   N(   R   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt	   conjugatee  s    c         C` s   |  j    j   S(   s   Return the Hermitian transpose of this matrix.

        See Also
        --------
        np.matrix.getH : NumPy's implementation of `getH` for matrices
        (   R   R   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   k  s    c         C` s   |  j    j   S(   N(   R<   R   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   t  s    c         C` s   |  j    j   S(   N(   R<   R   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   w  s    c         C` s3   |  j    } | j d k } | j | | j | f S(   sg  nonzero indices

        Returns a tuple of arrays (row,col) containing the indices
        of the non-zero elements of the matrix.

        Examples
        --------
        >>> from scipy.sparse import csr_matrix
        >>> A = csr_matrix([[1,2,0],[0,0,3],[4,0,5]])
        >>> A.nonzero()
        (array([0, 0, 1, 2, 2]), array([0, 1, 2, 0, 2]))

        i    (   Rb   R_   R]   R^   (   R-   Rc   t   nz_mask(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   nonzeroz  s    c         C` s   d d l  m } |  j d } | d k  r6 | | 7} n  | d k  sN | | k r] t d   n  | d g | g d g g f d | d f d |  j } |  | S(   sg   Returns a copy of column j of the matrix, as an (m x 1) sparse
        matrix (column vector).
        i   (   t
   csc_matrixi    s   index out of boundsR5   RE   (   R   R   R5   t
   IndexErrorRE   (   R-   t   jR   Rp   t   col_selector(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   getcol  s    c         C` s   d d l  m } |  j d } | d k  r6 | | 7} n  | d k  sN | | k r] t d   n  | d g d g | g g f d d | f d |  j } | |  S(   s`   Returns a copy of row i of the matrix, as a (1 x n) sparse
        matrix (row vector).
        i   (   t
   csr_matrixi    s   index out of boundsR5   RE   (   R   R   R5   R   RE   (   R-   t   iR   t   mt   row_selector(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   getrow  s    c         C` s   t  j |  j d | d |   S(   s  
        Return a dense matrix representation of this matrix.

        Parameters
        ----------
        order : {'C', 'F'}, optional
            Whether to store multi-dimensional data in C (row-major)
            or Fortran (column-major) order in memory. The default
            is 'None', indicating the NumPy default of C-ordered.
            Cannot be specified in conjunction with the `out`
            argument.

        out : ndarray, 2-dimensional, optional
            If specified, uses this array (or `numpy.matrix`) as the
            output buffer instead of allocating a new array to
            return. The provided array must have the same shape and
            dtype as the sparse matrix on which you are calling the
            method.

        Returns
        -------
        arr : numpy.matrix, 2-dimensional
            A NumPy matrix object with the same shape and containing
            the same data represented by the sparse matrix, with the
            requested memory order. If `out` was passed and was an
            array (rather than a `numpy.matrix`), it will be filled
            with the appropriate values and returned wrapped in a
            `numpy.matrix` object that shares the same memory.
        R;   Re   (   RG   R   R   (   R-   R;   Re   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s"   |  j  d t  j d | d |  S(   s  
        Return a dense ndarray representation of this matrix.

        Parameters
        ----------
        order : {'C', 'F'}, optional
            Whether to store multi-dimensional data in C (row-major)
            or Fortran (column-major) order in memory. The default
            is 'None', indicating the NumPy default of C-ordered.
            Cannot be specified in conjunction with the `out`
            argument.

        out : ndarray, 2-dimensional, optional
            If specified, uses this array as the output buffer
            instead of allocating a new array to return. The provided
            array must have the same shape and dtype as the sparse
            matrix on which you are calling the method. For most
            sparse types, `out` is required to be memory contiguous
            (either C or Fortran ordered).

        Returns
        -------
        arr : ndarray, 2-dimensional
            An array with the same shape and containing the same
            data represented by the sparse matrix, with the requested
            memory order. If `out` was passed, the same object is
            returned after being modified in-place to contain the
            appropriate values.
        R   R;   Re   (   Rb   R   R   (   R-   R;   Re   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s   |  j  d |  j d t  S(   s   Convert this matrix to Compressed Sparse Row format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant csr_matrix.
        R   (   Rb   R<   R   (   R-   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR<     s    c         C` s   |  j  d |  j d t  S(   s   Convert this matrix to Dictionary Of Keys format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant dok_matrix.
        R   (   Rb   t   todokR   (   R-   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s   |  j  d t  j d |  S(   s   Convert this matrix to COOrdinate format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant coo_matrix.
        R   (   R<   R   Rb   (   R-   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyRb     s    c         C` s   |  j  d t  j d |  S(   s   Convert this matrix to LInked List format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant lil_matrix.
        R   (   R<   R   t   tolil(   R-   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s   |  j  d |  j d t  S(   s   Convert this matrix to sparse DIAgonal format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant dia_matrix.
        R   (   Rb   t   todiaR   (   R-   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    c         C` s"   |  j  d t  j d | d |  S(   s  Convert this matrix to Block Sparse Row format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant bsr_matrix.

        When blocksize=(R, C) is provided, it will be used for construction of
        the bsr_matrix.
        R   t	   blocksize(   R<   R   t   tobsr(   R-   R   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    	c         C` s   |  j  d |  j d t  S(   s   Convert this matrix to Compressed Sparse Column format.

        With copy=False, the data/indices may be shared between this matrix and
        the resultant csc_matrix.
        R   (   R<   t   tocscR   (   R-   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   )  s    c         C` s   |  j  |  d t S(   s   Returns a copy of this matrix.

        No data/indices will be shared between the returned value and current
        matrix.
        R   (   R*   R   (   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   1  s    c         C` s-  t  |  |  j \ } } t |  j  } | d k rl |  t j t j | d f d |  j d | d |  S| d k  r | d 7} n  | d k r t j t j d | f d |  |  } n( |  t j t j | d f d |  } | d k	 r| j | j k rt	 d   n  | j d d	 d | d |  S(
   sq  
        Sum the matrix elements over a given axis.

        Parameters
        ----------
        axis : {-2, -1, 0, 1, None} optional
            Axis along which the sum is computed. The default is to
            compute the sum of all the matrix elements, returning a scalar
            (i.e. `axis` = `None`).
        dtype : dtype, optional
            The type of the returned matrix and of the accumulator in which
            the elements are summed.  The dtype of `a` is used by default
            unless `a` has an integer dtype of less precision than the default
            platform integer.  In that case, if `a` is signed then the platform
            integer is used while if `a` is unsigned then an unsigned integer
            of the same precision as the platform integer is used.

            .. versionadded: 0.18.0

        out : np.matrix, optional
            Alternative output matrix in which to place the result. It must
            have the same shape as the expected output, but the type of the
            output values will be cast if necessary.

            .. versionadded: 0.18.0

        Returns
        -------
        sum_along_axis : np.matrix
            A matrix with the same shape as `self`, with the specified
            axis removed.

        See Also
        --------
        np.matrix.sum : NumPy's implementation of 'sum' for matrices

        i   RE   Re   i    i   s   dimensions do not matchRP   N(    (
   R   R5   R   RE   R(   RG   R   t   onest   sumR+   (   R-   RP   RE   Re   R   Rp   t	   res_dtypet   ret(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR   9  s"    &
	c   	      C` sE  d   } t  |  |  j j } | |  j  } | d	 k rO | ra t j } qa n t j |  j } | rp t j n | } |  j |  } | d	 k r | t j |  j d |  j d  j	 d | d |  S| d k  r | d 7} n  | d k r| d |  j d j	 d d d | d |  S| d |  j d j	 d d d | d |  Sd	 S(
   s  
        Compute the arithmetic mean along the specified axis.

        Returns the average of the matrix elements. The average is taken
        over all elements in the matrix by default, otherwise over the
        specified axis. `float64` intermediate and return values are used
        for integer inputs.

        Parameters
        ----------
        axis : {-2, -1, 0, 1, None} optional
            Axis along which the mean is computed. The default is to compute
            the mean of all elements in the matrix (i.e. `axis` = `None`).
        dtype : data-type, optional
            Type to use in computing the mean. For integer inputs, the default
            is `float64`; for floating point inputs, it is the same as the
            input dtype.

            .. versionadded: 0.18.0

        out : np.matrix, optional
            Alternative output matrix in which to place the result. It must
            have the same shape as the expected output, but the type of the
            output values will be cast if necessary.

            .. versionadded: 0.18.0

        Returns
        -------
        m : np.matrix

        See Also
        --------
        np.matrix.mean : NumPy's implementation of 'mean' for matrices

        c         S` s(   t  j |  t  j  p' t  j |  t  j  S(   N(   RG   R   R   t   bool_(   RE   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   _is_integral  s    i    i   RE   Re   i   g      ?RP   N(
   R   RE   RV   R(   RG   t   float64R=   t   arrayR5   R   (	   R-   RP   RE   Re   R   R   t   integralt   inter_dtypet
   inter_self(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   mean  s*    %	
	c         C` s   |  j    j   S(   s0   Returns the main diagonal of the matrix
        (   R<   t   diagonal(   R-   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s    i    c         C` sl   |  j  \ } } | d k r' | | k s@ | d k  rO | | k rO t d   n  |  j t j |  |  d S(   s  
        Set diagonal or off-diagonal elements of the array.

        Parameters
        ----------
        values : array_like
            New values of the diagonal elements.

            Values may have any length.  If the diagonal is longer than values,
            then the remaining diagonal entries will not be set.  If values if
            longer than the diagonal, then the remaining values are ignored.

            If a scalar value is given, all of the diagonal is set to it.

        k : int, optional
            Which off-diagonal to set, corresponding to elements a[i,i+k].
            Default: 0 (the main diagonal).

        i    s   k exceeds matrix dimensionsN(   R5   R+   t   _setdiagRG   R   (   R-   t   valuest   kR   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   setdiag  s    1c         C` s  |  j  \ } } | d k  r | j d k rk t | | |  } x t |  D] } | |  | | | f <qJ Wqt | | | t |   } | d k r d  Sx t | |   D]  \ } } | |  | | | f <q Wn | j d k rt | | |  } x t |  D] } | |  | | | f <q Wna t | | | t |   } | d k rKd  Sx2 t | |   D]  \ } } | |  | | | f <q\Wd  S(   Ni    (   R5   R   t   minR   R0   t	   enumerate(   R-   R   R   R   R   t	   max_indexR   t   v(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR     s(    c         C` s   | d  k	 rh | d  k	 r' t d   n  | j |  j k sK | j |  j k rZ t d   n  d | d <| St j |  j d |  j d | Sd  S(   Ns,   order cannot be specified if out is not Nones7   out array must be same dtype and shape as sparse matrixg        .RE   R;   (   R(   R+   R5   RE   RG   t   zeros(   R-   R;   Re   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   _process_toarray_args  s    $
c         K` s  t  d   | D  rQ t |  } t j |  d t | | <t | |  | |   S| j d d  } | d k su | ry t St |  } | | =t	 |  } | t j
 k r |  j
 |   }	 n| t j k r |  j |   }	 n| t j k r!| d k r|  j | d  }	 q|  j | d  }	 n| t j k rh| d k rR|  j | d  }	 q|  j | d  }	 n=| t j k rt j d d k }
 | d k } |  j d |
 d	 | |  }	 n | t j k r| d k } |  j d t d	 | |  }	 n | t j k r|  j |   }	 n | t j k r/|  j |   }	 nv | t j k rMt |   }	 nX | t k r| j } t |  |  rt |  |    }	 qt |  j    |    }	 n t S| d k	 rt! | t"  rt! |	 t"  r|	 j#   | d
 <n
 |	 | d
 <| }	 n  |	 S(   sP   Method for compatibility with NumPy's ufuncs and dot
        functions.
        c         s` s7   |  ]- } t  | t  o. t j |  j t k Vq d  S(   N(   R   R	   RG   R   RE   t   object(   t   .0t   x(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pys	   <genexpr>  s   RE   Re   t   __call__i    i   i   R   R   .N($   t   anyR[   RG   R   R   RS   t   popR(   R   R/   Rj   t   addRy   Rn   R   R   t   subtractR{   R|   R   t   syst   version_infoR   R   R   Rl   Rm   t   absoluteRw   t    _ufuncs_with_fixed_point_at_zeroR   t   hasattrR<   R   R	   R   (   R-   t   funct   methodt   post   inputst   kwargst	   with_selfRe   t   without_selfR   R   R   t	   func_name(    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   __numpy_ufunc__  sh    				
	N([   R   R   t   __doc__t   __array_priority__R   t   MAXPRINTR.   R6   R7   t   propertyR5   R3   R=   RK   RM   RN   RO   R(   RQ   RR   RT   RY   Rf   Rg   t   __nonzero__Rh   R>   Rj   Rl   Rm   Rn   Ro   Rq   Rr   Rs   Rt   Ru   Rv   Rx   Ry   Rz   R{   R|   R   R   R~   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R<   R   Rb   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR	   >   s   							
																						L							
+																					 #	HI			c         C` s   t  |  t  S(   N(   R   R	   (   R   (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyR
   W  s    (/   R   t
   __future__R    R   R   R   t   numpyRG   t   scipy._lib.sixR   t   sputilsR   R   R   R   R   t   __all__t   WarningR   R   R   RU   t	   frozensett   sint   tant   arcsint   arctant   sinht   tanht   arcsinht   arctanht   rintt   signt   expm1t   log1pt   deg2radt   rad2degt   floort   ceilt   trunct   sqrtR   R  R   R	   R
   R   (    (    (    s0   /tmp/pip-build-7oUkmx/scipy/scipy/sparse/base.pyt   <module>   sT   (	*$'    	