I had reason to review the sparse array stuff<http://www.jsoftware.com/papers/sparse.htm> and found the following amusing benchmark. If x is a tri-diagonal system it's more efficient to solve for it using sparse arrays:
n=: 200 x=: (1+(n,n)?@$100) * (n,n)$1|.1 1 1,(n-2)$0 y=: n ?@$ 64 >./ | (y %. x) - y %.&.$. x 2.01119e_11 ts=: 6!:2 , 7!:2@] NB. time and space ts 'y %. x' 0.0710297 3.67123e6 ts 'y %.&.$. x' 0.000313168 145536 The expression y %.&.$. x convert y and x to sparse (ys and xs, say), solve the system using ys%.xs, then convert the result back into dense. Of course, a purely sparse solution is capable of handling larger systems: f=: }. @ }: @ (,/) @ (,."_1 +/&_1 0 1) @ i. NB. indices for a triagonal system n=: 1e6 s=: (1+?. (_2+3*n)$1000) (<"1 f n)} 1 $. (n,n);0 1 $s 1000000 1000000 y=: n ?.@$ 1000 ts 'y %. s' 0.0937907 4.19437e7 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
