Wow- that is what I want.

Thanks
Don

On 14/01/2013 2:13 PM, Raul Miller wrote:
Here's a bit of code to build a sparse symmetric matrix with 0 as the
sparse value:

symamend=: ,~@:({:"1)@[`((<"1@,|."1)@:(}:"1)@[)`]}
buildsym=: ] symamend 1 $. [;i.@#@[;0:

Example use:

    2 2 buildsym 0 0 5,0 1 _1,:1 1 6
0 0 |  5
0 1 | _1
1 0 | _1
1 1 |  6

Left argument is the shape of the sparse array, right argument is the
data.  Note that you'll get an error if the data cannot be contained
within the shape.

FYI,


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to