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,
--
Raul
On Mon, Jan 14, 2013 at 4:56 PM, Don & Cathy Kelly <[email protected]> wrote:
> The J dictionary deals with conversion between the full and sparse matrix
> forms
>
>
> ] M=:> 5 _1;_1 6
> 5 _1
> _1 6
>
> $.M
> 0 0 │ 5
> 0 1 │ _1
> 1 0 │ _1
> 1 1 │ 6
>
> is fine but I would like to enter the row,column and value list as it
> appears in $.M (i.e. as an m by 3 array
> It would also be nice to not have to repeat items in the list (i.e
> M(0,1)=M(1,0)
>
> Don
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm