Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sparse array support #37

Open
smarkesini opened this issue Sep 15, 2019 · 3 comments
Open

sparse array support #37

smarkesini opened this issue Sep 15, 2019 · 3 comments

Comments

@smarkesini
Copy link

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

@FilipeMaia
Copy link
Owner

This is more complicated but I'll see what can be done.

@FilipeMaia
Copy link
Owner

FilipeMaia commented Sep 18, 2019

a84760a 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)

@smarkesini
Copy link
Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants