each suitable for some tasks
many employ sparsetools C++ module by Nathan Bell
assume the following is imported:
>>> import numpy as np
>>> import scipy.sparse as sps
>>> import matplotlib.pyplot as plt
the multiplication with ‘*’ is the matrix multiplication (dot product)
shape, data type set/get
nonzero indices
format conversion, interaction with NumPy (toarray(), todense())
...
data usually stored in NumPy arrays
| format | matrix * vector | get item | fancy get | set item | fancy set | solvers | note |
|---|---|---|---|---|---|---|---|
| DIA | sparsetools | . | . | . | . | iterative | has data array, specialized |
| LIL | via CSR | yes | yes | yes | yes | iterative | arithmetics via CSR, incremental construction |
| DOK | python | yes | one axis only | yes | yes | iterative | O(1) item access, incremental construction |
| COO | sparsetools | . | . | . | . | iterative | has data array, facilitates fast conversion |
| CSR | sparsetools | yes | yes | slow | . | any | has data array, fast row-wise ops |
| CSC | sparsetools | yes | yes | slow | . | any | has data array, fast column-wise ops |
| BSR | sparsetools | . | . | . | . | specialized | has data array, specialized |