Dictionary Of Keys based sparse matrix.
This is an efficient structure for constructing sparse matrices incrementally.
Notes
Sparse matrices can be used in arithmetic operations: they support addition, subtraction, multiplication, division, and matrix power.
Allows for efficient O(1) access of individual elements. Duplicates are not allowed. Can be efficiently converted to a coo_matrix once constructed.
Examples
>>> from scipy.sparse import *
>>> from scipy import *
>>> S = dok_matrix((5,5), dtype=float32)
>>> for i in range(5):
>>> for j in range(5):
>>> S[i,j] = i+j # Update element
Attributes
shape | |
ndim | |
nnz |
dtype | dtype | Data type of the matrix |
Methods