擅长:python、mysql、java
<p>从coo矩阵文档:</p>
<pre><code> | Intended Usage
| - COO is a fast format for constructing sparse matrices
| - Once a matrix has been constructed, convert to CSR or
| CSC format for fast arithmetic and matrix vector operations
| - By default when converting to CSR or CSC format, duplicate (i,j)
| entries will be summed together. This facilitates efficient
| construction of finite element matrices and the like. (see example)
</code></pre>
<p>实际上,<code>csr_matrix</code>以预期的方式支持索引:</p>
<pre><code>>>> from scipy.sparse import coo_matrix
>>> m = coo_matrix([[1, 2, 3], [4, 5, 6]])
>>> m1 = m.tocsr()
>>> m1[1, 2]
6
>>> m1
<2x3 sparse matrix of type '<type 'numpy.int64'>'
with 6 stored elements in Compressed Sparse Row format>
</code></pre>
<p>(我从文档中找到上述引用的方式是<code>>>> help(m)</code>,相当于<a href="http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.sparse.coo_matrix.html" rel="noreferrer">the online docs</a>)。</p>