afnumpy
afnumpy copied to clipboard
sparse array support
Hello again, this is a feature request: It would be awesome to get some kind of sparse array support, most importantly spmv and spmm with a dense matrix, I realize this is a scipy function, but such basic linear algebra functionality would be nice, something along the lines of S=csr_matrix((data, (row_ind, col_ind)), [shape=(M, N)]) vol=qtS #SpMV where qt is a 1d vector or dense matrix with dimension (,M)
Cheers, Stefano
This is more complicated but I'll see what can be done.
a84760ac21f67d86f7d257bd87eb870e183ada22 add very very basic sparse matrix functionality. It can do something like the following:
import afnumpy.sparse as afsparse
import numpy as np
row = np.array([0, 0, 1, 2, 2, 2])
col = np.array([0, 2, 2, 0, 1, 2])
data = np.array([1, 2, 3, 4, 5, 6], dtype=np.float32)
A = afsparse.csr_matrix((data, (row, col)), shape=(3, 3))
v = np.ones((3),dtype=np.float32)
print(A*v)
Out[]: array([ 3., 3., 15.], dtype=float32)
Awesome, thank you!