ls,
the script below does suggest that dot product of sparse (spv) with dense
vector (nsv) is not optimised. Is this correct?
If so, is     +/(5&$.spv)*nsv{~4&$.spv      the best possible alternative?
Thanks in advance,
Jan.

mksv=:3 : 0
 NB. non sparse
 ?y.$0
:
 NB. sparse
 0.9(i.x.)}1$.y.
)
mul=:3 : 0
] spv=:100 mksv y.    NB. less sparse
] nsv=:mksv y.
 ts1=.ts'+/nsv*nsv'
 ts2=.ts'+/nsv*spv'
 ts3=.ts'+/spv*spv'
 {."1 ts1,ts2,:ts3
)
pd'new'
pd'key  +/nsv*nsv +/nsv*spv +/spv*spv'
pd |: mul"0 (1000*>:i.100)
pd'show'
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to